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


Python SystemManager.list_keyspaces方法代码示例

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


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

示例1: ensure_cassandra_cf

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

示例2: CreateCF

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

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

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

示例5: main

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

示例6: setup_databases

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import list_keyspaces [as 别名]
    def setup_databases(self, **kwargs):
        settings.KEYSPACE = settings.KEYSPACE_TESTS
        print "Patched value of KEYSPACE to '{0}'".format(settings.KEYSPACE)
        if "dont_drop_daedalus_tests" not in os.environ:
            sys_mgr = SystemManager()
            try:
                sys_mgr.drop_keyspace(settings.KEYSPACE)
                print "Keyspace {0} droped OK".format(settings.KEYSPACE)
            except:
                pass
            finally:
                sys_mgr.close()

            sys_mgr = SystemManager()
            # keyspace 'settings.KEYSPACE' shouldn't exists
            if settings.KEYSPACE in sys_mgr.list_keyspaces():
                print "ERROR: keyspace {0} EXISTS after been droped".format(settings.KEYSPACE)
                print " - Keyspaces:", sys_mgr.list_keyspaces()
                assert False, "ERROR"
            sys_mgr.close()

        storage.get_service().create_keyspace_and_cfs()
        return super(CassandraDjangoTestSuiteRunner, self).setup_databases(**kwargs)
开发者ID:hgdeoro,项目名称:daedalus,代码行数:25,代码来源:test_runner.py

示例7: cassandra_reset

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import list_keyspaces [as 别名]
def cassandra_reset():
    from feedly import settings

    hostname = settings.FEEDLY_CASSANDRA_HOSTS[0]
    keyspace = "test_feedly"

    sys = SystemManager(hostname)

    # sys.drop_keyspace(keyspace)

    if keyspace not in sys.list_keyspaces():
        sys.create_keyspace(keyspace, SIMPLE_STRATEGY, {"replication_factor": "1"})

        sys.create_column_family(keyspace, "activity", comparator_type=UTF8_TYPE)

        sys.create_column_family(keyspace, "timeline", comparator_type=IntegerType(reversed=True))
开发者ID:jblomo,项目名称:Feedly,代码行数:18,代码来源:conftest.py

