當前位置: 首頁>>代碼示例>>Python>>正文


Python policies.RoundRobinPolicy方法代碼示例

本文整理匯總了Python中cassandra.policies.RoundRobinPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Python policies.RoundRobinPolicy方法的具體用法?Python policies.RoundRobinPolicy怎麽用?Python policies.RoundRobinPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cassandra.policies的用法示例。


在下文中一共展示了policies.RoundRobinPolicy方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_loadbalancing_policy

# 需要導入模塊: from cassandra import policies [as 別名]
# 或者: from cassandra.policies import RoundRobinPolicy [as 別名]
def _get_loadbalancing_policy(self, policy):
        # NOTE(nick-ma-z): http://datastax.github.io/python-driver/
        # api/cassandra/policies.html
        if policy == 'rr':
            return policies.RoundRobinPolicy()
        elif policy == 'dc_rr':
            return policies.DCAwareRoundRobinPolicy(
                cfg.CONF.df_cassandra.local_dc_name,
                cfg.CONF.df_cassandra.used_hosts_per_remote_dc)
        elif policy == 'wl_rr':
            return policies.WhiteListRoundRobinPolicy(
                cfg.CONF.df_cassandra.whitelist_hosts)
        elif policy == 'token_rr':
            return policies.TokenAwarePolicy(
                policies.RoundRobinPolicy())
        else:
            # by default
            return policies.RoundRobinPolicy() 
開發者ID:openstack,項目名稱:dragonflow,代碼行數:20,代碼來源:cassandra_db_driver.py

示例2: init

# 需要導入模塊: from cassandra import policies [as 別名]
# 或者: from cassandra.policies import RoundRobinPolicy [as 別名]
def init(args):
    global solr_connection
    solr_connection = SolrConnection(args.solr)
    global solr_collection
    solr_collection = solr_connection[args.collection]
    global SOLR_UNIQUE_KEY
    SOLR_UNIQUE_KEY = args.solrIdField

    dc_policy = RoundRobinPolicy()
    token_policy = TokenAwarePolicy(dc_policy)

    global cassandra_cluster
    cassandra_cluster = Cluster(contact_points=args.cassandra, port=args.cassandraPort,
                                protocol_version=int(args.cassandraProtocolVersion),
                                load_balancing_policy=token_policy)
    global cassandra_session
    cassandra_session = cassandra_cluster.connect(keyspace=args.cassandraKeyspace)

    global cassandra_table
    cassandra_table = args.cassandraTable 
開發者ID:apache,項目名稱:incubator-sdap-nexus,代碼行數:22,代碼來源:deletebyquery.py

示例3: get_db

# 需要導入模塊: from cassandra import policies [as 別名]
# 或者: from cassandra.policies import RoundRobinPolicy [as 別名]
def get_db(args):
    log = logging.getLogger("cassandra")
    patch_tables(args)
    try:
        cas_host, cas_port = args.cassandra.split(":")
    except ValueError:
        cas_host = args.cassandra
        cas_port = "9042"

    def get_cluster():
        return Cluster((cas_host,), port=int(cas_port),
                       load_balancing_policy=RoundRobinPolicy())
    cluster = get_cluster()
    log.info("Connecting to %s", args.cassandra)
    try:
        session = cluster.connect(args.keyspace)
    except NoHostAvailable:
        log.warning("Keyspace %s does not exist", args.keyspace)
        cluster = get_cluster()
        session = cluster.connect()
    return session 
開發者ID:src-d,項目名稱:apollo,代碼行數:23,代碼來源:cassandra_utils.py

示例4: make_execution_profile

# 需要導入模塊: from cassandra import policies [as 別名]
# 或者: from cassandra.policies import RoundRobinPolicy [as 別名]
def make_execution_profile(retry_policy=FlakyRetryPolicy(), consistency_level=ConsistencyLevel.ONE, **kwargs):
    if 'load_balancing_policy' in kwargs:
        return ExecutionProfile(retry_policy=retry_policy,
                                consistency_level=consistency_level,
                                **kwargs)
    else:
        return ExecutionProfile(retry_policy=retry_policy,
                                consistency_level=consistency_level,
                                load_balancing_policy=RoundRobinPolicy(),
                                **kwargs) 
開發者ID:apache,項目名稱:cassandra-dtest,代碼行數:12,代碼來源:dtest.py


注:本文中的cassandra.policies.RoundRobinPolicy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。