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


Python SystemManager.get_keyspace_properties方法代码示例

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


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

示例1: main

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

示例2: CCli

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

#.........这里部分代码省略.........
        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:
            return self.perror('Please, select working keyspace or define it as command parameter')

        try:
            options = self.sm.get_keyspace_properties(keyspace)
        except NotFoundException:
            return self.perror('Unknown keyspace %s' % keyspace)

        pt = PrettyTable()
        pt.field_names = ['Keyspace', keyspace]
        pt.align["Keyspace"] = "l"
        pt.align[keyspace] = 'r'

        pt.add_row(['replication_strategy', options['replication_strategy']])
        for k, v in options['strategy_options'].items():
            pt.add_row([k, "\033[34m%s\033[0m" % v])

        print pt.get_string(sortby='Keyspace')

    @check_keyspace
    def describe_columnfamily(self, columnfamily):
        try:
            options = self.sm.get_keyspace_column_families(self.keyspace, use_dict_for_col_metadata=True)[columnfamily]
        except KeyError:
            return self.perror('Unknown columnfamily %s' % columnfamily)

        pt = PrettyTable()
        pt.field_names = ['ColumnFamily', columnfamily]
        pt.align["ColumnFamily"] = "l"
        pt.align[columnfamily] = 'r'

        for k, v in options.__dict__.items():
            if k == 'column_metadata' and len(v):
                continue
            pt.add_row([k, v])

        print pt.get_string(sortby='ColumnFamily')
开发者ID:rembish,项目名称:cassandra-cli,代码行数:70,代码来源:oldcli.py


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