当前位置: 首页>>代码示例>>Python>>正文


Python SystemManager.close方法代码示例

本文整理汇总了Python中pycassa.system_manager.SystemManager.close方法的典型用法代码示例。如果您正苦于以下问题:Python SystemManager.close方法的具体用法?Python SystemManager.close怎么用?Python SystemManager.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycassa.system_manager.SystemManager的用法示例。


在下文中一共展示了SystemManager.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_connection

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
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,代码行数:28,代码来源:simple_client.py

示例2: CreateCF

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
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,代码行数:33,代码来源:cassandraoperator.py

示例3: setup_class

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
    def setup_class(cls):
        sys = SystemManager()
        sys.create_column_family(TEST_KS, 'StdLong', comparator_type=LongType())
        sys.create_column_family(TEST_KS, 'StdInteger', comparator_type=IntegerType())
        sys.create_column_family(TEST_KS, 'StdBigInteger', comparator_type=IntegerType())
        sys.create_column_family(TEST_KS, 'StdDecimal', comparator_type=DecimalType())
        sys.create_column_family(TEST_KS, 'StdTimeUUID', comparator_type=TimeUUIDType())
        sys.create_column_family(TEST_KS, 'StdLexicalUUID', comparator_type=LexicalUUIDType())
        sys.create_column_family(TEST_KS, 'StdAscii', comparator_type=AsciiType())
        sys.create_column_family(TEST_KS, 'StdUTF8', comparator_type=UTF8Type())
        sys.create_column_family(TEST_KS, 'StdBytes', comparator_type=BytesType())
        sys.create_column_family(TEST_KS, 'StdComposite',
                                 comparator_type=CompositeType(LongType(), BytesType()))
        sys.close()

        cls.cf_long = ColumnFamily(pool, 'StdLong')
        cls.cf_int = ColumnFamily(pool, 'StdInteger')
        cls.cf_big_int = ColumnFamily(pool, 'StdBigInteger')
        cls.cf_decimal = ColumnFamily(pool, 'StdDecimal')
        cls.cf_time = ColumnFamily(pool, 'StdTimeUUID')
        cls.cf_lex = ColumnFamily(pool, 'StdLexicalUUID')
        cls.cf_ascii = ColumnFamily(pool, 'StdAscii')
        cls.cf_utf8 = ColumnFamily(pool, 'StdUTF8')
        cls.cf_bytes = ColumnFamily(pool, 'StdBytes')
        cls.cf_composite = ColumnFamily(pool, 'StdComposite')

        cls.cfs = [cls.cf_long, cls.cf_int, cls.cf_time, cls.cf_lex,
                   cls.cf_ascii, cls.cf_utf8, cls.cf_bytes,
                   cls.cf_composite]
开发者ID:YinYanfei,项目名称:pycassa,代码行数:31,代码来源:test_autopacking.py

示例4: _create_cf

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
 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,代码行数:14,代码来源:app.py

示例5: handle

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
    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,代码行数:14,代码来源:setup_session_db.py

示例6: test_big_batched_writes

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
def test_big_batched_writes():
    ## this is an m1.xlarge doing nothing but supporting this test
    server = 'localhost:9160'
    keyspace = 'testkeyspace_' + getpass.getuser().replace('-', '_')
    family = 'testcf'
    sm = SystemManager(server)
    try:
        sm.drop_keyspace(keyspace)
    except pycassa.InvalidRequestException:
        pass
    sm.create_keyspace(keyspace, SIMPLE_STRATEGY, {'replication_factor': '1'})
    sm.create_column_family(keyspace, family, super=False,
                            key_validation_class = LEXICAL_UUID_TYPE,
                            default_validation_class  = LEXICAL_UUID_TYPE,
                            column_name_class = ASCII_TYPE)
    sm.alter_column(keyspace, family, 'test', ASCII_TYPE)
    sm.close()

    pool = ConnectionPool(keyspace, [server], max_retries=10, pool_timeout=0, pool_size=10, timeout=120)
    pool.fill()
    pool.add_listener( Listener() )

    ## assert that we are using framed transport
    conn = pool._q.get()
    assert isinstance(conn.transport, thrift.transport.TTransport.TFramedTransport)
    pool._q.put(conn)

    try:
        for num_rows in range(14, 20):
            ## write some data to cassandra using increasing data sizes
            one_mb = ' ' * 2**20
            rows = []
            for i in xrange(num_rows):
                key = uuid.uuid4()
                rows.append((key, dict(test=one_mb)))

            testcf = pycassa.ColumnFamily(pool, family)
            with testcf.batch() as batch:
                for (key, data_dict) in rows:
                    data_size = len(data_dict.values()[0])
                    logger.critical('adding %r with %.6f MB' % (key, float(data_size)/2**20))
                    batch.insert(key, data_dict)

            logger.critical('%d rows written' % num_rows)

    finally:
        sm = SystemManager(server)
        try:
            sm.drop_keyspace(keyspace)
        except pycassa.InvalidRequestException:
            pass
        sm.close()
        logger.critical('clearing test keyspace: %r' % keyspace)