示例8: setup_package

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import list_keyspaces [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, e:
        print e
        try:
            sys.drop_keyspace(TEST_KS)
        except:
            pass
        raise e
开发者ID:EmergingThreats,项目名称:pycassa,代码行数:23,代码来源:__init__.py

示例9: CCli

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import list_keyspaces [as 别名]
class CCli(Cmd, object):
    prompt = '> '
    continuation_prompt = '. '
    
    timing = True
    colors = True
    debug = True

    # O'Key, guys, you created good library with a lot of parameters, but,
    # I think, you should test it before release, shouldn't?
    case_insensitive = False

    max_data_size = 35
    max_rows = 50
    
    def __init__(self, *args, **kwargs):
        super(CCli, self).__init__(*args, **kwargs)

        self.sm = None
        self.pool = None

        self.server = None
        self.keyspace = None

        self.settable['max_data_size'] = 'Maximum value symbols [0 = no truncating]'
        self.settable['max_rows'] = 'Maximum rows to receive by one get'

    def func_named(self, arg):
        return super(CCli, self).func_named(arg[0])

    @parse(Optional(server, default='locahost:9160'))
    def do_connect(self, server):
        try:
            self.sm = SystemManager(server)
        except TTransportException:
            return self.perror('Can not connect to %s' % server)
        
        self.server = server
        self.prompt = '%s> ' % server

        self.keyspace = None
        self.pool = None

        print 'Successfully connected to %s' % server

    @check_connection
    @parse(keyspace)
    def do_use(self, keyspace):
        if keyspace not in self.sm.list_keyspaces():
            return self.perror('Unknown keyspace %s' % keyspace)

        self.prompt = '%s/%s> ' % (self.server, keyspace)
        self.keyspace = keyspace
        self.pool = ConnectionPool(keyspace, server_list=[self.server])
        
        print 'Using %s as default keyspace' % keyspace

    def complete_use(self, text, line, begidx, endidx):
        if not self.sm:
            return []
        
        return [x for x in self.sm.list_keyspaces() if x.startswith(text)]

    @check_connection
    @parse(Keyword('keyspaces') | Keyword('columnfamilies'))
    def do_list(self, space):
        return getattr(self, 'list_%s' % space)()

    def list_keyspaces(self):
        pt = PrettyTable()
        pt.field_names = ['Keyspaces']
        pt.align = 'l'

        for ks in self.sm.list_keyspaces():
            pt.add_row([ks])

        print pt.get_string(sortby="Keyspaces")

    @check_keyspace
    def list_columnfamilies(self):
        pt = PrettyTable()
        pt.field_names = ['ColumnFamilies']
        pt.align = 'l'

        for cf in self.sm.get_keyspace_column_families(self.keyspace).keys():
            pt.add_row([cf])

        print pt.get_string(sortby="ColumnFamilies")

    def complete_list(self, text, line, begidx, endidx):
        return [x for x in ['keyspaces', 'columnfamilies'] if x.startswith(text)]

    @check_connection
    @parse(Keyword('keyspace') + Optional(keyspace, default=None) | Keyword('columnfamily') + columnfamily)
    def do_describe(self, space, name):
        return getattr(self, 'describe_%s' % space)(name)

    def describe_keyspace(self, keyspace):
        keyspace = keyspace or self.keyspace
        if not keyspace:
#.........这里部分代码省略.........
开发者ID:rembish,项目名称:cassandra-cli,代码行数:103,代码来源:oldcli.py

示例10: SystemManager

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import list_keyspaces [as 别名]
from pycassa.system_manager import SystemManager
from pycassa.system_manager import SIMPLE_STRATEGY
from pycassa.system_manager import UTF8_TYPE
from pycassa.system_manager import LONG_TYPE
from storage.cassandra_settings import HOSTS
from storage.cassandra_settings import KEYSPACE_NAME


sys = SystemManager(HOSTS[0])

if KEYSPACE_NAME in sys.list_keyspaces():
    sys.drop_keyspace(KEYSPACE_NAME)

sys.create_keyspace(KEYSPACE_NAME, SIMPLE_STRATEGY, {'replication_factor': '1'})
sys.create_column_family(KEYSPACE_NAME, 'LoveActivity', comparator_type=UTF8_TYPE)
sys.create_column_family(KEYSPACE_NAME, 'Feed', comparator_type=UTF8_TYPE)
sys.create_column_family(KEYSPACE_NAME, 'AggregatedFeed', comparator_type=LONG_TYPE, super=True)
开发者ID:tbarbugli,项目名称:Feedly,代码行数:19,代码来源:sync_cassandra.py

示例11: teardown_package

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import list_keyspaces [as 别名]
def teardown_package():
    sys = SystemManager()
    if TEST_KS in sys.list_keyspaces():
        sys.drop_keyspace(TEST_KS)
    sys.close()
开发者ID:EmergingThreats,项目名称:pycassa,代码行数:7,代码来源:__init__.py

示例12: SystemManager

# 需要导入模块: from pycassa.system_manager import SystemManager [as 别名]
# 或者: from pycassa.system_manager.SystemManager import list_keyspaces [as 别名]
import json

from pycassa import ConnectionPool
from pycassa.columnfamily import ColumnFamily
from pycassa.system_manager import SystemManager
from pycassa.system_manager import SIMPLE_STRATEGY
from pycassa.system_manager import UTF8_TYPE
from pycassa.system_manager import ASCII_TYPE

import time

############################## Create Keyspace ################################
server_list = ['cassandra1:9160', 'cassandra2:9160', 'cassandra3:9160']
sys = SystemManager(server_list[0])
sys.list_keyspaces()
if 'entries' in sys.list_keyspaces():
    sys.drop_keyspace('entries')
sys.create_keyspace('entries', SIMPLE_STRATEGY, {'replication_factor': '1'})

############################## Connection Pooling ############################
#pool = ConnectionPool('entries', server_list=server_list, pool_size=20)
pool = ConnectionPool('entries', server_list=server_list)

############################## Create Column Family ###########################
sys.create_column_family('entries', 'Author', comparator_type=UTF8_TYPE)
author_cf = ColumnFamily(pool, 'Author')

################################ INSERT #######################################
# Insert a row with a Column
author_cf.insert('sacharya', {'first_name': 'Sudarshan'})
# Insert a row with multiple columns
开发者ID:sacharya,项目名称:cassandra-101,代码行数:33,代码来源:cassandra-pycassa.py


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