Я пытаюсь обновить таблицу Cassandra с помощью приведенного ниже сценария.
import requests
import json
import os
from cassandra import ConsistencyLevel
from cassandra.cluster import Cluster
from cassandra.query import SimpleStatement
from cassandra.auth import PlainTextAuthProvider
from cassandra.cqlengine import connection
def main():
pogid_supcs = open("supcpog","r")
print "Connecting to Cassandra \n"
auth_provider = PlainTextAuthProvider(username='XXX', password='XYZEW')
cluster = Cluster(['10.65.120.27','10.65.120.2','10.65.120.24','10.70.120.22','10.70.120.24','10.70.120.23'],auth_provider = auth_provider)
session = cluster.connect()
lines = pogid_supcs.readlines()
pogid_supcs.close()
attributes = open("attributesBackup40.txt","w")
attributeError = open("attributeError1.txt","a")
#attributes.write(" pog_id | supc | attribute_name | value |\n")
for line in lines:
#try:
pogid = long(line.split(",")[1]);
supc = ((line.split(",")[0]).strip()).upper();
print pogid
print supc
statement="update cams_web.product_full set catalog_status='TERMINATED' where pog_id = "+str(pogid)+" and supc = '"+supc+"';"
print statement
session.execute(statement)
# results = session.execute(statement)
# for rows in results:
# print rows.pog_id
# val=(rows.value).encode('ascii','ignore')
# attributes.write(str(rows.pog_id)+","+str(rows.supc)+","+str(rows.attribute_name)+","+str(rows.bucket_id)+","+str(rows.sub_partition)+","+str(rows.attribute_class)+","+str(rows.brand_id)+","+str(rows.created)+","+str(rows.priority)+","+str(rows.updated)+","+val+"\n")
# attributes.write("\n")
# except:
#attributeError.write(pogid"\n")
attributes.close()
if __name__ == "__main__" :
main()
Оператор выполняется нормально, когда я вхожу в систему на одном из этих компьютеров и запускаю запрос на обновление, но когда я пытаюсь ивыполнить запрос через скрипт. Я получаю указанную ниже ошибку.
Error from server: code=1000 [Unavailable exception] message="Cannot achieve consistency level LOCAL_ONE" info={'required_replicas': 1, 'alive_replicas': 0, 'consistency': 'LOCAL_ONE'}
Все компьютеры, к которым я подключаюсь, работают.