开发者ID:johnrfrank,项目名称:pycassa,代码行数:55,代码来源:test_big_batch_writes.py

示例7: create

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
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,代码行数:14,代码来源:schema.py

示例8: test_add_remove_counter

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
    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,代码行数:16,代码来源:test_autopacking.py

示例9: create_keyspace

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
 def create_keyspace(self):
     """
     Creates the Cassandra Keyspace (if not exist)
     """
     sys_mgr = None
     try:
         sys_mgr = SystemManager()
         try:
             sys_mgr.describe_ring(settings.KEYSPACE)
         except:
             logger.info("create_keyspace(): Creating keyspace %s", settings.KEYSPACE)
             sys_mgr.create_keyspace(settings.KEYSPACE, SIMPLE_STRATEGY, {'replication_factor': '1'})
     finally:
         if sys_mgr:
             sys_mgr.close()
开发者ID:hgdeoro,项目名称:daedalus,代码行数:17,代码来源:storage.py

示例10: test_default_validated_columns

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
    def test_default_validated_columns(self):
        sys = SystemManager()
        sys.create_column_family(TEST_KS, 'DefaultValidator', default_validation_class=LongType())
        sys.alter_column(TEST_KS, 'DefaultValidator', 'subcol', TimeUUIDType())
        sys.close()

        cf = ColumnFamily(pool, 'DefaultValidator')
        key = 'key1'

        col_cf = {'aaaaaa': 1L}
        col_cm = {'subcol': TIME1}
        col_ncf = {'aaaaaa': TIME1}

        # Both of these inserts work, as cf allows
        #  longs and cm for 'subcol' allows TIMEUUIDs.
        cf.insert(key, col_cf)
        cf.insert(key, col_cm)
        assert_equal(cf.get(key), {'aaaaaa': 1L, 'subcol': TIME1})
开发者ID:YinYanfei,项目名称:pycassa,代码行数:20,代码来源:test_autopacking.py

示例11: _create_column_family

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
    def _create_column_family(self, family, bytes_columns=[], 
                              key_validation_class=TIME_UUID_TYPE):
        '''
        Creates a column family of the name 'family' and sets any of
        the names in the bytes_column list to have the BYTES_TYPE.

        key_validation_class defaults to TIME_UUID_TYPE and could also
        be ASCII_TYPE for md5 hash keys, like we use for 'inbound'
        '''
        sm = SystemManager(random.choice(self.server_list))
        # sys.create_column_family(self.namespace, family, super=False)
        sm.create_column_family(self.namespace, family, super=False,
                key_validation_class = key_validation_class, 
                default_validation_class  = TIME_UUID_TYPE,
                column_name_class = ASCII_TYPE)
        for column in bytes_columns:
            sm.alter_column(self.namespace, family, column, BYTES_TYPE)
        sm.close()
开发者ID:naimdjon,项目名称:streamcorpus-pipeline,代码行数:20,代码来源:_pycassa_simple_table.py

