Пример #1
0
def setup_module():
    global pool, sys_man
    credentials = {'username': '******', 'password': '******'}
    pool = ConnectionPool(keyspace='PycassaTestKeyspace',
                          credentials=credentials,
                          timeout=1.0)
    sys_man = SystemManager()
Пример #2
0
def setup_module():
    global pool, cf, scf, indexed_cf, sys_man
    credentials = {'username': '******', 'password': '******'}
    pool = ConnectionPool(keyspace='PycassaTestKeyspace', credentials=credentials)
    cf = ColumnFamily(pool, 'Standard1', dict_class=TestDict)
    scf = ColumnFamily(pool, 'Super1', dict_class=dict)
    indexed_cf = ColumnFamily(pool, 'Indexed1')
    sys_man = SystemManager()
Пример #3
0
 def set_server(self, server):
     try:
         self.manager = SystemManager(server, credentials=self.credentials)
     except TTransportException:
         host = server.split(':')[0]
         raise CCliClientConnectionError(
             "Can't connect to %s" % ('local Cassandra server' if host in [
                 'localhost', '127.0.0.1'
             ] else "Cassandra server on '%s'" % host))
Пример #4
0
def setup_module():
    global pool, cf, scf, indexed_cf, counter_cf, counter_scf, sys_man, have_counters
    credentials = {'username': '******', 'password': '******'}
    pool = ConnectionPool(keyspace='PycassaTestKeyspace',
                          credentials=credentials)
    cf = ColumnFamily(pool, 'Standard1', dict_class=TestDict)
    scf = ColumnFamily(pool, 'Super1', dict_class=dict)
    indexed_cf = ColumnFamily(pool, 'Indexed1')
    sys_man = SystemManager()
    have_counters = sys_man._conn.version != CASSANDRA_07
    if have_counters:
        counter_cf = ColumnFamily(pool, 'Counter1')
        counter_scf = ColumnFamily(pool, 'SuperCounter1')
Пример #5
0
#!/usr/bin/env python
from pycassa import SystemManager 

sys = SystemManager('127.0.0.1:9160')
sys.create_keyspace('Articles', replication_factor=1)
for cf in ['RawData', 'PolishedData', 'index']:
    sys.create_column_family('Articles', cf)

#!/usr/bin/python2.7

import ccmlib.cluster
from pycassa import SystemManager, ConnectionPool, ColumnFamily, SIMPLE_STRATEGY, cassandra

values = list(map(str, range(10)))
keyspace, table = 'test_keyspace', 'test_table'

cluster = ccmlib.cluster.Cluster('.', 'thrift-test', partitioner='RandomPartitioner', cassandra_version='3.11.2')
cluster.set_configuration_options({'start_rpc': 'true', 'hinted_handoff_enabled': 'false'})
cluster.populate(3, debug=True).start()
sys = SystemManager('127.0.0.1')
sys.create_keyspace(keyspace, SIMPLE_STRATEGY, {'replication_factor': '3'})
sys.create_column_family(keyspace, table)

# Imitate temporary node unavailability that cause inconsistency in data across nodes
failing_node = cluster.nodelist()[2]
failing_node.stop()
cf = ColumnFamily(ConnectionPool(keyspace, server_list=['127.0.0.1']), table)
for value in values:
    cf.insert(value, {'value': value}, write_consistency_level=cassandra.ttypes.ConsistencyLevel.QUORUM)
failing_node.start()
failing_node.wait_for_thrift_interface()

cf = ColumnFamily(ConnectionPool(keyspace, server_list=['127.0.0.3']), table)
# Returns many Nones records
print(cf.multiget(values, read_consistency_level=cassandra.ttypes.ConsistencyLevel.QUORUM).values())
cf = ColumnFamily(ConnectionPool(keyspace, server_list=['127.0.0.1']), table)
# All returned records are fine
print(cf.multiget(values, read_consistency_level=cassandra.ttypes.ConsistencyLevel.ONE).values())
cluster.stop()