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


Python ZkFarmJoiner.dispatch方法代码示例

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


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

示例1: test_remote_modification_should_not_cancel_local_one

# 需要导入模块: from zkfarmer.watcher import ZkFarmJoiner [as 别名]
# 或者: from zkfarmer.watcher.ZkFarmJoiner import dispatch [as 别名]
    def test_remote_modification_should_not_cancel_local_one(self):
        """Test if a received remote modification does not cancel a local one.

        This may happen if we have a local modification while
        processing the echo of a previous modification. For example,
        we set a value to 1021, we receive back a remote change about
        this value being set to 1021 but we have a local modification
        at the same time putting the value to 1022.
        """
        self.conf.read.return_value = {"enabled": "1",
                                       "hostname": self.NAME,
                                       "counter": 1000}
        z = ZkFarmJoiner(self.client, "/services/db", self.conf)
        z.loop(3, timeout=self.TIMEOUT)
        self.conf.reset_mock()
        self.conf.read.return_value = {"enabled": "1",
                                       "hostname": self.NAME,
                                       "counter": 1001}
        z.dispatch(FakeFileEvent())
        z.loop(1, timeout=self.TIMEOUT)
        # Here comes the local modification that won't be noticed now
        self.conf.reset_mock()
        self.conf.read.return_value = {"enabled": "1",
                                       "hostname": self.NAME,
                                       "counter": 1002}
        z.loop(3, timeout=self.TIMEOUT)
        self.assertFalse(self.conf.write.called)
开发者ID:vincentbernat,项目名称:zkfarmer,代码行数:29,代码来源:test_joiner.py

示例2: test_common_node_disconnect_and_local_modifications

# 需要导入模块: from zkfarmer.watcher import ZkFarmJoiner [as 别名]
# 或者: from zkfarmer.watcher.ZkFarmJoiner import dispatch [as 别名]
 def test_common_node_disconnect_and_local_modifications(self):
     """Check that remote modifications take over local modifications for a common node"""
     self.conf.read.return_value = {"enabled": "1"}
     z = ZkFarmJoiner(self.client, "/services/db", self.conf, True)
     z.loop(3, timeout=self.TIMEOUT)
     self.expire_session()
     self.conf.read.return_value = {"enabled": "22"}
     z.dispatch(FakeFileEvent())
     z.loop(10, timeout=self.TIMEOUT)
     self.assertEqual(json.loads(self.client.get("/services/db/common")[0]),
                      {"enabled": "1"})
开发者ID:iskandar,项目名称:zkfarmer,代码行数:13,代码来源:test_joiner.py

示例3: test_disconnect_while_local_modification

# 需要导入模块: from zkfarmer.watcher import ZkFarmJoiner [as 别名]
# 或者: from zkfarmer.watcher.ZkFarmJoiner import dispatch [as 别名]
 def test_disconnect_while_local_modification(self):
     """Test we can disconnect and have a local modification while disconnected"""
     self.conf.read.return_value = {"enabled": "1",
                                    "hostname": self.NAME}
     z = ZkFarmJoiner(self.client, "/services/db", self.conf)
     z.loop(3, timeout=self.TIMEOUT)
     self.expire_session()
     self.conf.read.return_value = {"enabled": "22",
                                    "hostname": self.NAME}
     z.dispatch(FakeFileEvent())
     z.loop(10, timeout=self.TIMEOUT)
     self.assertEqual(json.loads(self.client.get("/services/db/%s" % self.IP)[0]),
                      {"enabled": "22",
                       "hostname": self.NAME})
开发者ID:iskandar,项目名称:zkfarmer,代码行数:16,代码来源:test_joiner.py

示例4: test_local_modification

# 需要导入模块: from zkfarmer.watcher import ZkFarmJoiner [as 别名]
# 或者: from zkfarmer.watcher.ZkFarmJoiner import dispatch [as 别名]
 def test_local_modification(self):
     """Check if ZooKeeper is updated after a local modification"""
     self.conf.read.return_value = {"enabled": "1",
                                    "hostname": self.NAME}
     z = ZkFarmJoiner(self.client, "/services/db", self.conf)
     z.loop(3, timeout=self.TIMEOUT)
     self.conf.reset_mock()
     self.conf.read.return_value = {"enabled": "0",
                                    "hostname": self.NAME}
     z.dispatch(FakeFileEvent())
     z.loop(4, timeout=self.TIMEOUT)
     self.assertFalse(self.conf.write.called)
     self.assertEqual(json.loads(self.client.get("/services/db/%s" % self.IP)[0]),
                      {"enabled": "0",
                       "hostname": self.NAME})
开发者ID:iskandar,项目名称:zkfarmer,代码行数:17,代码来源:test_joiner.py

示例5: test_disconnect_while_both_remote_and_local_modification

# 需要导入模块: from zkfarmer.watcher import ZkFarmJoiner [as 别名]
# 或者: from zkfarmer.watcher.ZkFarmJoiner import dispatch [as 别名]
 def test_disconnect_while_both_remote_and_local_modification(self):
     self.conf.read.return_value = {"enabled": "1",
                                    "hostname": self.NAME}
     z = ZkFarmJoiner(self.client, "/services/db", self.conf)
     z.loop(3, timeout=self.TIMEOUT)
     self.expire_session()
     z.dispatch(FakeFileEvent())
     self.conf.read.return_value = {"enabled": "56",
                                    "hostname": self.NAME}
     self.client.ensure_path("/services/db/%s" % self.IP) # Disconnected, the path does not exist
     self.client.set("/services/db/%s" % self.IP,
                     json.dumps({"enabled": "22",
                                 "hostname": self.NAME}))
     z.loop(10, timeout=self.TIMEOUT)
     self.assertEqual(json.loads(self.client.get("/services/db/%s" % self.IP)[0]),
                      {"enabled": "56",
                       "hostname": self.NAME})
开发者ID:vincentbernat,项目名称:zkfarmer,代码行数:19,代码来源:test_joiner.py

示例6: test_detect_file_moved

# 需要导入模块: from zkfarmer.watcher import ZkFarmJoiner [as 别名]
# 或者: from zkfarmer.watcher.ZkFarmJoiner import dispatch [as 别名]
 def test_detect_file_moved(self):
     """Test if we can detect a file moved into our location."""
     self.conf.read.return_value = {"enabled": "56",
                                    "hostname": self.NAME}
     z = ZkFarmJoiner(self.client, "/services/db", self.conf)
     z.loop(3, timeout=self.TIMEOUT)
     self.conf.reset_mock()
     self.conf.read.return_value = {"enabled": "57",
                                    "hostname": self.NAME}
     f = FakeFileEvent()
     f.src_path="/unrelated/path"
     f.dst_path="/fake/root"
     z.dispatch(f)
     z.loop(4, timeout=self.TIMEOUT)
     self.assertFalse(self.conf.write.called)
     self.assertEqual(json.loads(self.client.get("/services/db/%s" % self.IP)[0]),
                      {"enabled": "57",
                       "hostname": self.NAME})
开发者ID:iskandar,项目名称:zkfarmer,代码行数:20,代码来源:test_joiner.py


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