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


Python SystemManager.create_column_family方法代码示例

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


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

示例1: CreateCF

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [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

示例2: get_connection

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [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

示例3: initializeTableLayout

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [as 别名]
def initializeTableLayout(keyspace, server_list, replicationStrategy,
  strategyOptions, localDCName, credentials):

    sys_manager = SystemManager(server_list[0], credentials=credentials)

    # Make sure the the keyspace exists
    if keyspace not in sys_manager.list_keyspaces():
      sys_manager.create_keyspace(keyspace, replicationStrategy,
        strategyOptions)

    cf_defs = sys_manager.get_keyspace_column_families(keyspace)

    # Create UTF8 CF's
    for tablename in ["global_nodes", "metadata"]:
      if tablename not in cf_defs.keys():
        createUTF8ColumnFamily(sys_manager, keyspace, tablename)

    if localDCName:

        dcNodes = "dc_%s_nodes" % (localDCName,)
        if dcNodes not in cf_defs.keys():
          createUTF8ColumnFamily(sys_manager, keyspace, dcNodes)
    else:
      # TODO Log we do not have the DC name
      pass

    if "node_slices" not in cf_defs.keys():
      sys_manager.create_column_family(
        keyspace,
        "node_slices",
        super=False,
        comparator_type=pycassa_types.LongType(),
        key_validation_class=pycassa_types.UTF8Type(),
        default_validation_class=pycassa_types.LongType()
      )
开发者ID:acquia,项目名称:carbon-cassandra-plugin,代码行数:37,代码来源:carbon_cassandra_db.py

示例4: __init__

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

示例5: ensure_cassandra_cf

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [as 别名]
 def ensure_cassandra_cf(self):
     s = SystemManager()
     if self.keyspace not in s.list_keyspaces():
         s.create_keyspace(self.keyspace, SIMPLE_STRATEGY, {'replication_factor': '1'})
     if self.cassandra_columns_family not in s.get_keyspace_column_families(self.keyspace):
         s.create_column_family(self.keyspace, self.cassandra_columns_family)
     self.columnfamily = ColumnFamily(self.cassandra_session, self.cassandra_columns_family)
开发者ID:TPNguyen,项目名称:python-pds,代码行数:9,代码来源:temporal_daily_cython.py

示例6: test_single_component_composite

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

示例7: setup_class

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [as 别名]
 def setup_class(cls):
     sys = SystemManager()
     sys.create_column_family(
         TEST_KS,
         'CustomComposite1',
         comparator_type=CompositeType(
             IntegerType(),
             UTF8Type()))
开发者ID:YinYanfei,项目名称:pycassa,代码行数:10,代码来源:test_autopacking.py

示例8: setUp

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

示例9: setUp

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

示例10: _cassandra_ensure_keyspace

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [as 别名]
    def _cassandra_ensure_keyspace(self, server_list,
                                   keyspace_name, cf_info_list):
        # Retry till cassandra is up
        server_idx = 0
        num_dbnodes = len(self._server_list)
        connected = False
        while not connected:
            try:
                cass_server = self._server_list[server_idx]
                sys_mgr = SystemManager(cass_server)
                connected = True
            except Exception as e:
                # TODO do only for
                # thrift.transport.TTransport.TTransportException
                server_idx = (server_idx + 1) % num_dbnodes
                time.sleep(3)

        if self._reset_config:
            try:
                sys_mgr.drop_keyspace(keyspace_name)
            except pycassa.cassandra.ttypes.InvalidRequestException as e:
                # TODO verify only EEXISTS
                self._logger("Warning! " + str(e), level=SandeshLevel.SYS_WARN)

        try:
            sys_mgr.create_keyspace(keyspace_name, SIMPLE_STRATEGY,
                                    {'replication_factor': str(num_dbnodes)})
        except pycassa.cassandra.ttypes.InvalidRequestException as e:
            # TODO verify only EEXISTS
            self._logger("Warning! " + str(e), level=SandeshLevel.SYS_WARN)

        gc_grace_sec = 0
        if num_dbnodes > 1:
            gc_grace_sec = 60

        for cf_info in cf_info_list:
            try:
                (cf_name, comparator_type) = cf_info
                if comparator_type:
                    sys_mgr.create_column_family(
                        keyspace_name, cf_name,
                        comparator_type=comparator_type,
                        gc_grace_seconds=gc_grace_sec,
                        default_validation_class='UTF8Type')
                else:
                    sys_mgr.create_column_family(keyspace_name, cf_name,
                        gc_grace_seconds=gc_grace_sec,
                        default_validation_class='UTF8Type')
            except pycassa.cassandra.ttypes.InvalidRequestException as e:
                # TODO verify only EEXISTS
                self._logger("Warning! " + str(e), level=SandeshLevel.SYS_WARN)
                sys_mgr.alter_column_family(keyspace_name, cf_name,
                    gc_grace_seconds=gc_grace_sec,
                    default_validation_class='UTF8Type')
开发者ID:GIC-de,项目名称:contrail-controller,代码行数:56,代码来源:vnc_cassandra.py

示例11: test_uuid_composites

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

示例12: handle

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [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

示例13: test_big_batched_writes

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [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

示例14: _create_cf

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [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

示例15: test_add_remove_counter

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import create_column_family [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


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