本文整理汇总了Python中pycassa.system_manager.SystemManager类的典型用法代码示例。如果您正苦于以下问题:Python SystemManager类的具体用法?Python SystemManager怎么用?Python SystemManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SystemManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: tearDown
def tearDown(self):
if self.store._store is not None:
self.store.clear()
self.store.close()
from pycassa.system_manager import SystemManager # @UnresolvedImport @IgnorePep8
system_manager = SystemManager('localhost:9160')
system_manager.drop_column_family('Murk', 'shove')
开发者ID:hansent,项目名称:shove,代码行数:7,代码来源:test_store.py
示例2: Cluster
class Cluster(object):
def __init__(self, name):
self.keyspaces = OrderedDict()
self.name = name
self._sm_client = None
cmcache.append('clusters', self)
def setclient(self, servers_list=[connection.DEFAULT_SERVER]):
for server in servers_list:
try:
self._sm_client = SystemManager(server)
return
except:
pass
if self._sm_client is None:
raise NoServerAvailable('Cannot create system_manager connections on server list %s' % str(servers_list))
def registerKeyspace(self, name, keyspc):
self.keyspaces[name] = keyspc
if self._sm_client is None:
self.setclient()
# try to actually register this keyspace to the system via
if not name in self._sm_client.list_keyspaces():
self._sm_client.create_keyspace(name, keyspec.strategy_class)
def __str__(self):
return self.name
开发者ID:hwang3419,项目名称:Comedy,代码行数:28,代码来源:hierachy.py
示例3: setup_class
def setup_class(cls):
sys = SystemManager()
sys.create_column_family(
TEST_KS,
'CustomComposite1',
comparator_type=CompositeType(
IntegerType(),
UTF8Type()))
开发者ID:YinYanfei,项目名称:pycassa,代码行数:8,代码来源:test_autopacking.py
示例4: test_single_component_composite
def test_single_component_composite(self):
sys = SystemManager()
sys.create_column_family(TEST_KS, 'SingleComposite',
comparator_type=CompositeType(IntegerType()))
cf = ColumnFamily(pool, 'SingleComposite')
cf.insert('key', {(123456,): 'val'})
assert_equal(cf.get('key'), {(123456,): 'val'})
开发者ID:YinYanfei,项目名称:pycassa,代码行数:8,代码来源:test_autopacking.py
示例5: delete_namespace
def delete_namespace(self):
sm = SystemManager(self._chosen_server)
try:
sm.drop_keyspace(self._app_namespace)
except pycassa.InvalidRequestException, exc:
if exc.why.startswith('Cannot drop non existing keyspace'):
pass
else:
raise exc
开发者ID:diffeo,项目名称:kvlayer,代码行数:9,代码来源:_cassandra.py
示例6: setUp
def setUp(self):
from shove import Shove
from pycassa.system_manager import SystemManager # @UnresolvedImport @IgnorePep8
system_manager = SystemManager('localhost:9160')
try:
system_manager.create_column_family('Murk', 'shove')
except:
pass
self.store = Shove('cassandra://localhost:9160/Murk/shove')
开发者ID:hansent,项目名称:shove,代码行数:9,代码来源:test_store.py
示例7: setUp
def setUp(self):
from shove import Shove
from pycassa.system_manager import SystemManager
system_manager = SystemManager('localhost:9160')
try:
system_manager.create_column_family('Foo', 'shove')
except:
pass
self.store = Shove('cassandra://localhost:9160/Foo/shove')
开发者ID:13111,项目名称:SickRage,代码行数:9,代码来源:test_cassandra_store.py
示例8: db_export
def db_export(self):
db_contents = {'cassandra': {},
'zookeeper': {}}
cassandra_contents = db_contents['cassandra']
for ks_name in (set(KEYSPACES) -
set(self._args.omit_keyspaces or [])):
if self._api_args.cluster_id:
full_ks_name = '%s_%s' %(self._api_args.cluster_id, ks_name)
else:
full_ks_name = ks_name
cassandra_contents[ks_name] = {}
socket_factory = pycassa.connection.default_socket_factory
if self._api_args.cassandra_use_ssl:
socket_factory = pycassa.connection.make_ssl_socket_factory(
self._api_args.cassandra_ca_certs, validate=False)
pool = pycassa.ConnectionPool(
full_ks_name, self._api_args.cassandra_server_list,
pool_timeout=120, max_retries=-1, timeout=5,
socket_factory=socket_factory)
creds = None
if (self._api_args.cassandra_user and
self._api_args.cassandra_password):
creds = {'username': self._api_args.cassandra_user,
'password': self._api_args.cassandra_password}
sys_mgr = SystemManager(self._api_args.cassandra_server_list[0],
credentials=creds)
for cf_name in sys_mgr.get_keyspace_column_families(full_ks_name):
cassandra_contents[ks_name][cf_name] = {}
cf = pycassa.ColumnFamily(pool, cf_name)
for r,c in cf.get_range(column_count=10000000, include_timestamp=True):
cassandra_contents[ks_name][cf_name][r] = c
def get_nodes(path):
if not zk.get_children(path):
return [(path, zk.get(path))]
nodes = []
for child in zk.get_children(path):
nodes.extend(get_nodes('%s%s/' %(path, child)))
return nodes
zk = kazoo.client.KazooClient(self._api_args.zk_server_ip)
zk.start()
nodes = get_nodes(self._api_args.cluster_id+'/')
zk.stop()
db_contents['zookeeper'] = json.dumps(nodes)
f = open(self._args.export_to, 'w')
try:
f.write(json.dumps(db_contents))
finally:
f.close()
开发者ID:rombie,项目名称:contrail-controller,代码行数:56,代码来源:db_json_exim.py
示例9: CreateCF
def CreateCF(connStr, keySpace, cfs, columesTypeList = None):
sysmgt = SystemManager(connStr)
list = sysmgt.list_keyspaces()
if keySpace in list:
#print('pyagent is existed')
pass
else:
sysmgt.create_keyspace(keySpace, SIMPLE_STRATEGY, {'replication_factor': '3'})
cfDict = sysmgt.get_keyspace_column_families(keySpace)
allCF = cfDict.keys()
for i in range(len(cfs)):
columnFamily = cfs[i]
#print(columnFamily)
if columesTypeList != None:
columes = columesTypeList[i]
else:
columes = None
if columnFamily in allCF:
#print(columnFamily + ' is existed')
pass
else:
#print(columnFamily + ' is creating')
sysmgt.create_column_family(keySpace, columnFamily, super=False,
comparator_type=UTF8_TYPE,
key_validation_class=ASCII_TYPE,
default_validation_class=UTF8_TYPE,
column_validation_classes=columes,
gc_grace_seconds=1000)
sysmgt.close()
开发者ID:wangbokun,项目名称:sms_send,代码行数:31,代码来源:cassandraoperator.py
示例10: get_connection
def get_connection():
"""
Creates a connection to Cassandra.
Returs:
pool
"""
cassandra_host = os.environ.get('CASSANDRA_HOST', 'localhost')
sys_mgr = SystemManager()
try:
sys_mgr.describe_ring(KEYSPACE)
except:
sys_mgr.create_keyspace(KEYSPACE, SIMPLE_STRATEGY, {'replication_factor': '1'})
pool = ConnectionPool(KEYSPACE, server_list=[cassandra_host])
for cf_name in [CF_LOGS, CF_LOGS_BY_APP, CF_LOGS_BY_HOST, CF_LOGS_BY_SEVERITY]:
try:
cf = ColumnFamily(pool, cf_name)
except:
sys_mgr.create_column_family(KEYSPACE, cf_name, comparator_type=TimeUUIDType())
cf = ColumnFamily(pool, cf_name)
cf.get_count(str(uuid.uuid4()))
sys_mgr.close()
return pool
开发者ID:hgdeoro,项目名称:daedalus,代码行数:26,代码来源:simple_client.py
示例11: main
def main(argv):
usage = "Usage: dbdiscover.py"
args, kwargs = parse(argv)
host = kwargs.get('host', settings.DEFAULT_CASSANDRA_HOST)
port = kwargs.get('port', settings.DEFAULT_CASSANDRA_PORT)
try:
system = SystemManager("%s:%s" % (host, port))
ksprops = system.get_keyspace_properties("system").keys()
# header = ["keyspace"] + sorted(ksprops)
header = ["keyspace", "column_family"]
writer = csv.writer(output)
writer.writerow(header)
for keyspace in system.list_keyspaces():
ksinfo = system.get_keyspace_column_families(keyspace, use_dict_for_col_metadata=True)
attrs = [
"id",
"column_type",
"comment",
"comparator_type",
"default_validation_class",
"gc_grace_seconds",
"key_alias",
"key_cache_save_period_in_seconds",
"key_cache_size",
"key_validation_class",
"max_compaction_threshold",
"memtable_operations_in_millions",
"memtable_throughput_in_mb",
"memtable_flush_after_mins",
"merge_shards_chance",
"min_compaction_threshold",
"read_repair_chance",
"replicate_on_write",
"row_cache_provider",
"row_cache_save_period_in_seconds",
"row_cache_size",
"subcomparator_type",
]
for cfname, cfdef in ksinfo.iteritems():
ks = ("keyspace="+ keyspace)
cf = ("column_family="+ cfname)
row =(ks, cf)
writer.writerow(row)
return
except:
error(output, excinfo(), 2)
开发者ID:esatterly,项目名称:splunk-cassandra,代码行数:54,代码来源:dbdiscover.py
示例12: create
def create():
keyspace = configuration.cassandra_keyspace
mgr = SystemManager()
try:
workaround_1779(mgr.create_column_family, keyspace, 'Indexes',
comparator_type=UTF8_TYPE)
workaround_1779(mgr.create_column_family, keyspace, 'Stacktrace',
comparator_type=UTF8_TYPE)
workaround_1779(mgr.create_column_family, keyspace, 'AwaitingRetrace',
comparator_type=UTF8_TYPE)
finally:
mgr.close()
开发者ID:pexip,项目名称:os-whoopsie-daisy,代码行数:12,代码来源:schema.py
示例13: handle
def handle(self, **options):
"""
:param options:
"""
sys = SystemManager(server=CASSANDRA_HOSTS[0])
sys.create_column_family(CASSANDRA_SESSIONS_KEYSPACE, CASSANDRA_SESSIONS_COLUMN_FAMILY,
key_validation_class=types.UTF8Type(),
column_validation_classes={
'session_data': types.UTF8Type()
})
sys.close()
开发者ID:alexole,项目名称:django-cassandra-sessions,代码行数:12,代码来源:setup_session_db.py
示例14: _create_cf
def _create_cf(self, cf_name):
sys_mng = SystemManager('localhost:9160')
validators = {'name': UTF8_TYPE, 'content': UTF8_TYPE, 'post_time': UTF8_TYPE}
sys_mng.create_column_family(
'bbs',
cf_name,
super=False,
comparator_type=UTF8_TYPE,
key_validation_class=UTF8_TYPE,
column_validation_classes=validators
)
sys_mng.close()
开发者ID:hiroakis,项目名称:simple-bbs-cassandra,代码行数:12,代码来源:app.py
示例15: test_uuid_composites
def test_uuid_composites(self):
sys = SystemManager()
sys.create_column_family(TEST_KS, 'UUIDComposite',
comparator_type=CompositeType(IntegerType(reversed=True), TimeUUIDType()),
key_validation_class=TimeUUIDType(),
default_validation_class=UTF8Type())
key, u1, u2 = uuid.uuid1(), uuid.uuid1(), uuid.uuid1()
cf = ColumnFamily(pool, 'UUIDComposite')
cf.insert(key, {(123123, u1): 'foo'})
cf.insert(key, {(123123, u1): 'foo', (-1, u2): 'bar', (-123123123, u1): 'baz'})
assert_equal(cf.get(key), {(123123, u1): 'foo', (-1, u2): 'bar', (-123123123, u1): 'baz'})
开发者ID:YinYanfei,项目名称:pycassa,代码行数:12,代码来源:test_autopacking.py
示例16: wait_for_consistency
def wait_for_consistency(self, sm=None):
if sm is None:
sm = SystemManager(self._chosen_server)
start_consistency_delay = time.time()
consistency_delay = 0
while len(sm.describe_schema_versions()) > 1 and \
consistency_delay < self.max_consistency_delay:
consistency_delay = time.time() - start_consistency_delay
if consistency_delay > 20:
logger.warn('waited %.1f seconds for cluster-wide consistency %r' % (
consistency_delay, sm.describe_schema_versions()))
time.sleep(0.2)
logger.info('number of schemas in cluster: %d' % len(sm.describe_schema_versions()))
开发者ID:diffeo,项目名称:kvlayer,代码行数:13,代码来源:_cassandra.py
示例17: __init__
def __init__(self, engine, **kw):
super(CassandraStore, self).__init__(engine, **kw)
spliturl = urlsplit(engine)
_, keyspace, column_family = spliturl.path.split('/')
try:
self._store = pycassa.ColumnFamily(
pycassa.ConnectionPool(keyspace, [spliturl.hostname]),
column_family,
)
except pycassa.InvalidRequestException:
from pycassa.system_manager import SystemManager # @UnresolvedImport @IgnorePep8
system_manager = SystemManager(spliturl[1])
system_manager.create_keyspace(
keyspace,
pycassa.system_manager.SIMPLE_STRATEGY,
dict(replication_factor=native(kw.get('replication', 1))),
)
system_manager.create_column_family(keyspace, column_family)
self._store = pycassa.ColumnFamily(
pycassa.ConnectionPool(keyspace, [spliturl.netloc]),
column_family,
)
except pycassa.NotFoundException:
from pycassa.system_manager import SystemManager # @UnresolvedImport @IgnorePep8
system_manager = SystemManager(spliturl[1])
system_manager.create_column_family(keyspace, column_family)
self._store = pycassa.ColumnFamily(
pycassa.ConnectionPool(keyspace, [spliturl.netloc]),
column_family,
)
开发者ID:cnstudios,项目名称:Plex-Trakt-Scrobbler,代码行数:30,代码来源:cassandra.py
示例18: handle_noargs
def handle_noargs(self, **options):
sys = SystemManager(server=settings.CASSANDRA_SERVERS[0])
REPLICATION_STRATEGY = getattr(pycassa.system_manager, settings.CASSANDRA_REPLICATION_STRATEGY)
existing_cfs = sys.get_keyspace_column_families(settings.CASSANDRA_KEYSPACE).keys()
if 'APIConsumers' not in existing_cfs:
print 'Creating missing column family: APIConsumers'
sys.create_column_family(settings.CASSANDRA_KEYSPACE, 'APIConsumers', comparator_type=UTF8_TYPE)
sys.alter_column(settings.CASSANDRA_KEYSPACE, 'APIConsumers', 'consumer_key', UTF8_TYPE)
sys.alter_column(settings.CASSANDRA_KEYSPACE, 'APIConsumers', 'consumer_secret', UTF8_TYPE)
sys.alter_column(settings.CASSANDRA_KEYSPACE, 'APIConsumers', 'username', UTF8_TYPE)
print 'All done!'
开发者ID:hnkien,项目名称:sirikata-cdn,代码行数:14,代码来源:add_newtables.py
示例19: test_add_remove_counter
def test_add_remove_counter(self):
sys = SystemManager()
sys.create_column_family(TEST_KS, 'KeyLongCounter', key_validation_class=LongType(),
default_validation_class='CounterColumnType')
sys.close()
cf_long = ColumnFamily(pool, 'KeyLongCounter')
key = 1111111111111111L
cf_long.add(key, 'col')
assert_equal(cf_long.get(key), {'col': 1})
cf_long.remove_counter(key, 'col')
time.sleep(0.1)
assert_raises(NotFoundException, cf_long.get, key)
开发者ID:YinYanfei,项目名称:pycassa,代码行数:14,代码来源:test_autopacking.py
示例20: test_get_indexed_slices
def test_get_indexed_slices(self):
sys = SystemManager()
for cf, keys in self.type_groups:
sys.create_index(TEST_KS, cf.column_family, 'birthdate', LongType())
cf = ColumnFamily(pool, cf.column_family)
for key in keys:
cf.insert(key, {'birthdate': 1})
expr = create_index_expression('birthdate', 1)
clause = create_index_clause([expr])
rows = list(cf.get_indexed_slices(clause))
assert_equal(len(rows), len(keys))
for k, c in rows:
assert_true(k in keys)
assert_equal(c, {'birthdate': 1})
开发者ID:YinYanfei,项目名称:pycassa,代码行数:14,代码来源:test_autopacking.py
注:本文中的pycassa.system_manager.SystemManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论