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


Python Cluster.lock_by_id方法代码示例

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


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

示例1: quit

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import lock_by_id [as 别名]
def quit(host, port, cluster_id, quit_cluster):
    logging.info('Node %s:%d quit from cluster [ %d ]', host, port, cluster_id)
    instance = pick_by(host, port)
    if instance.assignee is None:
        return
    Cluster.lock_by_id(instance.assignee_id)
    quit_cluster(host, port)
    instance.assignee = None
    db.session.add(instance)
开发者ID:Bluelich,项目名称:redis-ctl,代码行数:11,代码来源:node.py

示例2: pick_and_launch

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import lock_by_id [as 别名]
def pick_and_launch(host, port, cluster_id, start_cluster):
    logging.info('Launching cluster for [ %d ]', cluster_id)
    node = pick_by(host, port)
    if node.assignee is not None:
        raise errors.AppMutexError()
    cluster = Cluster.lock_by_id(cluster_id)
    start_cluster(node.host, node.port)
    node.assignee = cluster
    db.session.add(node)
开发者ID:Bluelich,项目名称:redis-ctl,代码行数:11,代码来源:node.py

示例3: pick_and_replicate

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import lock_by_id [as 别名]
def pick_and_replicate(master_host, master_port, slave_host, slave_port,
                       replicate_node):
    master_node = pick_by(master_host, master_port)
    if master_node.assignee_id is None:
        raise ValueError('node not in cluster')
    cluster = Cluster.lock_by_id(master_node.assignee_id)
    slave_node = pick_by(slave_host, slave_port)
    replicate_node(master_host, master_port, slave_host, slave_port)
    slave_node.assignee = cluster
    db.session.add(slave_node)
开发者ID:Bluelich,项目名称:redis-ctl,代码行数:12,代码来源:node.py

示例4: pick_and_expand

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import lock_by_id [as 别名]
def pick_and_expand(host, port, cluster_id, join_node):
    cluster = Cluster.lock_by_id(cluster_id)
    if len(cluster.nodes) == 0:
        raise ValueError('no node in such cluster')
    new_node = db.session.query(RedisNode).filter(
        RedisNode.host == host,
        RedisNode.port == port,
        RedisNode.assignee_id == None).with_for_update().first()
    if new_node is None:
        raise ValueError('no such node')

    join_node(cluster.nodes[0].host, cluster.nodes[0].port, new_node.host,
              new_node.port)
    new_node.assignee_id = cluster_id
    db.session.add(new_node)
开发者ID:Bluelich,项目名称:redis-ctl,代码行数:17,代码来源:node.py


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