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


Python Framework.cut_wires方法代码示例

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


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

示例1: partition

# 需要导入模块: from framework import Framework [as 别名]
# 或者: from framework.Framework import cut_wires [as 别名]
    def partition(self):
        """Show a network partition"""
        dynamomessages._show_metadata = True
        cls = dynamo99
        A = cls.DynamoNode()
        B = cls.DynamoNode()
        C = cls.DynamoNode()
        D = cls.DynamoNode()
        E = cls.DynamoNode()
        F = cls.DynamoNode()
        a = cls.DynamoClientNode('a')
        b = cls.DynamoClientNode('b')
        all_nodes = set((A, B, C, D, E, F, a, b))
        pref_list = cls.DynamoNode.chash.find_nodes('K1', 5)[0]
        coordinator = pref_list[0]
        # Set in a get-then-put
        # Send in first get-then-put
        a.get('K1', destnode=coordinator)
        Framework.schedule(timers_to_process=0)
        getrsp = a.last_msg
        a.put('K1', getrsp.metadata, 1, destnode=coordinator)
        Framework.schedule(timers_to_process=0)
        a_metadata = [a.last_msg.metadata]  # PutRsp has a single VectorClock

        # Now partition the network: (b A B C) (D E F a)
        Framework.cut_wires((b, A, B, C), (D, E, F, a))
        Framework.cut_wires((D, E, F, a), (b, A, B, C))

        # Subsequent Put from a
        a.put('K1', a_metadata, 11, destnode=coordinator)
        Framework.schedule(timers_to_process=2)
        a_metadata = [a.last_msg.metadata]  # PutRsp has a single VectorClock

        # Get-then-Put from b
        b.get('K1', destnode=coordinator)
        while b.last_msg is None:  # Wait for rsp to arrive
            Framework.schedule(timers_to_process=1)
        getrsp = b.last_msg
        b.put('K1', getrsp.metadata, 21, destnode=A)
        Framework.schedule(timers_to_process=3)
        return all_nodes
开发者ID:TaoZong,项目名称:Python,代码行数:43,代码来源:test_dynamo.py


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