本文整理汇总了Python中pycassa.system_manager.SystemManager.describe_schema_versions方法的典型用法代码示例。如果您正苦于以下问题:Python SystemManager.describe_schema_versions方法的具体用法?Python SystemManager.describe_schema_versions怎么用?Python SystemManager.describe_schema_versions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycassa.system_manager.SystemManager
的用法示例。
在下文中一共展示了SystemManager.describe_schema_versions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_for_consistency
# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import describe_schema_versions [as 别名]
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()))
示例2: test_composite_column_names
# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import describe_schema_versions [as 别名]
def test_composite_column_names(client):
'''
examine the unique nature of cassandras "wide sorted rows";
Basically, C* is good at storing large OrderedDict objects and
less good at the simpler kind of key=value storage that we were
doing earlier.
'''
config = client._config
namespace = client._app_namespace
chosen_server = client._chosen_server
sm = SystemManager(chosen_server)
sm.create_keyspace(namespace, SIMPLE_STRATEGY, {'replication_factor': '1'})
family = 'test'
sm.create_column_family(
namespace, family, super=False,
key_validation_class = ASCII_TYPE,
default_validation_class = BYTES_TYPE,
comparator_type=CompositeType(UUIDType(), UUIDType()),
#column_name_class = LEXICAL_UUID_TYPE
)
logger.info( sm.describe_schema_versions() )
pool = ConnectionPool(namespace, config['storage_addresses'],
max_retries=1000, pool_timeout=10, pool_size=2, timeout=120)
cf = pycassa.ColumnFamily(pool, family)
u1, u2, u3, u4 = uuid.uuid1(), uuid.uuid1(), uuid.uuid1(), uuid.uuid1()
## insert four
cf.insert('inbound', {(u1, u2): b''})
cf.insert('inbound', {(u1, u3): b''})
cf.insert('inbound', {(u1, u4): b''})
cf.insert('inbound', {(u1, u1): b'45'})
## insert three with duplicates
cf.insert('inbound', {(u3, u3): b'42'})
cf.insert('inbound', {(u3, u3): b'43'})
cf.insert('inbound', {(u3, u2): b''})
cf.insert('inbound', {(u3, u4): b''})
## insert two
cf.insert('inbound', {(u2, u3): b''})
cf.insert('inbound', {(u2, u4): b''})
## verify start/finish parameters work as expected
assert 4 == len(cf.get('inbound', column_start=(u1,), column_finish=(u1,)))
assert 2 == len(cf.get('inbound', column_start=(u2,), column_finish=(u2,)))
assert 3 == len(cf.get('inbound', column_start=(u3,), column_finish=(u3,)))
## check delete of a single column
cf.remove('inbound', columns=[(u2, u3)])
assert 1 == len(cf.get('inbound', column_start=(u2,), column_finish=(u2,)))
## check that the last inserted value appears at the expected
## location in the OrderedDict
assert '43' == cf.get('inbound', column_start=(u3,), column_finish=(u3,)).items()[1][1]
rec1 = cf.get('inbound', column_start=(u3,u3), column_finish=(u3,u3)).items()
assert len(rec1) == 1
start = uuid.UUID(int=0)
finish = uuid.UUID(int=2**128-1)
assert start < u1 < u2 < u3 < u4 < finish
assert 8 == len(cf.get('inbound', column_start=(start,), column_finish=(finish,)).items())
## test range searching
start = uuid.UUID(int=u3.int - 1)
finish = uuid.UUID(int=u3.int + 1)
assert start.int < u3.int < finish.int
rec2 = cf.get('inbound', column_start=(start,), column_finish=(finish,)).items()
assert rec2[1][0] == rec1[0][0]
assert rec2[1][1] == rec1[0][1] == '43'
cf.insert('inbound', {(u3,u3): b''.join(map(lambda u: u.bytes, (u1,u2,u3,u4)))})
data = cf.get('inbound', column_start=(u3,u3), column_finish=(u3,u3)).items()[0][1]
assert [u1,u2,u3,u4] == map(lambda b: uuid.UUID(bytes=b), grouper(data, 16))
sm.close()