示例12: test_validated_columns

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
    def test_validated_columns(self):
        sys = SystemManager()
        sys.create_column_family(TEST_KS, 'Validators',)
        sys.alter_column(TEST_KS, 'Validators', 'long', LongType())
        sys.alter_column(TEST_KS, 'Validators', 'int', IntegerType())
        sys.alter_column(TEST_KS, 'Validators', 'time', TimeUUIDType())
        sys.alter_column(TEST_KS, 'Validators', 'lex', LexicalUUIDType())
        sys.alter_column(TEST_KS, 'Validators', 'ascii', AsciiType())
        sys.alter_column(TEST_KS, 'Validators', 'utf8', UTF8Type())
        sys.alter_column(TEST_KS, 'Validators', 'bytes', BytesType())
        sys.close()

        cf = ColumnFamily(pool, 'Validators')
        key = 'key1'

        col = {'long': 1L}
        cf.insert(key, col)
        assert_equal(cf.get(key)['long'], 1L)

        col = {'int': 1}
        cf.insert(key, col)
        assert_equal(cf.get(key)['int'], 1)

        col = {'time': TIME1}
        cf.insert(key, col)
        assert_equal(cf.get(key)['time'], TIME1)

        col = {'lex': uuid.UUID(bytes='aaa aaa aaa aaaa')}
        cf.insert(key, col)
        assert_equal(cf.get(key)['lex'], uuid.UUID(bytes='aaa aaa aaa aaaa'))

        col = {'ascii': 'aaa'}
        cf.insert(key, col)
        assert_equal(cf.get(key)['ascii'], 'aaa')

        col = {'utf8': u'a\u0020'}
        cf.insert(key, col)
        assert_equal(cf.get(key)['utf8'], u'a\u0020')

        col = {'bytes': 'aaa'}
        cf.insert(key, col)
        assert_equal(cf.get(key)['bytes'], 'aaa')

        cf.remove(key)
开发者ID:YinYanfei,项目名称:pycassa,代码行数:46,代码来源:test_autopacking.py

示例13: test_validation_with_packed_names

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
    def test_validation_with_packed_names(self):
        """
        Make sure that validated columns are packed correctly when the
        column names themselves must be packed
        """
        sys = SystemManager()
        sys.create_column_family(TEST_KS, 'Validators2',
                comparator_type=LongType(), default_validation_class=LongType())
        sys.alter_column(TEST_KS, 'Validators2', 1, TimeUUIDType())
        sys.close()

        my_uuid = uuid.uuid1()
        cf = ColumnFamily(pool, 'Validators2')

        cf.insert('key', {0: 0})
        assert_equal(cf.get('key'), {0: 0})

        cf.insert('key', {1: my_uuid})
        assert_equal(cf.get('key'), {0: 0, 1: my_uuid})

        cf.insert('key', {0: 0, 1: my_uuid})
        assert_equal(cf.get('key'), {0: 0, 1: my_uuid})
开发者ID:YinYanfei,项目名称:pycassa,代码行数:24,代码来源:test_autopacking.py

示例14: create_cfs

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
 def create_cfs(self):
     """
     Creates the Cassandra Column Families (if not exist)
     """
     sys_mgr = None
     pool = None
     try:
         sys_mgr = SystemManager()
         pool = ConnectionPool(settings.KEYSPACE, server_list=settings.CASSANDRA_HOSTS)
         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:
                 logger.info("create_cfs(): Creating column family %s", cf_name)
                 sys_mgr.create_column_family(settings.KEYSPACE, cf_name, comparator_type=TimeUUIDType())
                 cf = ColumnFamily(pool, cf_name)
                 cf.get_count(str(uuid.uuid4()))
     finally:
         if pool:
             pool.dispose()
         if sys_mgr:
             sys_mgr.close()
开发者ID:hgdeoro,项目名称:daedalus,代码行数:24,代码来源:storage.py

示例15: setup_package

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import close [as 别名]
def setup_package():
    sys = SystemManager()
    if TEST_KS in sys.list_keyspaces():
        sys.drop_keyspace(TEST_KS)
    try:
        sys.create_keyspace(TEST_KS, 'SimpleStrategy', {'replication_factor': '1'})
        sys.create_column_family(TEST_KS, 'Standard1')
        sys.create_column_family(TEST_KS, 'Super1', super=True)
        sys.create_column_family(TEST_KS, 'Indexed1')
        sys.create_index(TEST_KS, 'Indexed1', 'birthdate', 'LongType')
        sys.create_column_family(TEST_KS, 'Counter1',
                                 default_validation_class='CounterColumnType')
        sys.create_column_family(TEST_KS, 'SuperCounter1', super=True,
                                 default_validation_class='CounterColumnType')
    except Exception as e:
        print(e)
        try:
            sys.drop_keyspace(TEST_KS)
        except:
            pass
        raise e
    sys.close()
开发者ID:pista329,项目名称:pycassa-thriftpy,代码行数:24,代码来源:__init__.py


注:本文中的pycassa.system_manager.SystemManager.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。