diff --git a/CHANGES.txt b/CHANGES.txt index 20c1433820..f0a05f65d4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,7 +16,8 @@ * Fix clustertool to not throw exception when calling get_endpoints (CASSANDRA-2437) * upgrade to thrift 0.6 (CASSANDRA-2412) * repair works on a token range instead of full ring (CASSANDRA-2324) - * purge tombstone from row cache (CASSANDRA-2305) + * purge tombstones from row cache (CASSANDRA-2305) + * push replication_factor into strategy_options (CASSANDRA-1263) 0.7.5 diff --git a/conf/schema-sample.txt b/conf/schema-sample.txt index df2b32038d..5669ff9697 100644 --- a/conf/schema-sample.txt +++ b/conf/schema-sample.txt @@ -9,7 +9,7 @@ client and typing "help;" */ create keyspace Keyspace1 - with replication_factor = 1 + with strategy_options=[{replication_factor:1}] and placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'; use Keyspace1; diff --git a/drivers/py/cql/cassandra/Cassandra.py b/drivers/py/cql/cassandra/Cassandra.py index 939867e298..dbe9ff508a 100644 --- a/drivers/py/cql/cassandra/Cassandra.py +++ b/drivers/py/cql/cassandra/Cassandra.py @@ -128,17 +128,24 @@ class Iface: """ pass + def add(self, key, column_parent, column, consistency_level): + """ + Increment or decrement a counter. + + Parameters: + - key + - column_parent + - column + - consistency_level + """ + pass + def remove(self, key, column_path, timestamp, consistency_level): """ Remove data from the row specified by key at the granularity specified by column_path, and the given timestamp. Note that all the values in column_path besides column_path.column_family are truly optional: you can remove the entire row by just specifying the ColumnFamily, or you can remove a SuperColumn or a single Column by specifying those levels too. - Note that counters have limited support for deletes: if you remove - a counter, you must wait to issue any following update until the - delete has reached all the nodes and all of them have been fully - compacted. - Parameters: - key - column_path @@ -147,6 +154,19 @@ class Iface: """ pass + def remove_counter(self, key, path, consistency_level): + """ + Remove a counter at the specified location. + Note that counters have limited support for deletes: if you remove a counter, you must wait to issue any following update + until the delete has reached all the nodes and all of them have been fully compacted. + + Parameters: + - key + - path + - consistency_level + """ + pass + def batch_mutate(self, mutation_map, consistency_level): """ Mutate many columns or super columns for many row keys. See also: Mutation. @@ -174,64 +194,6 @@ class Iface: """ pass - def add(self, key, column_parent, column, consistency_level): - """ - Increment or decrement a counter. - - Parameters: - - key - - column_parent - - column - - consistency_level - """ - pass - - def get_counter(self, key, path, consistency_level): - """ - Return the counter at the specified column path. - - Parameters: - - key - - path - - consistency_level - """ - pass - - def get_counter_slice(self, key, column_parent, predicate, consistency_level): - """ - Get a list of counters from the specified columns. - - Parameters: - - key - - column_parent - - predicate - - consistency_level - """ - pass - - def multiget_counter_slice(self, keys, column_parent, predicate, consistency_level): - """ - Get counter slices from multiple keys. - - Parameters: - - keys - - column_parent - - predicate - - consistency_level - """ - pass - - def remove_counter(self, key, path, consistency_level): - """ - Remove a counter at the specified location. - - Parameters: - - key - - path - - consistency_level - """ - pass - def describe_schema_versions(self, ): """ for each schema version present in the cluster, returns a list of nodes at that version. @@ -799,17 +761,54 @@ class Client(Iface): raise result.te return + def add(self, key, column_parent, column, consistency_level): + """ + Increment or decrement a counter. + + Parameters: + - key + - column_parent + - column + - consistency_level + """ + self.send_add(key, column_parent, column, consistency_level) + self.recv_add() + + def send_add(self, key, column_parent, column, consistency_level): + self._oprot.writeMessageBegin('add', TMessageType.CALL, self._seqid) + args = add_args() + args.key = key + args.column_parent = column_parent + args.column = column + args.consistency_level = consistency_level + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = add_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.ire != None: + raise result.ire + if result.ue != None: + raise result.ue + if result.te != None: + raise result.te + return + def remove(self, key, column_path, timestamp, consistency_level): """ Remove data from the row specified by key at the granularity specified by column_path, and the given timestamp. Note that all the values in column_path besides column_path.column_family are truly optional: you can remove the entire row by just specifying the ColumnFamily, or you can remove a SuperColumn or a single Column by specifying those levels too. - Note that counters have limited support for deletes: if you remove - a counter, you must wait to issue any following update until the - delete has reached all the nodes and all of them have been fully - compacted. - Parameters: - key - column_path @@ -848,6 +847,48 @@ class Client(Iface): raise result.te return + def remove_counter(self, key, path, consistency_level): + """ + Remove a counter at the specified location. + Note that counters have limited support for deletes: if you remove a counter, you must wait to issue any following update + until the delete has reached all the nodes and all of them have been fully compacted. + + Parameters: + - key + - path + - consistency_level + """ + self.send_remove_counter(key, path, consistency_level) + self.recv_remove_counter() + + def send_remove_counter(self, key, path, consistency_level): + self._oprot.writeMessageBegin('remove_counter', TMessageType.CALL, self._seqid) + args = remove_counter_args() + args.key = key + args.path = path + args.consistency_level = consistency_level + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_remove_counter(self, ): + (fname, mtype, rseqid) = self._iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(self._iprot) + self._iprot.readMessageEnd() + raise x + result = remove_counter_result() + result.read(self._iprot) + self._iprot.readMessageEnd() + if result.ire != None: + raise result.ire + if result.ue != None: + raise result.ue + if result.te != None: + raise result.te + return + def batch_mutate(self, mutation_map, consistency_level): """ Mutate many columns or super columns for many row keys. See also: Mutation. @@ -928,220 +969,6 @@ class Client(Iface): raise result.ue return - def add(self, key, column_parent, column, consistency_level): - """ - Increment or decrement a counter. - - Parameters: - - key - - column_parent - - column - - consistency_level - """ - self.send_add(key, column_parent, column, consistency_level) - self.recv_add() - - def send_add(self, key, column_parent, column, consistency_level): - self._oprot.writeMessageBegin('add', TMessageType.CALL, self._seqid) - args = add_args() - args.key = key - args.column_parent = column_parent - args.column = column - args.consistency_level = consistency_level - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_add(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = add_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.ire != None: - raise result.ire - if result.ue != None: - raise result.ue - if result.te != None: - raise result.te - return - - def get_counter(self, key, path, consistency_level): - """ - Return the counter at the specified column path. - - Parameters: - - key - - path - - consistency_level - """ - self.send_get_counter(key, path, consistency_level) - return self.recv_get_counter() - - def send_get_counter(self, key, path, consistency_level): - self._oprot.writeMessageBegin('get_counter', TMessageType.CALL, self._seqid) - args = get_counter_args() - args.key = key - args.path = path - args.consistency_level = consistency_level - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_get_counter(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = get_counter_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.ire != None: - raise result.ire - if result.nfe != None: - raise result.nfe - if result.ue != None: - raise result.ue - if result.te != None: - raise result.te - raise TApplicationException(TApplicationException.MISSING_RESULT, "get_counter failed: unknown result"); - - def get_counter_slice(self, key, column_parent, predicate, consistency_level): - """ - Get a list of counters from the specified columns. - - Parameters: - - key - - column_parent - - predicate - - consistency_level - """ - self.send_get_counter_slice(key, column_parent, predicate, consistency_level) - return self.recv_get_counter_slice() - - def send_get_counter_slice(self, key, column_parent, predicate, consistency_level): - self._oprot.writeMessageBegin('get_counter_slice', TMessageType.CALL, self._seqid) - args = get_counter_slice_args() - args.key = key - args.column_parent = column_parent - args.predicate = predicate - args.consistency_level = consistency_level - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_get_counter_slice(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = get_counter_slice_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.ire != None: - raise result.ire - if result.ue != None: - raise result.ue - if result.te != None: - raise result.te - raise TApplicationException(TApplicationException.MISSING_RESULT, "get_counter_slice failed: unknown result"); - - def multiget_counter_slice(self, keys, column_parent, predicate, consistency_level): - """ - Get counter slices from multiple keys. - - Parameters: - - keys - - column_parent - - predicate - - consistency_level - """ - self.send_multiget_counter_slice(keys, column_parent, predicate, consistency_level) - return self.recv_multiget_counter_slice() - - def send_multiget_counter_slice(self, keys, column_parent, predicate, consistency_level): - self._oprot.writeMessageBegin('multiget_counter_slice', TMessageType.CALL, self._seqid) - args = multiget_counter_slice_args() - args.keys = keys - args.column_parent = column_parent - args.predicate = predicate - args.consistency_level = consistency_level - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_multiget_counter_slice(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = multiget_counter_slice_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.success != None: - return result.success - if result.ire != None: - raise result.ire - if result.ue != None: - raise result.ue - if result.te != None: - raise result.te - raise TApplicationException(TApplicationException.MISSING_RESULT, "multiget_counter_slice failed: unknown result"); - - def remove_counter(self, key, path, consistency_level): - """ - Remove a counter at the specified location. - - Parameters: - - key - - path - - consistency_level - """ - self.send_remove_counter(key, path, consistency_level) - self.recv_remove_counter() - - def send_remove_counter(self, key, path, consistency_level): - self._oprot.writeMessageBegin('remove_counter', TMessageType.CALL, self._seqid) - args = remove_counter_args() - args.key = key - args.path = path - args.consistency_level = consistency_level - args.write(self._oprot) - self._oprot.writeMessageEnd() - self._oprot.trans.flush() - - def recv_remove_counter(self, ): - (fname, mtype, rseqid) = self._iprot.readMessageBegin() - if mtype == TMessageType.EXCEPTION: - x = TApplicationException() - x.read(self._iprot) - self._iprot.readMessageEnd() - raise x - result = remove_counter_result() - result.read(self._iprot) - self._iprot.readMessageEnd() - if result.ire != None: - raise result.ire - if result.ue != None: - raise result.ue - if result.te != None: - raise result.te - return - def describe_schema_versions(self, ): """ for each schema version present in the cluster, returns a list of nodes at that version. @@ -1711,14 +1538,11 @@ class Processor(Iface, TProcessor): self._processMap["get_range_slices"] = Processor.process_get_range_slices self._processMap["get_indexed_slices"] = Processor.process_get_indexed_slices self._processMap["insert"] = Processor.process_insert + self._processMap["add"] = Processor.process_add self._processMap["remove"] = Processor.process_remove + self._processMap["remove_counter"] = Processor.process_remove_counter self._processMap["batch_mutate"] = Processor.process_batch_mutate self._processMap["truncate"] = Processor.process_truncate - self._processMap["add"] = Processor.process_add - self._processMap["get_counter"] = Processor.process_get_counter - self._processMap["get_counter_slice"] = Processor.process_get_counter_slice - self._processMap["multiget_counter_slice"] = Processor.process_multiget_counter_slice - self._processMap["remove_counter"] = Processor.process_remove_counter self._processMap["describe_schema_versions"] = Processor.process_describe_schema_versions self._processMap["describe_keyspaces"] = Processor.process_describe_keyspaces self._processMap["describe_cluster_name"] = Processor.process_describe_cluster_name @@ -1927,6 +1751,24 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() + def process_add(self, seqid, iprot, oprot): + args = add_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_result() + try: + self._handler.add(args.key, args.column_parent, args.column, args.consistency_level) + except InvalidRequestException, ire: + result.ire = ire + except UnavailableException, ue: + result.ue = ue + except TimedOutException, te: + result.te = te + oprot.writeMessageBegin("add", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_remove(self, seqid, iprot, oprot): args = remove_args() args.read(iprot) @@ -1945,6 +1787,24 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() + def process_remove_counter(self, seqid, iprot, oprot): + args = remove_counter_args() + args.read(iprot) + iprot.readMessageEnd() + result = remove_counter_result() + try: + self._handler.remove_counter(args.key, args.path, args.consistency_level) + except InvalidRequestException, ire: + result.ire = ire + except UnavailableException, ue: + result.ue = ue + except TimedOutException, te: + result.te = te + oprot.writeMessageBegin("remove_counter", TMessageType.REPLY, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + def process_batch_mutate(self, seqid, iprot, oprot): args = batch_mutate_args() args.read(iprot) @@ -1979,98 +1839,6 @@ class Processor(Iface, TProcessor): oprot.writeMessageEnd() oprot.trans.flush() - def process_add(self, seqid, iprot, oprot): - args = add_args() - args.read(iprot) - iprot.readMessageEnd() - result = add_result() - try: - self._handler.add(args.key, args.column_parent, args.column, args.consistency_level) - except InvalidRequestException, ire: - result.ire = ire - except UnavailableException, ue: - result.ue = ue - except TimedOutException, te: - result.te = te - oprot.writeMessageBegin("add", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_get_counter(self, seqid, iprot, oprot): - args = get_counter_args() - args.read(iprot) - iprot.readMessageEnd() - result = get_counter_result() - try: - result.success = self._handler.get_counter(args.key, args.path, args.consistency_level) - except InvalidRequestException, ire: - result.ire = ire - except NotFoundException, nfe: - result.nfe = nfe - except UnavailableException, ue: - result.ue = ue - except TimedOutException, te: - result.te = te - oprot.writeMessageBegin("get_counter", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_get_counter_slice(self, seqid, iprot, oprot): - args = get_counter_slice_args() - args.read(iprot) - iprot.readMessageEnd() - result = get_counter_slice_result() - try: - result.success = self._handler.get_counter_slice(args.key, args.column_parent, args.predicate, args.consistency_level) - except InvalidRequestException, ire: - result.ire = ire - except UnavailableException, ue: - result.ue = ue - except TimedOutException, te: - result.te = te - oprot.writeMessageBegin("get_counter_slice", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_multiget_counter_slice(self, seqid, iprot, oprot): - args = multiget_counter_slice_args() - args.read(iprot) - iprot.readMessageEnd() - result = multiget_counter_slice_result() - try: - result.success = self._handler.multiget_counter_slice(args.keys, args.column_parent, args.predicate, args.consistency_level) - except InvalidRequestException, ire: - result.ire = ire - except UnavailableException, ue: - result.ue = ue - except TimedOutException, te: - result.te = te - oprot.writeMessageBegin("multiget_counter_slice", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - - def process_remove_counter(self, seqid, iprot, oprot): - args = remove_counter_args() - args.read(iprot) - iprot.readMessageEnd() - result = remove_counter_result() - try: - self._handler.remove_counter(args.key, args.path, args.consistency_level) - except InvalidRequestException, ire: - result.ire = ire - except UnavailableException, ue: - result.ue = ue - except TimedOutException, te: - result.te = te - oprot.writeMessageBegin("remove_counter", TMessageType.REPLY, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - def process_describe_schema_versions(self, seqid, iprot, oprot): args = describe_schema_versions_args() args.read(iprot) @@ -4240,6 +4008,197 @@ class insert_result: def __ne__(self, other): return not (self == other) +class add_args: + """ + Attributes: + - key + - column_parent + - column + - consistency_level + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'key', None, None, ), # 1 + (2, TType.STRUCT, 'column_parent', (ColumnParent, ColumnParent.thrift_spec), None, ), # 2 + (3, TType.STRUCT, 'column', (CounterColumn, CounterColumn.thrift_spec), None, ), # 3 + (4, TType.I32, 'consistency_level', None, 1, ), # 4 + ) + + def __init__(self, key=None, column_parent=None, column=None, consistency_level=thrift_spec[4][4],): + self.key = key + self.column_parent = column_parent + self.column = column + self.consistency_level = consistency_level + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.key = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.column_parent = ColumnParent() + self.column_parent.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.column = CounterColumn() + self.column.read(iprot) + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.I32: + self.consistency_level = iprot.readI32(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('add_args') + if self.key != None: + oprot.writeFieldBegin('key', TType.STRING, 1) + oprot.writeString(self.key) + oprot.writeFieldEnd() + if self.column_parent != None: + oprot.writeFieldBegin('column_parent', TType.STRUCT, 2) + self.column_parent.write(oprot) + oprot.writeFieldEnd() + if self.column != None: + oprot.writeFieldBegin('column', TType.STRUCT, 3) + self.column.write(oprot) + oprot.writeFieldEnd() + if self.consistency_level != None: + oprot.writeFieldBegin('consistency_level', TType.I32, 4) + oprot.writeI32(self.consistency_level) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + if self.key is None: + raise TProtocol.TProtocolException(message='Required field key is unset!') + if self.column_parent is None: + raise TProtocol.TProtocolException(message='Required field column_parent is unset!') + if self.column is None: + raise TProtocol.TProtocolException(message='Required field column is unset!') + if self.consistency_level is None: + raise TProtocol.TProtocolException(message='Required field consistency_level is unset!') + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class add_result: + """ + Attributes: + - ire + - ue + - te + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'ire', (InvalidRequestException, InvalidRequestException.thrift_spec), None, ), # 1 + (2, TType.STRUCT, 'ue', (UnavailableException, UnavailableException.thrift_spec), None, ), # 2 + (3, TType.STRUCT, 'te', (TimedOutException, TimedOutException.thrift_spec), None, ), # 3 + ) + + def __init__(self, ire=None, ue=None, te=None,): + self.ire = ire + self.ue = ue + self.te = te + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.ire = InvalidRequestException() + self.ire.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.ue = UnavailableException() + self.ue.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.te = TimedOutException() + self.te.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('add_result') + if self.ire != None: + oprot.writeFieldBegin('ire', TType.STRUCT, 1) + self.ire.write(oprot) + oprot.writeFieldEnd() + if self.ue != None: + oprot.writeFieldBegin('ue', TType.STRUCT, 2) + self.ue.write(oprot) + oprot.writeFieldEnd() + if self.te != None: + oprot.writeFieldBegin('te', TType.STRUCT, 3) + self.te.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class remove_args: """ Attributes: @@ -4428,6 +4387,182 @@ class remove_result: def __ne__(self, other): return not (self == other) +class remove_counter_args: + """ + Attributes: + - key + - path + - consistency_level + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'key', None, None, ), # 1 + (2, TType.STRUCT, 'path', (ColumnPath, ColumnPath.thrift_spec), None, ), # 2 + (3, TType.I32, 'consistency_level', None, 1, ), # 3 + ) + + def __init__(self, key=None, path=None, consistency_level=thrift_spec[3][4],): + self.key = key + self.path = path + self.consistency_level = consistency_level + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.key = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.path = ColumnPath() + self.path.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I32: + self.consistency_level = iprot.readI32(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('remove_counter_args') + if self.key != None: + oprot.writeFieldBegin('key', TType.STRING, 1) + oprot.writeString(self.key) + oprot.writeFieldEnd() + if self.path != None: + oprot.writeFieldBegin('path', TType.STRUCT, 2) + self.path.write(oprot) + oprot.writeFieldEnd() + if self.consistency_level != None: + oprot.writeFieldBegin('consistency_level', TType.I32, 3) + oprot.writeI32(self.consistency_level) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + if self.key is None: + raise TProtocol.TProtocolException(message='Required field key is unset!') + if self.path is None: + raise TProtocol.TProtocolException(message='Required field path is unset!') + if self.consistency_level is None: + raise TProtocol.TProtocolException(message='Required field consistency_level is unset!') + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class remove_counter_result: + """ + Attributes: + - ire + - ue + - te + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'ire', (InvalidRequestException, InvalidRequestException.thrift_spec), None, ), # 1 + (2, TType.STRUCT, 'ue', (UnavailableException, UnavailableException.thrift_spec), None, ), # 2 + (3, TType.STRUCT, 'te', (TimedOutException, TimedOutException.thrift_spec), None, ), # 3 + ) + + def __init__(self, ire=None, ue=None, te=None,): + self.ire = ire + self.ue = ue + self.te = te + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.ire = InvalidRequestException() + self.ire.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.ue = UnavailableException() + self.ue.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.te = TimedOutException() + self.te.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('remove_counter_result') + if self.ire != None: + oprot.writeFieldBegin('ire', TType.STRUCT, 1) + self.ire.write(oprot) + oprot.writeFieldEnd() + if self.ue != None: + oprot.writeFieldBegin('ue', TType.STRUCT, 2) + self.ue.write(oprot) + oprot.writeFieldEnd() + if self.te != None: + oprot.writeFieldBegin('te', TType.STRUCT, 3) + self.te.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class batch_mutate_args: """ Attributes: @@ -4752,1014 +4887,6 @@ class truncate_result: def __ne__(self, other): return not (self == other) -class add_args: - """ - Attributes: - - key - - column_parent - - column - - consistency_level - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'key', None, None, ), # 1 - (2, TType.STRUCT, 'column_parent', (ColumnParent, ColumnParent.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'column', (CounterColumn, CounterColumn.thrift_spec), None, ), # 3 - (4, TType.I32, 'consistency_level', None, 1, ), # 4 - ) - - def __init__(self, key=None, column_parent=None, column=None, consistency_level=thrift_spec[4][4],): - self.key = key - self.column_parent = column_parent - self.column = column - self.consistency_level = consistency_level - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.key = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.column_parent = ColumnParent() - self.column_parent.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.column = CounterColumn() - self.column.read(iprot) - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I32: - self.consistency_level = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('add_args') - if self.key != None: - oprot.writeFieldBegin('key', TType.STRING, 1) - oprot.writeString(self.key) - oprot.writeFieldEnd() - if self.column_parent != None: - oprot.writeFieldBegin('column_parent', TType.STRUCT, 2) - self.column_parent.write(oprot) - oprot.writeFieldEnd() - if self.column != None: - oprot.writeFieldBegin('column', TType.STRUCT, 3) - self.column.write(oprot) - oprot.writeFieldEnd() - if self.consistency_level != None: - oprot.writeFieldBegin('consistency_level', TType.I32, 4) - oprot.writeI32(self.consistency_level) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - if self.key is None: - raise TProtocol.TProtocolException(message='Required field key is unset!') - if self.column_parent is None: - raise TProtocol.TProtocolException(message='Required field column_parent is unset!') - if self.column is None: - raise TProtocol.TProtocolException(message='Required field column is unset!') - if self.consistency_level is None: - raise TProtocol.TProtocolException(message='Required field consistency_level is unset!') - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class add_result: - """ - Attributes: - - ire - - ue - - te - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'ire', (InvalidRequestException, InvalidRequestException.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ue', (UnavailableException, UnavailableException.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'te', (TimedOutException, TimedOutException.thrift_spec), None, ), # 3 - ) - - def __init__(self, ire=None, ue=None, te=None,): - self.ire = ire - self.ue = ue - self.te = te - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.ire = InvalidRequestException() - self.ire.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ue = UnavailableException() - self.ue.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.te = TimedOutException() - self.te.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('add_result') - if self.ire != None: - oprot.writeFieldBegin('ire', TType.STRUCT, 1) - self.ire.write(oprot) - oprot.writeFieldEnd() - if self.ue != None: - oprot.writeFieldBegin('ue', TType.STRUCT, 2) - self.ue.write(oprot) - oprot.writeFieldEnd() - if self.te != None: - oprot.writeFieldBegin('te', TType.STRUCT, 3) - self.te.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class get_counter_args: - """ - Attributes: - - key - - path - - consistency_level - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'key', None, None, ), # 1 - (2, TType.STRUCT, 'path', (ColumnPath, ColumnPath.thrift_spec), None, ), # 2 - (3, TType.I32, 'consistency_level', None, 1, ), # 3 - ) - - def __init__(self, key=None, path=None, consistency_level=thrift_spec[3][4],): - self.key = key - self.path = path - self.consistency_level = consistency_level - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.key = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.path = ColumnPath() - self.path.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.I32: - self.consistency_level = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('get_counter_args') - if self.key != None: - oprot.writeFieldBegin('key', TType.STRING, 1) - oprot.writeString(self.key) - oprot.writeFieldEnd() - if self.path != None: - oprot.writeFieldBegin('path', TType.STRUCT, 2) - self.path.write(oprot) - oprot.writeFieldEnd() - if self.consistency_level != None: - oprot.writeFieldBegin('consistency_level', TType.I32, 3) - oprot.writeI32(self.consistency_level) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - if self.key is None: - raise TProtocol.TProtocolException(message='Required field key is unset!') - if self.path is None: - raise TProtocol.TProtocolException(message='Required field path is unset!') - if self.consistency_level is None: - raise TProtocol.TProtocolException(message='Required field consistency_level is unset!') - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class get_counter_result: - """ - Attributes: - - success - - ire - - nfe - - ue - - te - """ - - thrift_spec = ( - (0, TType.STRUCT, 'success', (Counter, Counter.thrift_spec), None, ), # 0 - (1, TType.STRUCT, 'ire', (InvalidRequestException, InvalidRequestException.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'nfe', (NotFoundException, NotFoundException.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'ue', (UnavailableException, UnavailableException.thrift_spec), None, ), # 3 - (4, TType.STRUCT, 'te', (TimedOutException, TimedOutException.thrift_spec), None, ), # 4 - ) - - def __init__(self, success=None, ire=None, nfe=None, ue=None, te=None,): - self.success = success - self.ire = ire - self.nfe = nfe - self.ue = ue - self.te = te - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.STRUCT: - self.success = Counter() - self.success.read(iprot) - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.ire = InvalidRequestException() - self.ire.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.nfe = NotFoundException() - self.nfe.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.ue = UnavailableException() - self.ue.read(iprot) - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.STRUCT: - self.te = TimedOutException() - self.te.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('get_counter_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.STRUCT, 0) - self.success.write(oprot) - oprot.writeFieldEnd() - if self.ire != None: - oprot.writeFieldBegin('ire', TType.STRUCT, 1) - self.ire.write(oprot) - oprot.writeFieldEnd() - if self.nfe != None: - oprot.writeFieldBegin('nfe', TType.STRUCT, 2) - self.nfe.write(oprot) - oprot.writeFieldEnd() - if self.ue != None: - oprot.writeFieldBegin('ue', TType.STRUCT, 3) - self.ue.write(oprot) - oprot.writeFieldEnd() - if self.te != None: - oprot.writeFieldBegin('te', TType.STRUCT, 4) - self.te.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class get_counter_slice_args: - """ - Attributes: - - key - - column_parent - - predicate - - consistency_level - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'key', None, None, ), # 1 - (2, TType.STRUCT, 'column_parent', (ColumnParent, ColumnParent.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'predicate', (SlicePredicate, SlicePredicate.thrift_spec), None, ), # 3 - (4, TType.I32, 'consistency_level', None, 1, ), # 4 - ) - - def __init__(self, key=None, column_parent=None, predicate=None, consistency_level=thrift_spec[4][4],): - self.key = key - self.column_parent = column_parent - self.predicate = predicate - self.consistency_level = consistency_level - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.key = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.column_parent = ColumnParent() - self.column_parent.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.predicate = SlicePredicate() - self.predicate.read(iprot) - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I32: - self.consistency_level = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('get_counter_slice_args') - if self.key != None: - oprot.writeFieldBegin('key', TType.STRING, 1) - oprot.writeString(self.key) - oprot.writeFieldEnd() - if self.column_parent != None: - oprot.writeFieldBegin('column_parent', TType.STRUCT, 2) - self.column_parent.write(oprot) - oprot.writeFieldEnd() - if self.predicate != None: - oprot.writeFieldBegin('predicate', TType.STRUCT, 3) - self.predicate.write(oprot) - oprot.writeFieldEnd() - if self.consistency_level != None: - oprot.writeFieldBegin('consistency_level', TType.I32, 4) - oprot.writeI32(self.consistency_level) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - if self.key is None: - raise TProtocol.TProtocolException(message='Required field key is unset!') - if self.column_parent is None: - raise TProtocol.TProtocolException(message='Required field column_parent is unset!') - if self.predicate is None: - raise TProtocol.TProtocolException(message='Required field predicate is unset!') - if self.consistency_level is None: - raise TProtocol.TProtocolException(message='Required field consistency_level is unset!') - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class get_counter_slice_result: - """ - Attributes: - - success - - ire - - ue - - te - """ - - thrift_spec = ( - (0, TType.LIST, 'success', (TType.STRUCT,(Counter, Counter.thrift_spec)), None, ), # 0 - (1, TType.STRUCT, 'ire', (InvalidRequestException, InvalidRequestException.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ue', (UnavailableException, UnavailableException.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'te', (TimedOutException, TimedOutException.thrift_spec), None, ), # 3 - ) - - def __init__(self, success=None, ire=None, ue=None, te=None,): - self.success = success - self.ire = ire - self.ue = ue - self.te = te - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.LIST: - self.success = [] - (_etype176, _size173) = iprot.readListBegin() - for _i177 in xrange(_size173): - _elem178 = Counter() - _elem178.read(iprot) - self.success.append(_elem178) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.ire = InvalidRequestException() - self.ire.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ue = UnavailableException() - self.ue.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.te = TimedOutException() - self.te.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('get_counter_slice_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.LIST, 0) - oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter179 in self.success: - iter179.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.ire != None: - oprot.writeFieldBegin('ire', TType.STRUCT, 1) - self.ire.write(oprot) - oprot.writeFieldEnd() - if self.ue != None: - oprot.writeFieldBegin('ue', TType.STRUCT, 2) - self.ue.write(oprot) - oprot.writeFieldEnd() - if self.te != None: - oprot.writeFieldBegin('te', TType.STRUCT, 3) - self.te.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class multiget_counter_slice_args: - """ - Attributes: - - keys - - column_parent - - predicate - - consistency_level - """ - - thrift_spec = ( - None, # 0 - (1, TType.LIST, 'keys', (TType.STRING,None), None, ), # 1 - (2, TType.STRUCT, 'column_parent', (ColumnParent, ColumnParent.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'predicate', (SlicePredicate, SlicePredicate.thrift_spec), None, ), # 3 - (4, TType.I32, 'consistency_level', None, 1, ), # 4 - ) - - def __init__(self, keys=None, column_parent=None, predicate=None, consistency_level=thrift_spec[4][4],): - self.keys = keys - self.column_parent = column_parent - self.predicate = predicate - self.consistency_level = consistency_level - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.LIST: - self.keys = [] - (_etype183, _size180) = iprot.readListBegin() - for _i184 in xrange(_size180): - _elem185 = iprot.readString(); - self.keys.append(_elem185) - iprot.readListEnd() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.column_parent = ColumnParent() - self.column_parent.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.predicate = SlicePredicate() - self.predicate.read(iprot) - else: - iprot.skip(ftype) - elif fid == 4: - if ftype == TType.I32: - self.consistency_level = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('multiget_counter_slice_args') - if self.keys != None: - oprot.writeFieldBegin('keys', TType.LIST, 1) - oprot.writeListBegin(TType.STRING, len(self.keys)) - for iter186 in self.keys: - oprot.writeString(iter186) - oprot.writeListEnd() - oprot.writeFieldEnd() - if self.column_parent != None: - oprot.writeFieldBegin('column_parent', TType.STRUCT, 2) - self.column_parent.write(oprot) - oprot.writeFieldEnd() - if self.predicate != None: - oprot.writeFieldBegin('predicate', TType.STRUCT, 3) - self.predicate.write(oprot) - oprot.writeFieldEnd() - if self.consistency_level != None: - oprot.writeFieldBegin('consistency_level', TType.I32, 4) - oprot.writeI32(self.consistency_level) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - if self.keys is None: - raise TProtocol.TProtocolException(message='Required field keys is unset!') - if self.column_parent is None: - raise TProtocol.TProtocolException(message='Required field column_parent is unset!') - if self.predicate is None: - raise TProtocol.TProtocolException(message='Required field predicate is unset!') - if self.consistency_level is None: - raise TProtocol.TProtocolException(message='Required field consistency_level is unset!') - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class multiget_counter_slice_result: - """ - Attributes: - - success - - ire - - ue - - te - """ - - thrift_spec = ( - (0, TType.MAP, 'success', (TType.STRING,None,TType.LIST,(TType.STRUCT,(Counter, Counter.thrift_spec))), None, ), # 0 - (1, TType.STRUCT, 'ire', (InvalidRequestException, InvalidRequestException.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ue', (UnavailableException, UnavailableException.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'te', (TimedOutException, TimedOutException.thrift_spec), None, ), # 3 - ) - - def __init__(self, success=None, ire=None, ue=None, te=None,): - self.success = success - self.ire = ire - self.ue = ue - self.te = te - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 0: - if ftype == TType.MAP: - self.success = {} - (_ktype188, _vtype189, _size187 ) = iprot.readMapBegin() - for _i191 in xrange(_size187): - _key192 = iprot.readString(); - _val193 = [] - (_etype197, _size194) = iprot.readListBegin() - for _i198 in xrange(_size194): - _elem199 = Counter() - _elem199.read(iprot) - _val193.append(_elem199) - iprot.readListEnd() - self.success[_key192] = _val193 - iprot.readMapEnd() - else: - iprot.skip(ftype) - elif fid == 1: - if ftype == TType.STRUCT: - self.ire = InvalidRequestException() - self.ire.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ue = UnavailableException() - self.ue.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.te = TimedOutException() - self.te.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('multiget_counter_slice_result') - if self.success != None: - oprot.writeFieldBegin('success', TType.MAP, 0) - oprot.writeMapBegin(TType.STRING, TType.LIST, len(self.success)) - for kiter200,viter201 in self.success.items(): - oprot.writeString(kiter200) - oprot.writeListBegin(TType.STRUCT, len(viter201)) - for iter202 in viter201: - iter202.write(oprot) - oprot.writeListEnd() - oprot.writeMapEnd() - oprot.writeFieldEnd() - if self.ire != None: - oprot.writeFieldBegin('ire', TType.STRUCT, 1) - self.ire.write(oprot) - oprot.writeFieldEnd() - if self.ue != None: - oprot.writeFieldBegin('ue', TType.STRUCT, 2) - self.ue.write(oprot) - oprot.writeFieldEnd() - if self.te != None: - oprot.writeFieldBegin('te', TType.STRUCT, 3) - self.te.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class remove_counter_args: - """ - Attributes: - - key - - path - - consistency_level - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'key', None, None, ), # 1 - (2, TType.STRUCT, 'path', (ColumnPath, ColumnPath.thrift_spec), None, ), # 2 - (3, TType.I32, 'consistency_level', None, 1, ), # 3 - ) - - def __init__(self, key=None, path=None, consistency_level=thrift_spec[3][4],): - self.key = key - self.path = path - self.consistency_level = consistency_level - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.key = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.path = ColumnPath() - self.path.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.I32: - self.consistency_level = iprot.readI32(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('remove_counter_args') - if self.key != None: - oprot.writeFieldBegin('key', TType.STRING, 1) - oprot.writeString(self.key) - oprot.writeFieldEnd() - if self.path != None: - oprot.writeFieldBegin('path', TType.STRUCT, 2) - self.path.write(oprot) - oprot.writeFieldEnd() - if self.consistency_level != None: - oprot.writeFieldBegin('consistency_level', TType.I32, 3) - oprot.writeI32(self.consistency_level) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - if self.key is None: - raise TProtocol.TProtocolException(message='Required field key is unset!') - if self.path is None: - raise TProtocol.TProtocolException(message='Required field path is unset!') - if self.consistency_level is None: - raise TProtocol.TProtocolException(message='Required field consistency_level is unset!') - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class remove_counter_result: - """ - Attributes: - - ire - - ue - - te - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'ire', (InvalidRequestException, InvalidRequestException.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'ue', (UnavailableException, UnavailableException.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'te', (TimedOutException, TimedOutException.thrift_spec), None, ), # 3 - ) - - def __init__(self, ire=None, ue=None, te=None,): - self.ire = ire - self.ue = ue - self.te = te - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.ire = InvalidRequestException() - self.ire.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.ue = UnavailableException() - self.ue.read(iprot) - else: - iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.te = TimedOutException() - self.te.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('remove_counter_result') - if self.ire != None: - oprot.writeFieldBegin('ire', TType.STRUCT, 1) - self.ire.write(oprot) - oprot.writeFieldEnd() - if self.ue != None: - oprot.writeFieldBegin('ue', TType.STRUCT, 2) - self.ue.write(oprot) - oprot.writeFieldEnd() - if self.te != None: - oprot.writeFieldBegin('te', TType.STRUCT, 3) - self.te.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - class describe_schema_versions_args: thrift_spec = ( @@ -5829,16 +4956,16 @@ class describe_schema_versions_result: if fid == 0: if ftype == TType.MAP: self.success = {} - (_ktype204, _vtype205, _size203 ) = iprot.readMapBegin() - for _i207 in xrange(_size203): - _key208 = iprot.readString(); - _val209 = [] - (_etype213, _size210) = iprot.readListBegin() - for _i214 in xrange(_size210): - _elem215 = iprot.readString(); - _val209.append(_elem215) + (_ktype174, _vtype175, _size173 ) = iprot.readMapBegin() + for _i177 in xrange(_size173): + _key178 = iprot.readString(); + _val179 = [] + (_etype183, _size180) = iprot.readListBegin() + for _i184 in xrange(_size180): + _elem185 = iprot.readString(); + _val179.append(_elem185) iprot.readListEnd() - self.success[_key208] = _val209 + self.success[_key178] = _val179 iprot.readMapEnd() else: iprot.skip(ftype) @@ -5861,11 +4988,11 @@ class describe_schema_versions_result: if self.success != None: oprot.writeFieldBegin('success', TType.MAP, 0) oprot.writeMapBegin(TType.STRING, TType.LIST, len(self.success)) - for kiter216,viter217 in self.success.items(): - oprot.writeString(kiter216) - oprot.writeListBegin(TType.STRING, len(viter217)) - for iter218 in viter217: - oprot.writeString(iter218) + for kiter186,viter187 in self.success.items(): + oprot.writeString(kiter186) + oprot.writeListBegin(TType.STRING, len(viter187)) + for iter188 in viter187: + oprot.writeString(iter188) oprot.writeListEnd() oprot.writeMapEnd() oprot.writeFieldEnd() @@ -5959,11 +5086,11 @@ class describe_keyspaces_result: if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype222, _size219) = iprot.readListBegin() - for _i223 in xrange(_size219): - _elem224 = KsDef() - _elem224.read(iprot) - self.success.append(_elem224) + (_etype192, _size189) = iprot.readListBegin() + for _i193 in xrange(_size189): + _elem194 = KsDef() + _elem194.read(iprot) + self.success.append(_elem194) iprot.readListEnd() else: iprot.skip(ftype) @@ -5986,8 +5113,8 @@ class describe_keyspaces_result: if self.success != None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter225 in self.success: - iter225.write(oprot) + for iter195 in self.success: + iter195.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.ire != None: @@ -6298,11 +5425,11 @@ class describe_ring_result: if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype229, _size226) = iprot.readListBegin() - for _i230 in xrange(_size226): - _elem231 = TokenRange() - _elem231.read(iprot) - self.success.append(_elem231) + (_etype199, _size196) = iprot.readListBegin() + for _i200 in xrange(_size196): + _elem201 = TokenRange() + _elem201.read(iprot) + self.success.append(_elem201) iprot.readListEnd() else: iprot.skip(ftype) @@ -6325,8 +5452,8 @@ class describe_ring_result: if self.success != None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRUCT, len(self.success)) - for iter232 in self.success: - iter232.write(oprot) + for iter202 in self.success: + iter202.write(oprot) oprot.writeListEnd() oprot.writeFieldEnd() if self.ire != None: @@ -6825,10 +5952,10 @@ class describe_splits_result: if fid == 0: if ftype == TType.LIST: self.success = [] - (_etype236, _size233) = iprot.readListBegin() - for _i237 in xrange(_size233): - _elem238 = iprot.readString(); - self.success.append(_elem238) + (_etype206, _size203) = iprot.readListBegin() + for _i207 in xrange(_size203): + _elem208 = iprot.readString(); + self.success.append(_elem208) iprot.readListEnd() else: iprot.skip(ftype) @@ -6851,8 +5978,8 @@ class describe_splits_result: if self.success != None: oprot.writeFieldBegin('success', TType.LIST, 0) oprot.writeListBegin(TType.STRING, len(self.success)) - for iter239 in self.success: - oprot.writeString(iter239) + for iter209 in self.success: + oprot.writeString(iter209) oprot.writeListEnd() oprot.writeFieldEnd() if self.ire != None: diff --git a/drivers/py/cql/cassandra/constants.py b/drivers/py/cql/cassandra/constants.py index b92ec7940a..012d826395 100644 --- a/drivers/py/cql/cassandra/constants.py +++ b/drivers/py/cql/cassandra/constants.py @@ -7,4 +7,4 @@ from thrift.Thrift import * from ttypes import * -VERSION = "19.5.0" +VERSION = "20.0.0" diff --git a/drivers/py/cql/cassandra/ttypes.py b/drivers/py/cql/cassandra/ttypes.py index 4dbf4a1c1c..0b94d109f6 100644 --- a/drivers/py/cql/cassandra/ttypes.py +++ b/drivers/py/cql/cassandra/ttypes.py @@ -353,6 +353,165 @@ class SuperColumn: def __ne__(self, other): return not (self == other) +class CounterColumn: + """ + Attributes: + - name + - value + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'name', None, None, ), # 1 + (2, TType.I64, 'value', None, None, ), # 2 + ) + + def __init__(self, name=None, value=None,): + self.name = name + self.value = value + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.name = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I64: + self.value = iprot.readI64(); + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('CounterColumn') + if self.name != None: + oprot.writeFieldBegin('name', TType.STRING, 1) + oprot.writeString(self.name) + oprot.writeFieldEnd() + if self.value != None: + oprot.writeFieldBegin('value', TType.I64, 2) + oprot.writeI64(self.value) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + if self.name is None: + raise TProtocol.TProtocolException(message='Required field name is unset!') + if self.value is None: + raise TProtocol.TProtocolException(message='Required field value is unset!') + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + +class CounterSuperColumn: + """ + Attributes: + - name + - columns + """ + + thrift_spec = ( + None, # 0 + (1, TType.STRING, 'name', None, None, ), # 1 + (2, TType.LIST, 'columns', (TType.STRUCT,(CounterColumn, CounterColumn.thrift_spec)), None, ), # 2 + ) + + def __init__(self, name=None, columns=None,): + self.name = name + self.columns = columns + + def read(self, iprot): + if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: + fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRING: + self.name = iprot.readString(); + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.LIST: + self.columns = [] + (_etype10, _size7) = iprot.readListBegin() + for _i11 in xrange(_size7): + _elem12 = CounterColumn() + _elem12.read(iprot) + self.columns.append(_elem12) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: + oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStructBegin('CounterSuperColumn') + if self.name != None: + oprot.writeFieldBegin('name', TType.STRING, 1) + oprot.writeString(self.name) + oprot.writeFieldEnd() + if self.columns != None: + oprot.writeFieldBegin('columns', TType.LIST, 2) + oprot.writeListBegin(TType.STRUCT, len(self.columns)) + for iter13 in self.columns: + iter13.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + def validate(self): + if self.name is None: + raise TProtocol.TProtocolException(message='Required field name is unset!') + if self.columns is None: + raise TProtocol.TProtocolException(message='Required field columns is unset!') + return + + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.iteritems()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + class ColumnOrSuperColumn: """ Methods for fetching rows/records from Cassandra will return either a single instance of ColumnOrSuperColumn or a list @@ -361,23 +520,34 @@ class ColumnOrSuperColumn: in Columns, those values will be in the attribute column. This change was made between 0.3 and 0.4 to standardize on single query methods that may return either a SuperColumn or Column. + If the query was on a counter column family, you will either get a counter_column (instead of a column) or a + counter_super_column (instead of a super_column) + @param column. The Column returned by get() or get_slice(). @param super_column. The SuperColumn returned by get() or get_slice(). + @param counter_column. The Counterolumn returned by get() or get_slice(). + @param counter_super_column. The CounterSuperColumn returned by get() or get_slice(). Attributes: - column - super_column + - counter_column + - counter_super_column """ thrift_spec = ( None, # 0 (1, TType.STRUCT, 'column', (Column, Column.thrift_spec), None, ), # 1 (2, TType.STRUCT, 'super_column', (SuperColumn, SuperColumn.thrift_spec), None, ), # 2 + (3, TType.STRUCT, 'counter_column', (CounterColumn, CounterColumn.thrift_spec), None, ), # 3 + (4, TType.STRUCT, 'counter_super_column', (CounterSuperColumn, CounterSuperColumn.thrift_spec), None, ), # 4 ) - def __init__(self, column=None, super_column=None,): + def __init__(self, column=None, super_column=None, counter_column=None, counter_super_column=None,): self.column = column self.super_column = super_column + self.counter_column = counter_column + self.counter_super_column = counter_super_column def read(self, iprot): if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: @@ -400,6 +570,18 @@ class ColumnOrSuperColumn: self.super_column.read(iprot) else: iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.counter_column = CounterColumn() + self.counter_column.read(iprot) + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.counter_super_column = CounterSuperColumn() + self.counter_super_column.read(iprot) + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -418,6 +600,14 @@ class ColumnOrSuperColumn: oprot.writeFieldBegin('super_column', TType.STRUCT, 2) self.super_column.write(oprot) oprot.writeFieldEnd() + if self.counter_column != None: + oprot.writeFieldBegin('counter_column', TType.STRUCT, 3) + self.counter_column.write(oprot) + oprot.writeFieldEnd() + if self.counter_super_column != None: + oprot.writeFieldBegin('counter_super_column', TType.STRUCT, 4) + self.counter_super_column.write(oprot) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() def validate(self): @@ -998,238 +1188,6 @@ class ColumnPath: def __ne__(self, other): return not (self == other) -class CounterColumn: - """ - Attributes: - - name - - value - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.I64, 'value', None, None, ), # 2 - ) - - def __init__(self, name=None, value=None,): - self.name = name - self.value = value - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.name = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.I64: - self.value = iprot.readI64(); - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('CounterColumn') - if self.name != None: - oprot.writeFieldBegin('name', TType.STRING, 1) - oprot.writeString(self.name) - oprot.writeFieldEnd() - if self.value != None: - oprot.writeFieldBegin('value', TType.I64, 2) - oprot.writeI64(self.value) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - if self.name is None: - raise TProtocol.TProtocolException(message='Required field name is unset!') - if self.value is None: - raise TProtocol.TProtocolException(message='Required field value is unset!') - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class CounterSuperColumn: - """ - Attributes: - - name - - columns - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'name', None, None, ), # 1 - (2, TType.LIST, 'columns', (TType.STRUCT,(CounterColumn, CounterColumn.thrift_spec)), None, ), # 2 - ) - - def __init__(self, name=None, columns=None,): - self.name = name - self.columns = columns - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRING: - self.name = iprot.readString(); - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.LIST: - self.columns = [] - (_etype10, _size7) = iprot.readListBegin() - for _i11 in xrange(_size7): - _elem12 = CounterColumn() - _elem12.read(iprot) - self.columns.append(_elem12) - iprot.readListEnd() - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('CounterSuperColumn') - if self.name != None: - oprot.writeFieldBegin('name', TType.STRING, 1) - oprot.writeString(self.name) - oprot.writeFieldEnd() - if self.columns != None: - oprot.writeFieldBegin('columns', TType.LIST, 2) - oprot.writeListBegin(TType.STRUCT, len(self.columns)) - for iter13 in self.columns: - iter13.write(oprot) - oprot.writeListEnd() - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - if self.name is None: - raise TProtocol.TProtocolException(message='Required field name is unset!') - if self.columns is None: - raise TProtocol.TProtocolException(message='Required field columns is unset!') - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - -class Counter: - """ - Attributes: - - column - - super_column - """ - - thrift_spec = ( - None, # 0 - (1, TType.STRUCT, 'column', (CounterColumn, CounterColumn.thrift_spec), None, ), # 1 - (2, TType.STRUCT, 'super_column', (CounterSuperColumn, CounterSuperColumn.thrift_spec), None, ), # 2 - ) - - def __init__(self, column=None, super_column=None,): - self.column = column - self.super_column = super_column - - def read(self, iprot): - if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: - fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) - return - iprot.readStructBegin() - while True: - (fname, ftype, fid) = iprot.readFieldBegin() - if ftype == TType.STOP: - break - if fid == 1: - if ftype == TType.STRUCT: - self.column = CounterColumn() - self.column.read(iprot) - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.STRUCT: - self.super_column = CounterSuperColumn() - self.super_column.read(iprot) - else: - iprot.skip(ftype) - else: - iprot.skip(ftype) - iprot.readFieldEnd() - iprot.readStructEnd() - - def write(self, oprot): - if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: - oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) - return - oprot.writeStructBegin('Counter') - if self.column != None: - oprot.writeFieldBegin('column', TType.STRUCT, 1) - self.column.write(oprot) - oprot.writeFieldEnd() - if self.super_column != None: - oprot.writeFieldBegin('super_column', TType.STRUCT, 2) - self.super_column.write(oprot) - oprot.writeFieldEnd() - oprot.writeFieldStop() - oprot.writeStructEnd() - def validate(self): - return - - - def __repr__(self): - L = ['%s=%r' % (key, value) - for key, value in self.__dict__.iteritems()] - return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) - - def __eq__(self, other): - return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ - - def __ne__(self, other): - return not (self == other) - class SliceRange: """ A slice range is a structure that stores basic range, ordering and limit information for a query that will return @@ -1995,28 +1953,24 @@ class Deletion: class Mutation: """ - A Mutation is either an insert (represented by filling column_or_supercolumn), a deletion (represented by filling the deletion attribute), - a counter addition (represented by filling counter), or a counter deletion (represented by filling counter_deletion). - @param column_or_supercolumn. An insert to a column or supercolumn + A Mutation is either an insert (represented by filling column_or_supercolumn) or a deletion (represented by filling the deletion attribute). + @param column_or_supercolumn. An insert to a column or supercolumn (possibly counter column or supercolumn) @param deletion. A deletion of a column or supercolumn Attributes: - column_or_supercolumn - deletion - - counter """ thrift_spec = ( None, # 0 (1, TType.STRUCT, 'column_or_supercolumn', (ColumnOrSuperColumn, ColumnOrSuperColumn.thrift_spec), None, ), # 1 (2, TType.STRUCT, 'deletion', (Deletion, Deletion.thrift_spec), None, ), # 2 - (3, TType.STRUCT, 'counter', (Counter, Counter.thrift_spec), None, ), # 3 ) - def __init__(self, column_or_supercolumn=None, deletion=None, counter=None,): + def __init__(self, column_or_supercolumn=None, deletion=None,): self.column_or_supercolumn = column_or_supercolumn self.deletion = deletion - self.counter = counter def read(self, iprot): if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: @@ -2039,12 +1993,6 @@ class Mutation: self.deletion.read(iprot) else: iprot.skip(ftype) - elif fid == 3: - if ftype == TType.STRUCT: - self.counter = Counter() - self.counter.read(iprot) - else: - iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -2063,10 +2011,6 @@ class Mutation: oprot.writeFieldBegin('deletion', TType.STRUCT, 2) self.deletion.write(oprot) oprot.writeFieldEnd() - if self.counter != None: - oprot.writeFieldBegin('counter', TType.STRUCT, 3) - self.counter.write(oprot) - oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() def validate(self): @@ -2407,13 +2351,13 @@ class CfDef: (21, TType.I32, 'memtable_flush_after_mins', None, None, ), # 21 (22, TType.I32, 'memtable_throughput_in_mb', None, None, ), # 22 (23, TType.DOUBLE, 'memtable_operations_in_millions', None, None, ), # 23 - (24, TType.BOOL, 'replicate_on_write', None, False, ), # 24 + (24, TType.BOOL, 'replicate_on_write', None, None, ), # 24 (25, TType.DOUBLE, 'merge_shards_chance', None, None, ), # 25 (26, TType.STRING, 'key_validation_class', None, None, ), # 26 (27, TType.STRING, 'row_cache_provider', None, "org.apache.cassandra.cache.ConcurrentLinkedHashCacheProvider", ), # 27 ) - def __init__(self, keyspace=None, name=None, column_type=thrift_spec[3][4], comparator_type=thrift_spec[5][4], subcomparator_type=None, comment=None, row_cache_size=thrift_spec[9][4], key_cache_size=thrift_spec[11][4], read_repair_chance=thrift_spec[12][4], column_metadata=None, gc_grace_seconds=None, default_validation_class=None, id=None, min_compaction_threshold=None, max_compaction_threshold=None, row_cache_save_period_in_seconds=None, key_cache_save_period_in_seconds=None, memtable_flush_after_mins=None, memtable_throughput_in_mb=None, memtable_operations_in_millions=None, replicate_on_write=thrift_spec[24][4], merge_shards_chance=None, key_validation_class=None, row_cache_provider=thrift_spec[27][4],): + def __init__(self, keyspace=None, name=None, column_type=thrift_spec[3][4], comparator_type=thrift_spec[5][4], subcomparator_type=None, comment=None, row_cache_size=thrift_spec[9][4], key_cache_size=thrift_spec[11][4], read_repair_chance=thrift_spec[12][4], column_metadata=None, gc_grace_seconds=None, default_validation_class=None, id=None, min_compaction_threshold=None, max_compaction_threshold=None, row_cache_save_period_in_seconds=None, key_cache_save_period_in_seconds=None, memtable_flush_after_mins=None, memtable_throughput_in_mb=None, memtable_operations_in_millions=None, replicate_on_write=None, merge_shards_chance=None, key_validation_class=None, row_cache_provider=thrift_spec[27][4],): self.keyspace = keyspace self.name = name self.column_type = column_type @@ -2710,7 +2654,6 @@ class KsDef: - name - strategy_class - strategy_options - - replication_factor - cf_defs """ @@ -2719,15 +2662,13 @@ class KsDef: (1, TType.STRING, 'name', None, None, ), # 1 (2, TType.STRING, 'strategy_class', None, None, ), # 2 (3, TType.MAP, 'strategy_options', (TType.STRING,None,TType.STRING,None), None, ), # 3 - (4, TType.I32, 'replication_factor', None, None, ), # 4 - (5, TType.LIST, 'cf_defs', (TType.STRUCT,(CfDef, CfDef.thrift_spec)), None, ), # 5 + (4, TType.LIST, 'cf_defs', (TType.STRUCT,(CfDef, CfDef.thrift_spec)), None, ), # 4 ) - def __init__(self, name=None, strategy_class=None, strategy_options=None, replication_factor=None, cf_defs=None,): + def __init__(self, name=None, strategy_class=None, strategy_options=None, cf_defs=None,): self.name = name self.strategy_class = strategy_class self.strategy_options = strategy_options - self.replication_factor = replication_factor self.cf_defs = cf_defs def read(self, iprot): @@ -2761,11 +2702,6 @@ class KsDef: else: iprot.skip(ftype) elif fid == 4: - if ftype == TType.I32: - self.replication_factor = iprot.readI32(); - else: - iprot.skip(ftype) - elif fid == 5: if ftype == TType.LIST: self.cf_defs = [] (_etype68, _size65) = iprot.readListBegin() @@ -2802,12 +2738,8 @@ class KsDef: oprot.writeString(viter72) oprot.writeMapEnd() oprot.writeFieldEnd() - if self.replication_factor != None: - oprot.writeFieldBegin('replication_factor', TType.I32, 4) - oprot.writeI32(self.replication_factor) - oprot.writeFieldEnd() if self.cf_defs != None: - oprot.writeFieldBegin('cf_defs', TType.LIST, 5) + oprot.writeFieldBegin('cf_defs', TType.LIST, 4) oprot.writeListBegin(TType.STRUCT, len(self.cf_defs)) for iter73 in self.cf_defs: iter73.write(oprot) @@ -2820,8 +2752,6 @@ class KsDef: raise TProtocol.TProtocolException(message='Required field name is unset!') if self.strategy_class is None: raise TProtocol.TProtocolException(message='Required field strategy_class is unset!') - if self.replication_factor is None: - raise TProtocol.TProtocolException(message='Required field replication_factor is unset!') if self.cf_defs is None: raise TProtocol.TProtocolException(message='Required field cf_defs is unset!') return diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index fe93d54a33..79b9f6c7b0 100644 --- a/interface/cassandra.thrift +++ b/interface/cassandra.thrift @@ -46,7 +46,7 @@ namespace rb CassandraThrift # for every edit that doesn't result in a change to major/minor. # # See the Semantic Versioning Specification (SemVer) http://semver.org. -const string VERSION = "19.5.0" +const string VERSION = "20.0.0" # @@ -401,8 +401,7 @@ struct KsDef { 1: required string name, 2: required string strategy_class, 3: optional map strategy_options, - 4: required i32 replication_factor, - 5: required list cf_defs, + 4: required list cf_defs, } /** CQL query compression */ diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java index 9f42c7f1ad..bb3036a01f 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java @@ -44,6 +44,6 @@ import org.slf4j.LoggerFactory; public class Constants { - public static final String VERSION = "19.5.0"; + public static final String VERSION = "20.0.0"; } diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java index b95467b72d..f276a2b195 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/KsDef.java @@ -48,13 +48,11 @@ public class KsDef implements org.apache.thrift.TBase, jav private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField STRATEGY_CLASS_FIELD_DESC = new org.apache.thrift.protocol.TField("strategy_class", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField STRATEGY_OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("strategy_options", org.apache.thrift.protocol.TType.MAP, (short)3); - private static final org.apache.thrift.protocol.TField REPLICATION_FACTOR_FIELD_DESC = new org.apache.thrift.protocol.TField("replication_factor", org.apache.thrift.protocol.TType.I32, (short)4); - private static final org.apache.thrift.protocol.TField CF_DEFS_FIELD_DESC = new org.apache.thrift.protocol.TField("cf_defs", org.apache.thrift.protocol.TType.LIST, (short)5); + private static final org.apache.thrift.protocol.TField CF_DEFS_FIELD_DESC = new org.apache.thrift.protocol.TField("cf_defs", org.apache.thrift.protocol.TType.LIST, (short)4); public String name; public String strategy_class; public Map strategy_options; - public int replication_factor; public List cf_defs; /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -62,8 +60,7 @@ public class KsDef implements org.apache.thrift.TBase, jav NAME((short)1, "name"), STRATEGY_CLASS((short)2, "strategy_class"), STRATEGY_OPTIONS((short)3, "strategy_options"), - REPLICATION_FACTOR((short)4, "replication_factor"), - CF_DEFS((short)5, "cf_defs"); + CF_DEFS((short)4, "cf_defs"); private static final Map byName = new HashMap(); @@ -84,9 +81,7 @@ public class KsDef implements org.apache.thrift.TBase, jav return STRATEGY_CLASS; case 3: // STRATEGY_OPTIONS return STRATEGY_OPTIONS; - case 4: // REPLICATION_FACTOR - return REPLICATION_FACTOR; - case 5: // CF_DEFS + case 4: // CF_DEFS return CF_DEFS; default: return null; @@ -128,8 +123,6 @@ public class KsDef implements org.apache.thrift.TBase, jav } // isset id assignments - private static final int __REPLICATION_FACTOR_ISSET_ID = 0; - private BitSet __isset_bit_vector = new BitSet(1); public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { @@ -142,8 +135,6 @@ public class KsDef implements org.apache.thrift.TBase, jav new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); - tmpMap.put(_Fields.REPLICATION_FACTOR, new org.apache.thrift.meta_data.FieldMetaData("replication_factor", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.CF_DEFS, new org.apache.thrift.meta_data.FieldMetaData("cf_defs", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CfDef.class)))); @@ -157,14 +148,11 @@ public class KsDef implements org.apache.thrift.TBase, jav public KsDef( String name, String strategy_class, - int replication_factor, List cf_defs) { this(); this.name = name; this.strategy_class = strategy_class; - this.replication_factor = replication_factor; - setReplication_factorIsSet(true); this.cf_defs = cf_defs; } @@ -172,8 +160,6 @@ public class KsDef implements org.apache.thrift.TBase, jav * Performs a deep copy on other. */ public KsDef(KsDef other) { - __isset_bit_vector.clear(); - __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetName()) { this.name = other.name; } @@ -195,7 +181,6 @@ public class KsDef implements org.apache.thrift.TBase, jav } this.strategy_options = __this__strategy_options; } - this.replication_factor = other.replication_factor; if (other.isSetCf_defs()) { List __this__cf_defs = new ArrayList(); for (CfDef other_element : other.cf_defs) { @@ -214,8 +199,6 @@ public class KsDef implements org.apache.thrift.TBase, jav this.name = null; this.strategy_class = null; this.strategy_options = null; - setReplication_factorIsSet(false); - this.replication_factor = 0; this.cf_defs = null; } @@ -302,29 +285,6 @@ public class KsDef implements org.apache.thrift.TBase, jav } } - public int getReplication_factor() { - return this.replication_factor; - } - - public KsDef setReplication_factor(int replication_factor) { - this.replication_factor = replication_factor; - setReplication_factorIsSet(true); - return this; - } - - public void unsetReplication_factor() { - __isset_bit_vector.clear(__REPLICATION_FACTOR_ISSET_ID); - } - - /** Returns true if field replication_factor is set (has been assigned a value) and false otherwise */ - public boolean isSetReplication_factor() { - return __isset_bit_vector.get(__REPLICATION_FACTOR_ISSET_ID); - } - - public void setReplication_factorIsSet(boolean value) { - __isset_bit_vector.set(__REPLICATION_FACTOR_ISSET_ID, value); - } - public int getCf_defsSize() { return (this.cf_defs == null) ? 0 : this.cf_defs.size(); } @@ -390,14 +350,6 @@ public class KsDef implements org.apache.thrift.TBase, jav } break; - case REPLICATION_FACTOR: - if (value == null) { - unsetReplication_factor(); - } else { - setReplication_factor((Integer)value); - } - break; - case CF_DEFS: if (value == null) { unsetCf_defs(); @@ -420,9 +372,6 @@ public class KsDef implements org.apache.thrift.TBase, jav case STRATEGY_OPTIONS: return getStrategy_options(); - case REPLICATION_FACTOR: - return new Integer(getReplication_factor()); - case CF_DEFS: return getCf_defs(); @@ -443,8 +392,6 @@ public class KsDef implements org.apache.thrift.TBase, jav return isSetStrategy_class(); case STRATEGY_OPTIONS: return isSetStrategy_options(); - case REPLICATION_FACTOR: - return isSetReplication_factor(); case CF_DEFS: return isSetCf_defs(); } @@ -491,15 +438,6 @@ public class KsDef implements org.apache.thrift.TBase, jav return false; } - boolean this_present_replication_factor = true; - boolean that_present_replication_factor = true; - if (this_present_replication_factor || that_present_replication_factor) { - if (!(this_present_replication_factor && that_present_replication_factor)) - return false; - if (this.replication_factor != that.replication_factor) - return false; - } - boolean this_present_cf_defs = true && this.isSetCf_defs(); boolean that_present_cf_defs = true && that.isSetCf_defs(); if (this_present_cf_defs || that_present_cf_defs) { @@ -531,11 +469,6 @@ public class KsDef implements org.apache.thrift.TBase, jav if (present_strategy_options) builder.append(strategy_options); - boolean present_replication_factor = true; - builder.append(present_replication_factor); - if (present_replication_factor) - builder.append(replication_factor); - boolean present_cf_defs = true && (isSetCf_defs()); builder.append(present_cf_defs); if (present_cf_defs) @@ -582,16 +515,6 @@ public class KsDef implements org.apache.thrift.TBase, jav return lastComparison; } } - lastComparison = Boolean.valueOf(isSetReplication_factor()).compareTo(typedOther.isSetReplication_factor()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetReplication_factor()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.replication_factor, typedOther.replication_factor); - if (lastComparison != 0) { - return lastComparison; - } - } lastComparison = Boolean.valueOf(isSetCf_defs()).compareTo(typedOther.isSetCf_defs()); if (lastComparison != 0) { return lastComparison; @@ -652,15 +575,7 @@ public class KsDef implements org.apache.thrift.TBase, jav org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); } break; - case 4: // REPLICATION_FACTOR - if (field.type == org.apache.thrift.protocol.TType.I32) { - this.replication_factor = iprot.readI32(); - setReplication_factorIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - } - break; - case 5: // CF_DEFS + case 4: // CF_DEFS if (field.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list37 = iprot.readListBegin(); @@ -686,9 +601,6 @@ public class KsDef implements org.apache.thrift.TBase, jav iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method - if (!isSetReplication_factor()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'replication_factor' was not found in serialized data! Struct: " + toString()); - } validate(); } @@ -721,9 +633,6 @@ public class KsDef implements org.apache.thrift.TBase, jav oprot.writeFieldEnd(); } } - oprot.writeFieldBegin(REPLICATION_FACTOR_FIELD_DESC); - oprot.writeI32(this.replication_factor); - oprot.writeFieldEnd(); if (this.cf_defs != null) { oprot.writeFieldBegin(CF_DEFS_FIELD_DESC); { @@ -771,10 +680,6 @@ public class KsDef implements org.apache.thrift.TBase, jav first = false; } if (!first) sb.append(", "); - sb.append("replication_factor:"); - sb.append(this.replication_factor); - first = false; - if (!first) sb.append(", "); sb.append("cf_defs:"); if (this.cf_defs == null) { sb.append("null"); @@ -794,7 +699,6 @@ public class KsDef implements org.apache.thrift.TBase, jav if (strategy_class == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'strategy_class' was not present! Struct: " + toString()); } - // alas, we cannot check 'replication_factor' because it's a primitive and you chose the non-beans generator. if (cf_defs == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'cf_defs' was not present! Struct: " + toString()); } @@ -810,8 +714,6 @@ public class KsDef implements org.apache.thrift.TBase, jav private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); diff --git a/src/avro/internode.genavro b/src/avro/internode.genavro index b4993c0cf8..23fe90b46f 100644 --- a/src/avro/internode.genavro +++ b/src/avro/internode.genavro @@ -72,7 +72,6 @@ protocol InterNode { string name; string strategy_class; union{ map, null } strategy_options; - int replication_factor; array cf_defs; } diff --git a/src/java/org/apache/cassandra/cli/Cli.g b/src/java/org/apache/cassandra/cli/Cli.g index 00ff348b19..e043378f7a 100644 --- a/src/java/org/apache/cassandra/cli/Cli.g +++ b/src/java/org/apache/cassandra/cli/Cli.g @@ -442,10 +442,6 @@ replica_placement_strategy : StringLiteral ; -replication_factor - : IntegerPositiveLiteral - ; - keyspaceNewName : Identifier ; diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java index c2f78b8abb..23e666ea77 100644 --- a/src/java/org/apache/cassandra/cli/CliClient.java +++ b/src/java/org/apache/cassandra/cli/CliClient.java @@ -93,7 +93,6 @@ public class CliClient extends CliUserHelp * this enum defines which arguments are valid */ private enum AddKeyspaceArgument { - REPLICATION_FACTOR, PLACEMENT_STRATEGY, STRATEGY_OPTIONS } @@ -831,7 +830,7 @@ public class CliClient extends CliUserHelp // first value is the keyspace name, after that it is all key=value String keyspaceName = statement.getChild(0).getText(); - KsDef ksDef = new KsDef(keyspaceName, DEFAULT_PLACEMENT_STRATEGY, 1, new LinkedList()); + KsDef ksDef = new KsDef(keyspaceName, DEFAULT_PLACEMENT_STRATEGY, new LinkedList()); try { @@ -966,9 +965,6 @@ public class CliClient extends CliUserHelp case PLACEMENT_STRATEGY: ksDef.setStrategy_class(CliUtils.unescapeSQLString(mValue)); break; - case REPLICATION_FACTOR: - ksDef.setReplication_factor(Integer.parseInt(mValue)); - break; case STRATEGY_OPTIONS: ksDef.setStrategy_options(getStrategyOptionsFromTree(statement.getChild(i + 1))); break; @@ -1468,15 +1464,8 @@ public class CliClient extends CliUserHelp ks_def = metadata == null ? thriftClient.describe_keyspace(keySpaceName) : metadata; sessionState.out.println(" Replication Strategy: " + ks_def.strategy_class); - if (ks_def.strategy_class.endsWith(".NetworkTopologyStrategy")) - { - Map options = ks_def.strategy_options; - sessionState.out.println(" Options: [" + ((options == null) ? "" : FBUtilities.toString(options)) + "]"); - } - else - { - sessionState.out.println(" Replication Factor: " + ks_def.replication_factor); - } + Map options = ks_def.strategy_options; + sessionState.out.println(" Options: [" + ((options == null) ? "" : FBUtilities.toString(options)) + "]"); sessionState.out.println(" Column Families:"); diff --git a/src/java/org/apache/cassandra/cli/CliUserHelp.java b/src/java/org/apache/cassandra/cli/CliUserHelp.java index 8faebf93c7..5dee2462f1 100644 --- a/src/java/org/apache/cassandra/cli/CliUserHelp.java +++ b/src/java/org/apache/cassandra/cli/CliUserHelp.java @@ -143,20 +143,19 @@ public class CliUserHelp { state.out.println("create keyspace with = and = ...;\n"); state.out.println("Create a new keyspace with the specified values for the given set of attributes.\n"); state.out.println("valid attributes are:"); - state.out.println(" replication_factor: to how many nodes should entries to this keyspace be"); - state.out.println(" replicated. Valid entries are integers greater than 0."); - state.out.println(" Applies to Simple and OldNT strategies but NOT NTS."); state.out.println(" placement_strategy: the fully qualified class used to place replicas in"); state.out.println(" this keyspace. Valid values are"); state.out.println(" org.apache.cassandra.locator.SimpleStrategy,"); state.out.println(" org.apache.cassandra.locator.NetworkTopologyStrategy,"); state.out.println(" and org.apache.cassandra.locator.OldNetworkTopologyStrategy"); state.out.println(" strategy_options: additional options for placement_strategy."); - state.out.println(" Applies only to NetworkTopologyStrategy."); + state.out.println(" Simple and OldNetworkTopology strategies require"); + state.out.println(" 'replication_factor':N, and NetworkTopologyStrategy"); + state.out.println(" requires a map of 'DCName':N per-DC."); state.out.println("\nexamples:"); state.out.println("create keyspace foo with"); - state.out.println(" placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy';"); - state.out.println(" and replication_factor = 3;"); + state.out.println(" placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'"); + state.out.println(" and strategy_options=[{replication_factor:3}];"); state.out.println("create keyspace foo with"); state.out.println(" placement_strategy = 'org.apache.cassandra.locator.NetworkTopologyStrategy';"); state.out.println(" and strategy_options=[{DC1:2, DC2:2}];"); @@ -168,23 +167,22 @@ public class CliUserHelp { state.out.println("update keyspace with = and = ...;\n"); state.out.println("Update a keyspace with the specified values for the given set of attributes.\n"); state.out.println("valid attributes are:"); - state.out.println(" replication_factor: to how many nodes should entries to this keyspace be"); - state.out.println(" replicated. Valid entries are integers greater than 0."); - state.out.println(" Applies to Simple and OldNT strategies but NOT NTS."); state.out.println(" placement_strategy: the fully qualified class used to place replicas in"); state.out.println(" this keyspace. Valid values are"); state.out.println(" org.apache.cassandra.locator.SimpleStrategy,"); state.out.println(" org.apache.cassandra.locator.NetworkTopologyStrategy,"); state.out.println(" and org.apache.cassandra.locator.OldNetworkTopologyStrategy"); state.out.println(" strategy_options: additional options for placement_strategy."); - state.out.println(" Applies only to NetworkTopologyStrategy."); + state.out.println(" Simple and OldNetworkTopology strategies require"); + state.out.println(" 'replication_factor':N, and NetworkTopologyStrategy"); + state.out.println(" requires a map of 'DCName':N per-DC."); state.out.println("\nexamples:"); state.out.println("update keyspace foo with"); - state.out.println(" placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy';"); - state.out.println(" and replication_factor = 3;"); + state.out.println(" placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'"); + state.out.println(" and strategy_options=[{replication_factor:4}];"); state.out.println("update keyspace foo with"); state.out.println(" placement_strategy = 'org.apache.cassandra.locator.NetworkTopologyStrategy';"); - state.out.println(" and strategy_options=[{DC1:2, DC2:2}];"); + state.out.println(" and strategy_options=[{DC1:3, DC2:2}];"); break; case CliParser.NODE_ADD_COLUMN_FAMILY: diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index 0bc5eb389e..c18c95b264 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -368,8 +368,7 @@ public class DatabaseDescriptor // Hardcoded system tables KSMetaData systemMeta = new KSMetaData(Table.SYSTEM_TABLE, LocalStrategy.class, - null, - 1, + KSMetaData.optsWithRF(1), CFMetaData.StatusCf, CFMetaData.HintsCf, CFMetaData.MigrationsCf, diff --git a/src/java/org/apache/cassandra/config/KSMetaData.java b/src/java/org/apache/cassandra/config/KSMetaData.java index 4e7af9482e..b6248f1182 100644 --- a/src/java/org/apache/cassandra/config/KSMetaData.java +++ b/src/java/org/apache/cassandra/config/KSMetaData.java @@ -36,15 +36,13 @@ public final class KSMetaData public final String name; public final Class strategyClass; public final Map strategyOptions; - public final int replicationFactor; private final Map cfMetaData; - public KSMetaData(String name, Class strategyClass, Map strategyOptions, int replicationFactor, CFMetaData... cfDefs) + public KSMetaData(String name, Class strategyClass, Map strategyOptions, CFMetaData... cfDefs) { this.name = name; this.strategyClass = strategyClass == null ? NetworkTopologyStrategy.class : strategyClass; this.strategyOptions = strategyOptions; - this.replicationFactor = replicationFactor; Map cfmap = new HashMap(); for (CFMetaData cfm : cfDefs) cfmap.put(cfm.cfName, cfm); @@ -64,7 +62,6 @@ public final class KSMetaData return other.name.equals(name) && ObjectUtils.equals(other.strategyClass, strategyClass) && ObjectUtils.equals(other.strategyOptions, strategyOptions) - && other.replicationFactor == replicationFactor && other.cfMetaData.size() == cfMetaData.size() && other.cfMetaData.equals(cfMetaData); } @@ -87,7 +84,6 @@ public final class KSMetaData ks.strategy_options.put(new Utf8(e.getKey()), new Utf8(e.getValue())); } } - ks.replication_factor = replicationFactor; ks.cf_defs = SerDeUtils.createArray(cfMetaData.size(), org.apache.cassandra.db.migration.avro.CfDef.SCHEMA$); for (CFMetaData cfm : cfMetaData.values()) ks.cf_defs.add(cfm.deflate()); @@ -99,8 +95,6 @@ public final class KSMetaData { StringBuilder sb = new StringBuilder(); sb.append(name) - .append("rep factor:") - .append(replicationFactor) .append("rep strategy:") .append(strategyClass.getSimpleName()) .append("{") @@ -136,7 +130,7 @@ public final class KSMetaData for (int i = 0; i < cfsz; i++) cfMetaData[i] = CFMetaData.inflate(cfiter.next()); - return new KSMetaData(ks.name.toString(), repStratClass, strategyOptions, ks.replication_factor, cfMetaData); + return new KSMetaData(ks.name.toString(), repStratClass, strategyOptions, cfMetaData); } public static String convertOldStrategyName(String name) @@ -144,4 +138,11 @@ public final class KSMetaData return name.replace("RackUnawareStrategy", "SimpleStrategy") .replace("RackAwareStrategy", "OldNetworkTopologyStrategy"); } + + public static Map optsWithRF(final Integer rf) + { + Map ret = new HashMap(); + ret.put("replication_factor", rf.toString()); + return ret; + } } diff --git a/src/java/org/apache/cassandra/cql/CreateKeyspaceStatement.java b/src/java/org/apache/cassandra/cql/CreateKeyspaceStatement.java index 9774add668..3184c1cdf8 100644 --- a/src/java/org/apache/cassandra/cql/CreateKeyspaceStatement.java +++ b/src/java/org/apache/cassandra/cql/CreateKeyspaceStatement.java @@ -31,7 +31,6 @@ public class CreateKeyspaceStatement private final String name; private final Map attrs; private String strategyClass; - private int replicationFactor; private Map strategyOptions = new HashMap(); /** @@ -65,20 +64,6 @@ public class CreateKeyspaceStatement throw new InvalidRequestException("missing required argument \"strategy_class\""); strategyClass = attrs.get("strategy_class"); - // required - if (!attrs.containsKey("replication_factor")) - throw new InvalidRequestException("missing required argument \"replication_factor\""); - - try - { - replicationFactor = Integer.parseInt(attrs.get("replication_factor")); - } - catch (NumberFormatException e) - { - throw new InvalidRequestException(String.format("\"%s\" is not valid for replication_factor", - attrs.get("replication_factor"))); - } - // optional for (String key : attrs.keySet()) if ((key.contains(":")) && (key.startsWith("strategy_options"))) @@ -94,12 +79,7 @@ public class CreateKeyspaceStatement { return strategyClass; } - - public int getReplicationFactor() - { - return replicationFactor; - } - + public Map getStrategyOptions() { return strategyOptions; diff --git a/src/java/org/apache/cassandra/cql/QueryProcessor.java b/src/java/org/apache/cassandra/cql/QueryProcessor.java index 6657c60ec8..0bd2774a9b 100644 --- a/src/java/org/apache/cassandra/cql/QueryProcessor.java +++ b/src/java/org/apache/cassandra/cql/QueryProcessor.java @@ -640,8 +640,7 @@ public class QueryProcessor { KSMetaData ksm = new KSMetaData(create.getName(), AbstractReplicationStrategy.getClass(create.getStrategyClass()), - create.getStrategyOptions(), - create.getReplicationFactor()); + create.getStrategyOptions()); applyMigrationOnStage(new AddKeyspace(ksm)); } catch (ConfigurationException e) diff --git a/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java b/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java index bf8f0babb4..4bda09ea8e 100644 --- a/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java +++ b/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java @@ -68,7 +68,7 @@ public class AddColumnFamily extends Migration { List newCfs = new ArrayList(ksm.cfMetaData().values()); newCfs.add(cfm); - return new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, ksm.replicationFactor, newCfs.toArray(new CFMetaData[newCfs.size()])); + return new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, newCfs.toArray(new CFMetaData[newCfs.size()])); } public void applyModels() throws IOException diff --git a/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java b/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java index fc0352ee53..1027e3f3f7 100644 --- a/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java +++ b/src/java/org/apache/cassandra/db/migration/DropColumnFamily.java @@ -64,7 +64,7 @@ public class DropColumnFamily extends Migration List newCfs = new ArrayList(ksm.cfMetaData().values()); newCfs.remove(cfm); assert newCfs.size() == ksm.cfMetaData().size() - 1; - return new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, ksm.replicationFactor, newCfs.toArray(new CFMetaData[newCfs.size()])); + return new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, newCfs.toArray(new CFMetaData[newCfs.size()])); } public void applyModels() throws IOException diff --git a/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java b/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java index 666363a862..34b50af244 100644 --- a/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java +++ b/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java @@ -76,7 +76,7 @@ public class RenameColumnFamily extends Migration assert newCfs.size() == ksm.cfMetaData().size() - 1; CFMetaData newCfm = CFMetaData.rename(oldCfm, newName); newCfs.add(newCfm); - return new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, ksm.replicationFactor, newCfs.toArray(new CFMetaData[newCfs.size()])); + return new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, newCfs.toArray(new CFMetaData[newCfs.size()])); } public void applyModels() throws IOException diff --git a/src/java/org/apache/cassandra/db/migration/RenameKeyspace.java b/src/java/org/apache/cassandra/db/migration/RenameKeyspace.java index fa38aaf33f..9a6e2a8929 100644 --- a/src/java/org/apache/cassandra/db/migration/RenameKeyspace.java +++ b/src/java/org/apache/cassandra/db/migration/RenameKeyspace.java @@ -75,7 +75,7 @@ public class RenameKeyspace extends Migration CFMetaData.purge(oldCf); newCfs.add(CFMetaData.renameTable(oldCf, newName)); } - return new KSMetaData(newName, ksm.strategyClass, ksm.strategyOptions, ksm.replicationFactor, newCfs.toArray(new CFMetaData[newCfs.size()])); + return new KSMetaData(newName, ksm.strategyClass, ksm.strategyOptions, newCfs.toArray(new CFMetaData[newCfs.size()])); } public void applyModels() throws IOException diff --git a/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java b/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java index ffc0965f6f..12968da814 100644 --- a/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java +++ b/src/java/org/apache/cassandra/db/migration/UpdateKeyspace.java @@ -51,7 +51,7 @@ public class UpdateKeyspace extends Migration oldKsm = DatabaseDescriptor.getKSMetaData(ksm.name); if (oldKsm == null) throw new ConfigurationException(ksm.name + " cannot be updated because it doesn't exist."); - this.newKsm = new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, ksm.replicationFactor, oldKsm.cfMetaData().values().toArray(new CFMetaData[]{})); + this.newKsm = new KSMetaData(ksm.name, ksm.strategyClass, ksm.strategyOptions, oldKsm.cfMetaData().values().toArray(new CFMetaData[]{})); rm = makeDefinitionMutation(newKsm, oldKsm, newVersion); } diff --git a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java index 1a560a02de..5a945e2ba8 100644 --- a/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java +++ b/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java @@ -30,7 +30,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.cassandra.config.ConfigurationException; -import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.dht.Range; import org.apache.cassandra.dht.Token; import org.apache.cassandra.gms.FailureDetector; @@ -127,10 +126,13 @@ public abstract class AbstractReplicationStrategy return WriteResponseHandler.create(writeEndpoints, hintedEndpoints, consistencyLevel, table); } - public int getReplicationFactor() - { - return DatabaseDescriptor.getTableDefinition(table).replicationFactor; - } + /** + * calculate the RF based on strategy_options. When overwriting, ensure that this get() + * is FAST, as this is called often. + * + * @return the replication factor + */ + public abstract int getReplicationFactor(); /** * returns Multimap of {live destination: ultimate targets}, where if target is not the same @@ -235,6 +237,8 @@ public abstract class AbstractReplicationStrategy clearEndpointCache(); } + public abstract void validateOptions() throws ConfigurationException; + public static AbstractReplicationStrategy createReplicationStrategy(String table, Class strategyClass, TokenMetadata tokenMetadata, @@ -254,6 +258,9 @@ public abstract class AbstractReplicationStrategy throw new RuntimeException(e); } + // Throws Config Exception if strat_opts don't contain required info + strategy.validateOptions(); + return strategy; } diff --git a/src/java/org/apache/cassandra/locator/LocalStrategy.java b/src/java/org/apache/cassandra/locator/LocalStrategy.java index 2ec7846057..609157eb4f 100644 --- a/src/java/org/apache/cassandra/locator/LocalStrategy.java +++ b/src/java/org/apache/cassandra/locator/LocalStrategy.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import org.apache.cassandra.config.ConfigurationException; import org.apache.cassandra.dht.Token; import org.apache.cassandra.utils.FBUtilities; @@ -38,4 +39,14 @@ public class LocalStrategy extends AbstractReplicationStrategy { return Arrays.asList(FBUtilities.getLocalAddress()); } + + public int getReplicationFactor() + { + return 1; + } + + public void validateOptions() throws ConfigurationException + { + // LocalStrategy doesn't expect any options. + } } diff --git a/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java b/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java index 0545f6c54e..f8d11bd475 100644 --- a/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java +++ b/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java @@ -164,4 +164,17 @@ public class NetworkTopologyStrategy extends AbstractReplicationStrategy } return super.getWriteResponseHandler(writeEndpoints, hintedEndpoints, consistency_level); } + + public void validateOptions() throws ConfigurationException + { + for (Entry e : this.configOptions.entrySet()) + { + int rf = Integer.parseInt(e.getValue()); + if (rf < 0) + { + throw new ConfigurationException("Replication factor for NTS must be non-negative. dc: " +e.getKey()+", rf: "+rf); + } + } + + } } diff --git a/src/java/org/apache/cassandra/locator/OldNetworkTopologyStrategy.java b/src/java/org/apache/cassandra/locator/OldNetworkTopologyStrategy.java index aa446eb371..f35a6cd6e2 100644 --- a/src/java/org/apache/cassandra/locator/OldNetworkTopologyStrategy.java +++ b/src/java/org/apache/cassandra/locator/OldNetworkTopologyStrategy.java @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.apache.cassandra.config.ConfigurationException; import org.apache.cassandra.dht.Token; /** @@ -102,4 +103,26 @@ public class OldNetworkTopologyStrategy extends AbstractReplicationStrategy return endpoints; } + + public int getReplicationFactor() + { + return Integer.parseInt(this.configOptions.get("replication_factor")); + } + + public void validateOptions() throws ConfigurationException + { + if (this.configOptions == null) + { + throw new ConfigurationException("OldNetworkTopologyStrategy requires a replication_factor strategy option."); + } + if (this.configOptions.get("replication_factor") == null) + { + throw new ConfigurationException("OldNetworkTopologyStrategy requires a replication_factor strategy option."); + } + int rf = Integer.parseInt(this.configOptions.get("replication_factor")); + if (rf < 0) + { + throw new ConfigurationException("Replication factor for OldNetworkTopologyStrategy must be non-negative, "+rf+" given."); + } + } } diff --git a/src/java/org/apache/cassandra/locator/SimpleStrategy.java b/src/java/org/apache/cassandra/locator/SimpleStrategy.java index 85690d9542..dccae562f4 100644 --- a/src/java/org/apache/cassandra/locator/SimpleStrategy.java +++ b/src/java/org/apache/cassandra/locator/SimpleStrategy.java @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.apache.cassandra.config.ConfigurationException; import org.apache.cassandra.dht.Token; /** @@ -62,4 +63,25 @@ public class SimpleStrategy extends AbstractReplicationStrategy return endpoints; } + public int getReplicationFactor() + { + return Integer.parseInt(this.configOptions.get("replication_factor")); + } + + public void validateOptions() throws ConfigurationException + { + if (this.configOptions == null) + { + throw new ConfigurationException("SimpleStrategy requires a replication_factor strategy option."); + } + if (this.configOptions.get("replication_factor") == null) + { + throw new ConfigurationException("SimpleStrategy requires a replication_factor strategy option."); + } + int rf = Integer.parseInt(this.configOptions.get("replication_factor")); + if (rf < 0) + { + throw new ConfigurationException("Replication factor for SimpleStrategy must be non-negative, "+rf+" given."); + } + } } diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java index bbc061fa5d..affc073d6d 100644 --- a/src/java/org/apache/cassandra/thrift/CassandraServer.java +++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java @@ -49,8 +49,7 @@ import org.apache.cassandra.db.marshal.MarshalException; import org.apache.cassandra.db.migration.*; import org.apache.cassandra.db.context.CounterContext; import org.apache.cassandra.dht.*; -import org.apache.cassandra.locator.AbstractReplicationStrategy; -import org.apache.cassandra.locator.DynamicEndpointSnitch; +import org.apache.cassandra.locator.*; import org.apache.cassandra.scheduler.IRequestScheduler; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.StorageProxy; @@ -563,7 +562,7 @@ public class CassandraServer implements Cassandra.Iface List cfDefs = new ArrayList(); for (CFMetaData cfm : ksm.cfMetaData().values()) cfDefs.add(CFMetaData.convertToThrift(cfm)); - KsDef ksdef = new KsDef(ksm.name, ksm.strategyClass.getName(), ksm.replicationFactor, cfDefs); + KsDef ksdef = new KsDef(ksm.name, ksm.strategyClass.getName(), cfDefs); ksdef.setStrategy_options(ksm.strategyOptions); return ksdef; } @@ -859,11 +858,23 @@ public class CassandraServer implements Cassandra.Iface cfDefs.add(convertToCFMetaData(cfDef)); } + // Attempt to instantiate the ARS, which will throw a ConfigException if + // the strategy_options aren't fully formed or if the ARS Classname is invalid. + TokenMetadata tmd = StorageService.instance.getTokenMetadata(); + IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch(); + Class cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class); + AbstractReplicationStrategy strat = AbstractReplicationStrategy + .createReplicationStrategy(ks_def.name, + cls, + tmd, + eps, + ks_def.strategy_options); + KSMetaData ksm = new KSMetaData(ks_def.name, AbstractReplicationStrategy.getClass(ks_def.strategy_class), ks_def.strategy_options, - ks_def.replication_factor, cfDefs.toArray(new CFMetaData[cfDefs.size()])); + applyMigrationOnStage(new AddKeyspace(ksm)); return DatabaseDescriptor.getDefsVersion().toString(); } @@ -921,11 +932,9 @@ public class CassandraServer implements Cassandra.Iface try { - KSMetaData ksm = new KSMetaData( - ks_def.name, - AbstractReplicationStrategy.getClass(ks_def.strategy_class), - ks_def.strategy_options, - ks_def.replication_factor); + KSMetaData ksm = new KSMetaData(ks_def.name, + AbstractReplicationStrategy.getClass(ks_def.strategy_class), + ks_def.strategy_options); applyMigrationOnStage(new UpdateKeyspace(ksm)); return DatabaseDescriptor.getDefsVersion().toString(); } diff --git a/test/system/__init__.py b/test/system/__init__.py index 27ac5c6043..f6b2d57460 100644 --- a/test/system/__init__.py +++ b/test/system/__init__.py @@ -148,7 +148,7 @@ class ThriftTester(BaseTester): self.client.transport.close() def define_schema(self): - keyspace1 = Cassandra.KsDef('Keyspace1', 'org.apache.cassandra.locator.SimpleStrategy', None, 1, + keyspace1 = Cassandra.KsDef('Keyspace1', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, [ Cassandra.CfDef('Keyspace1', 'Standard1'), Cassandra.CfDef('Keyspace1', 'Standard2'), @@ -167,7 +167,7 @@ class ThriftTester(BaseTester): ]) - keyspace2 = Cassandra.KsDef('Keyspace2', 'org.apache.cassandra.locator.SimpleStrategy', None, 1, + keyspace2 = Cassandra.KsDef('Keyspace2', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, [ Cassandra.CfDef('Keyspace2', 'Standard1'), Cassandra.CfDef('Keyspace2', 'Standard3'), diff --git a/test/system/test_cql.py b/test/system/test_cql.py index 09831ec094..5891b797cb 100644 --- a/test/system/test_cql.py +++ b/test/system/test_cql.py @@ -324,14 +324,13 @@ class TestCql(ThriftTester): "create a new keyspace" init().execute(""" CREATE KEYSPACE TestKeyspace42 WITH strategy_options:DC1 = '1' - AND strategy_class = 'SimpleStrategy' AND replication_factor = 3 + AND strategy_class = 'NetworkTopologyStrategy' """) # TODO: temporary (until this can be done with CQL). ksdef = thrift_client.describe_keyspace("TestKeyspace42") - assert ksdef.replication_factor == 3 - strategy_class = "org.apache.cassandra.locator.SimpleStrategy" + strategy_class = "org.apache.cassandra.locator.NetworkTopologyStrategy" assert ksdef.strategy_class == strategy_class assert ksdef.strategy_options['DC1'] == "1" @@ -340,7 +339,7 @@ class TestCql(ThriftTester): conn = init() conn.execute(""" CREATE KEYSPACE Keyspace4Drop - WITH strategy_class = SimpleStrategy AND replication_factor = 1 + WITH strategy_class = SimpleStrategy AND strategy_options:replication_factor = 1 """) # TODO: temporary (until this can be done with CQL). @@ -358,7 +357,7 @@ class TestCql(ThriftTester): "create a new column family" conn = init() conn.execute(""" - CREATE KEYSPACE CreateCFKeyspace WITH replication_factor = 1 + CREATE KEYSPACE CreateCFKeyspace WITH strategy_options:replication_factor = 1 AND strategy_class = 'SimpleStrategy'; """) conn.execute("USE CreateCFKeyspace;") @@ -422,7 +421,7 @@ class TestCql(ThriftTester): "removing a column family" conn = init() conn.execute(""" - CREATE KEYSPACE Keyspace4CFDrop WITH replication_factor = 1 + CREATE KEYSPACE Keyspace4CFDrop WITH strategy_options:replication_factor = 1 AND strategy_class = 'SimpleStrategy'; """) conn.execute('USE Keyspace4CFDrop;') diff --git a/test/system/test_thrift_server.py b/test/system/test_thrift_server.py index a9c8d99f0c..a40554b1e5 100644 --- a/test/system/test_thrift_server.py +++ b/test/system/test_thrift_server.py @@ -1121,7 +1121,7 @@ class TestMutations(ThriftTester): assert sysks == kspaces[2] ks1 = client.describe_keyspace("Keyspace1") - assert ks1.replication_factor == 1 + assert ks1.strategy_options['replication_factor'] == '1', ks1.strategy_options for cf in ks1.cf_defs: if cf.name == "Standard1": cf0 = cf @@ -1145,20 +1145,20 @@ class TestMutations(ThriftTester): def test_invalid_ks_names(self): def invalid_keyspace(): - client.system_add_keyspace(KsDef('in-valid', 'org.apache.cassandra.locator.SimpleStrategy', {}, 1, [])) + client.system_add_keyspace(KsDef('in-valid', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, [])) _expect_exception(invalid_keyspace, InvalidRequestException) def test_invalid_strategy_class(self): def add_invalid_keyspace(): - client.system_add_keyspace(KsDef('ValidKs', 'InvalidStrategyClass', {}, 1, [])) + client.system_add_keyspace(KsDef('ValidKs', 'InvalidStrategyClass', {}, [])) exc = _expect_exception(add_invalid_keyspace, InvalidRequestException) s = str(exc) assert s.find("InvalidStrategyClass") > -1, s assert s.find("Unable to find replication strategy") > -1, s def update_invalid_keyspace(): - client.system_add_keyspace(KsDef('ValidKsForUpdate', 'org.apache.cassandra.locator.SimpleStrategy', {}, 1, [])) - client.system_update_keyspace(KsDef('ValidKsForUpdate', 'InvalidStrategyClass', {}, 1, [])) + client.system_add_keyspace(KsDef('ValidKsForUpdate', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, [])) + client.system_update_keyspace(KsDef('ValidKsForUpdate', 'InvalidStrategyClass', {}, [])) exc = _expect_exception(update_invalid_keyspace, InvalidRequestException) s = str(exc) @@ -1175,7 +1175,7 @@ class TestMutations(ThriftTester): def invalid_cf_inside_new_ks(): cf = CfDef('ValidKsName_invalid_cf', 'in-valid') _set_keyspace('system') - client.system_add_keyspace(KsDef('ValidKsName_invalid_cf', 'org.apache.cassandra.locator.SimpleStrategy', {}, 1, [cf])) + client.system_add_keyspace(KsDef('ValidKsName_invalid_cf', 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor': '1'}, [cf])) _expect_exception(invalid_cf_inside_new_ks, InvalidRequestException) def test_system_cf_recreate(self): @@ -1187,7 +1187,7 @@ class TestMutations(ThriftTester): # create newcf = CfDef(keyspace, cf_name) - newks = KsDef(keyspace, 'org.apache.cassandra.locator.SimpleStrategy', {}, 1, [newcf]) + newks = KsDef(keyspace, 'org.apache.cassandra.locator.SimpleStrategy', {'replication_factor':'1'}, [newcf]) client.system_add_keyspace(newks) _set_keyspace(keyspace) @@ -1211,7 +1211,9 @@ class TestMutations(ThriftTester): def test_system_keyspace_operations(self): # create. note large RF, this is OK - keyspace = KsDef('CreateKeyspace', 'org.apache.cassandra.locator.SimpleStrategy', {}, 10, + keyspace = KsDef('CreateKeyspace', + 'org.apache.cassandra.locator.SimpleStrategy', + {'replication_factor': '10'}, [CfDef('CreateKeyspace', 'CreateKsCf')]) client.system_add_keyspace(keyspace) newks = client.describe_keyspace('CreateKeyspace') @@ -1220,11 +1222,14 @@ class TestMutations(ThriftTester): _set_keyspace('CreateKeyspace') # modify valid - modified_keyspace = KsDef('CreateKeyspace', 'org.apache.cassandra.locator.OldNetworkTopologyStrategy', {}, 1, []) + modified_keyspace = KsDef('CreateKeyspace', + 'org.apache.cassandra.locator.OldNetworkTopologyStrategy', + {'replication_factor': '1'}, + []) client.system_update_keyspace(modified_keyspace) modks = client.describe_keyspace('CreateKeyspace') - assert modks.replication_factor == modified_keyspace.replication_factor assert modks.strategy_class == modified_keyspace.strategy_class + assert modks.strategy_options == modified_keyspace.strategy_options # drop client.system_drop_keyspace('CreateKeyspace') @@ -1235,7 +1240,7 @@ class TestMutations(ThriftTester): def test_create_then_drop_ks(self): keyspace = KsDef('AddThenDrop', strategy_class='org.apache.cassandra.locator.SimpleStrategy', - replication_factor=1, + strategy_options={'replication_factor':'1'}, cf_defs=[]) def test_existence(): client.describe_keyspace(keyspace.name) diff --git a/test/unit/org/apache/cassandra/SchemaLoader.java b/test/unit/org/apache/cassandra/SchemaLoader.java index c381e7326b..b0fe255cb0 100644 --- a/test/unit/org/apache/cassandra/SchemaLoader.java +++ b/test/unit/org/apache/cassandra/SchemaLoader.java @@ -68,11 +68,11 @@ public class SchemaLoader String ks_rcs = "RowCacheSpace"; Class simple = SimpleStrategy.class; - Map no_opts = Collections.emptyMap(); - int rep_factor1 = 1; - int rep_factor2 = 2; - int rep_factor3 = 3; - int rep_factor5 = 5; + + Map opts_rf1 = KSMetaData.optsWithRF(1); + Map opts_rf2 = KSMetaData.optsWithRF(2); + Map opts_rf3 = KSMetaData.optsWithRF(3); + Map opts_rf5 = KSMetaData.optsWithRF(5); ColumnFamilyType st = ColumnFamilyType.Standard; ColumnFamilyType su = ColumnFamilyType.Super; @@ -81,8 +81,7 @@ public class SchemaLoader // Keyspace 1 schema.add(new KSMetaData(ks1, simple, - no_opts, - rep_factor1, + opts_rf1, // Column Families standardCFMD(ks1, "Standard1"), @@ -125,8 +124,7 @@ public class SchemaLoader // Keyspace 2 schema.add(new KSMetaData(ks2, simple, - no_opts, - rep_factor1, + opts_rf1, // Column Families standardCFMD(ks2, "Standard1"), @@ -138,8 +136,7 @@ public class SchemaLoader // Keyspace 3 schema.add(new KSMetaData(ks3, simple, - no_opts, - rep_factor5, + opts_rf5, // Column Families standardCFMD(ks3, "Standard1"), @@ -148,8 +145,7 @@ public class SchemaLoader // Keyspace 4 schema.add(new KSMetaData(ks4, simple, - no_opts, - rep_factor3, + opts_rf3, // Column Families standardCFMD(ks4, "Standard1"), @@ -166,10 +162,7 @@ public class SchemaLoader // Keyspace 5 schema.add(new KSMetaData(ks5, simple, - no_opts, - rep_factor2, - - // Column Families + opts_rf2, standardCFMD(ks5, "Standard1"), standardCFMD(ks5, "Counter1") .defaultValidator(CounterColumnType.instance))); @@ -177,8 +170,7 @@ public class SchemaLoader // KeyCacheSpace schema.add(new KSMetaData(ks_kcs, simple, - no_opts, - rep_factor1, + opts_rf1, standardCFMD(ks_kcs, "Standard1") .keyCacheSize(0.5), standardCFMD(ks_kcs, "Standard2") @@ -187,8 +179,7 @@ public class SchemaLoader // RowCacheSpace schema.add(new KSMetaData(ks_rcs, simple, - no_opts, - rep_factor1, + opts_rf1, standardCFMD(ks_rcs, "CFWithoutCache"), standardCFMD(ks_rcs, "CachedCF") .rowCacheSize(100))); @@ -217,6 +208,6 @@ public class SchemaLoader } private static CFMetaData jdbcCFMD(String ksName, String cfName, AbstractType comp) { - return new CFMetaData(ksName, cfName, ColumnFamilyType.Standard, comp, null).defaultValidator(comp); + return new CFMetaData(ksName, cfName, ColumnFamilyType.Standard, comp, comp).defaultValidator(comp); } } diff --git a/test/unit/org/apache/cassandra/cli/CliTest.java b/test/unit/org/apache/cassandra/cli/CliTest.java index a214548eca..6d01f4a711 100644 --- a/test/unit/org/apache/cassandra/cli/CliTest.java +++ b/test/unit/org/apache/cassandra/cli/CliTest.java @@ -106,7 +106,7 @@ public class CliTest extends CleanupHelper "get Counter1['hello'];", "truncate CF1;", "update keyspace TestKeySpace with placement_strategy='org.apache.cassandra.locator.LocalStrategy';", - "update keyspace TestKeySpace with replication_factor=1 and strategy_options=[{DC1:3, DC2:4, DC5:1}];", + "update keyspace TestKeySpace with strategy_options=[{DC1:3, DC2:4, DC5:1}];", "assume CF1 comparator as utf8;", "assume CF1 sub_comparator as integer;", "assume CF1 validator as lexicaluuid;", diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java index ddefc28c3a..b739417112 100644 --- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java +++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java @@ -63,7 +63,9 @@ public class DatabaseDescriptorTest { for (KSMetaData ksm : DatabaseDescriptor.tables.values()) { - KSMetaData ksmDupe = KSMetaData.inflate(serDe(ksm.deflate(), new org.apache.cassandra.db.migration.avro.KsDef())); + // Not testing round-trip on the KsDef via serDe() because maps + // cannot be compared in avro. + KSMetaData ksmDupe = KSMetaData.inflate(ksm.deflate()); assert ksmDupe != null; assert ksmDupe.equals(ksm); } @@ -78,9 +80,9 @@ public class DatabaseDescriptorTest assert DatabaseDescriptor.getNonSystemTables().size() == 0; // add a few. - AddKeyspace ks0 = new AddKeyspace(new KSMetaData("ks0", SimpleStrategy.class, null, 3)); + AddKeyspace ks0 = new AddKeyspace(new KSMetaData("ks0", SimpleStrategy.class, KSMetaData.optsWithRF(3))); ks0.apply(); - AddKeyspace ks1 = new AddKeyspace(new KSMetaData("ks1", SimpleStrategy.class, null, 3)); + AddKeyspace ks1 = new AddKeyspace(new KSMetaData("ks1", SimpleStrategy.class, KSMetaData.optsWithRF(3))); ks1.apply(); assert DatabaseDescriptor.getTableDefinition("ks0") != null; diff --git a/test/unit/org/apache/cassandra/db/DefsTest.java b/test/unit/org/apache/cassandra/db/DefsTest.java index 35da85e30b..987885da05 100644 --- a/test/unit/org/apache/cassandra/db/DefsTest.java +++ b/test/unit/org/apache/cassandra/db/DefsTest.java @@ -400,7 +400,7 @@ public class DefsTest extends CleanupHelper DecoratedKey dk = Util.dk("key0"); CFMetaData newCf = addTestCF("NewKeyspace1", "AddedStandard1", "A new cf for a new ks"); - KSMetaData newKs = new KSMetaData(newCf.ksName, SimpleStrategy.class, null, 5, newCf); + KSMetaData newKs = new KSMetaData(newCf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), newCf); new AddKeyspace(newKs).apply(); @@ -579,7 +579,7 @@ public class DefsTest extends CleanupHelper { assert DatabaseDescriptor.getTableDefinition("EmptyKeyspace") == null; - KSMetaData newKs = new KSMetaData("EmptyKeyspace", SimpleStrategy.class, null, 5); + KSMetaData newKs = new KSMetaData("EmptyKeyspace", SimpleStrategy.class, KSMetaData.optsWithRF(5)); new AddKeyspace(newKs).apply(); assert DatabaseDescriptor.getTableDefinition("EmptyKeyspace") != null; @@ -615,7 +615,7 @@ public class DefsTest extends CleanupHelper { // create a keyspace to serve as existing. CFMetaData cf = addTestCF("UpdatedKeyspace", "AddedStandard1", "A new cf for a new ks"); - KSMetaData oldKs = new KSMetaData(cf.ksName, SimpleStrategy.class, null, 5, cf); + KSMetaData oldKs = new KSMetaData(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(5), cf); new AddKeyspace(oldKs).apply(); @@ -624,7 +624,7 @@ public class DefsTest extends CleanupHelper // anything with cf defs should fail. CFMetaData cf2 = addTestCF(cf.ksName, "AddedStandard2", "A new cf for a new ks"); - KSMetaData newBadKs = new KSMetaData(cf.ksName, SimpleStrategy.class, null, 4, cf2); + KSMetaData newBadKs = new KSMetaData(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(4), cf2); try { new UpdateKeyspace(newBadKs).apply(); @@ -636,7 +636,7 @@ public class DefsTest extends CleanupHelper } // names should match. - KSMetaData newBadKs2 = new KSMetaData(cf.ksName + "trash", SimpleStrategy.class, null, 4); + KSMetaData newBadKs2 = new KSMetaData(cf.ksName + "trash", SimpleStrategy.class, KSMetaData.optsWithRF(4)); try { new UpdateKeyspace(newBadKs2).apply(); @@ -647,12 +647,10 @@ public class DefsTest extends CleanupHelper // expected. } - KSMetaData newKs = new KSMetaData(cf.ksName, OldNetworkTopologyStrategy.class, null, 1); + KSMetaData newKs = new KSMetaData(cf.ksName, OldNetworkTopologyStrategy.class, KSMetaData.optsWithRF(1)); new UpdateKeyspace(newKs).apply(); KSMetaData newFetchedKs = DatabaseDescriptor.getKSMetaData(newKs.name); - assert newFetchedKs.replicationFactor == newKs.replicationFactor; - assert newFetchedKs.replicationFactor != oldKs.replicationFactor; assert newFetchedKs.strategyClass.equals(newKs.strategyClass); assert !newFetchedKs.strategyClass.equals(oldKs.strategyClass); } @@ -662,7 +660,7 @@ public class DefsTest extends CleanupHelper { // create a keyspace with a cf to update. CFMetaData cf = addTestCF("UpdatedCfKs", "Standard1added", "A new cf that will be updated"); - KSMetaData ksm = new KSMetaData(cf.ksName, SimpleStrategy.class, null, 1, cf); + KSMetaData ksm = new KSMetaData(cf.ksName, SimpleStrategy.class, KSMetaData.optsWithRF(1), cf); new AddKeyspace(ksm).apply(); assert DatabaseDescriptor.getTableDefinition(cf.ksName) != null; diff --git a/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java b/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java index 288491d3a8..ab1a52b860 100644 --- a/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java +++ b/test/unit/org/apache/cassandra/locator/OldNetworkTopologyStrategyTest.java @@ -32,6 +32,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; import org.apache.cassandra.SchemaLoader; +import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.dht.BigIntegerToken; import org.apache.cassandra.dht.Token; @@ -61,7 +62,7 @@ public class OldNetworkTopologyStrategyTest extends SchemaLoader { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); - AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, null); + AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.0.0.3"); @@ -86,7 +87,7 @@ public class OldNetworkTopologyStrategyTest extends SchemaLoader { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); - AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, null); + AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.1.0.3"); @@ -112,7 +113,7 @@ public class OldNetworkTopologyStrategyTest extends SchemaLoader { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); - AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, null); + AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.0.1.3"); diff --git a/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java b/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java index 42466e9f65..6a57a16d9f 100644 --- a/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java +++ b/test/unit/org/apache/cassandra/locator/SimpleStrategyTest.java @@ -32,6 +32,7 @@ import org.junit.Test; import org.apache.cassandra.CleanupHelper; import org.apache.cassandra.config.ConfigurationException; import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.db.Table; import org.apache.cassandra.dht.*; import org.apache.cassandra.service.StorageService; @@ -177,11 +178,12 @@ public class SimpleStrategyTest extends CleanupHelper private AbstractReplicationStrategy getStrategy(String table, TokenMetadata tmd) throws ConfigurationException { + KSMetaData ksmd = DatabaseDescriptor.getKSMetaData(table); return AbstractReplicationStrategy.createReplicationStrategy( table, - "org.apache.cassandra.locator.SimpleStrategy", + ksmd.strategyClass, tmd, new SimpleSnitch(), - null); + ksmd.strategyOptions); } } diff --git a/test/unit/org/apache/cassandra/service/ConsistencyLevelTest.java b/test/unit/org/apache/cassandra/service/ConsistencyLevelTest.java index 40465808d3..fd3c89151d 100644 --- a/test/unit/org/apache/cassandra/service/ConsistencyLevelTest.java +++ b/test/unit/org/apache/cassandra/service/ConsistencyLevelTest.java @@ -32,6 +32,7 @@ import org.apache.cassandra.CleanupHelper; import org.apache.cassandra.Util; import org.apache.cassandra.config.ConfigurationException; import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.db.Row; import org.apache.cassandra.dht.IPartitioner; import org.apache.cassandra.dht.RandomPartitioner; @@ -177,11 +178,13 @@ public class ConsistencyLevelTest extends CleanupHelper private AbstractReplicationStrategy getStrategy(String table, TokenMetadata tmd) throws ConfigurationException { - return AbstractReplicationStrategy.createReplicationStrategy(table, - "org.apache.cassandra.locator.SimpleStrategy", - tmd, - new SimpleSnitch(), - null); + KSMetaData ksmd = DatabaseDescriptor.getKSMetaData(table); + return AbstractReplicationStrategy.createReplicationStrategy( + table, + ksmd.strategyClass, + tmd, + new SimpleSnitch(), + ksmd.strategyOptions); } } diff --git a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java index ef7037e981..9a13ca70a2 100644 --- a/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java +++ b/test/unit/org/apache/cassandra/service/LeaveAndBootstrapTest.java @@ -32,6 +32,7 @@ import com.google.common.collect.Multimap; import org.apache.cassandra.CleanupHelper; import org.apache.cassandra.Util; import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.dht.*; import org.apache.cassandra.gms.ApplicationState; import org.apache.cassandra.gms.VersionedValue; @@ -613,12 +614,13 @@ public class LeaveAndBootstrapTest extends CleanupHelper private AbstractReplicationStrategy getStrategy(String table, TokenMetadata tmd) throws ConfigurationException { + KSMetaData ksmd = DatabaseDescriptor.getKSMetaData(table); return AbstractReplicationStrategy.createReplicationStrategy( table, - "org.apache.cassandra.locator.SimpleStrategy", + ksmd.strategyClass, tmd, new SimpleSnitch(), - null); + ksmd.strategyOptions); } } diff --git a/test/unit/org/apache/cassandra/service/MoveTest.java b/test/unit/org/apache/cassandra/service/MoveTest.java index 88fb54f44f..3f49071baf 100644 --- a/test/unit/org/apache/cassandra/service/MoveTest.java +++ b/test/unit/org/apache/cassandra/service/MoveTest.java @@ -33,6 +33,7 @@ import com.google.common.collect.Multimap; import org.apache.cassandra.CleanupHelper; import org.apache.cassandra.Util; import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.dht.*; import org.apache.cassandra.gms.ApplicationState; import org.apache.cassandra.gms.VersionedValue; @@ -504,12 +505,13 @@ public class MoveTest extends CleanupHelper private AbstractReplicationStrategy getStrategy(String table, TokenMetadata tmd) throws ConfigurationException { + KSMetaData ksmd = DatabaseDescriptor.getKSMetaData(table); return AbstractReplicationStrategy.createReplicationStrategy( table, - "org.apache.cassandra.locator.SimpleStrategy", + ksmd.strategyClass, tmd, new SimpleSnitch(), - null); + ksmd.strategyOptions); } private Token positionToken(int position)