コード例 #1
0
ファイル: api.py プロジェクト: pratikmallya/otter
def setup_converger(parent, kz_client, dispatcher, interval, build_timeout):
    """
    Create a Converger service, which has a Partitioner as a child service, so
    that if the Converger is stopped, the partitioner is also stopped.
    """
    partitioner_factory = partial(
        Partitioner,
        kz_client=kz_client,
        interval=interval,
        partitioner_path=CONVERGENCE_PARTITIONER_PATH,
        time_boundary=15,  # time boundary
    )
    cvg = Converger(log, dispatcher, 10, partitioner_factory, build_timeout,
                    interval / 2)
    cvg.setServiceParent(parent)
    watch_children(kz_client, CONVERGENCE_DIRTY_DIR, cvg.divergent_changed)
コード例 #2
0
def setup_converger(parent, kz_client, dispatcher, interval, build_timeout,
                    limited_retry_iterations, step_limits):
    """
    Create a Converger service, which has a Partitioner as a child service, so
    that if the Converger is stopped, the partitioner is also stopped.
    """
    partitioner_factory = partial(
        Partitioner,
        kz_client=kz_client,
        interval=interval,
        partitioner_path=CONVERGENCE_PARTITIONER_PATH,
        time_boundary=15,  # time boundary
    )
    cvg = Converger(log, dispatcher, 10, partitioner_factory, build_timeout,
                    interval / 2, limited_retry_iterations, step_limits)
    cvg.setServiceParent(parent)
    watch_children(kz_client, CONVERGENCE_DIRTY_DIR, cvg.divergent_changed)
コード例 #3
0
ファイル: test_watchers.py プロジェクト: jerith/txkazoo
 def test_error(self):
     """
     If the call to :obj:`ChildrenWatch` raises an exception, the returned
     Deferred will fail with that exception.
     """
     def FCW(*args, **kwargs):
         raise RuntimeError('foo')
     result = watch_children(self.tx_client, '/foo', None,
                             ChildrenWatch=FCW)
     f = self.failureResultOf(result)
     self.assertEqual(f.type, RuntimeError)
     self.assertEqual(str(f.value), 'foo')
コード例 #4
0
ファイル: test_watchers.py プロジェクト: jerith/txkazoo
 def test_kwargs(self):
     """
     ``allow_session_lost`` and ``send_event`` are passed through to the
     ChildrenWatch.
     """
     result = watch_children(self.tx_client, '/foo', None,
                             allow_session_lost=False,
                             send_event=True,
                             ChildrenWatch=FakeChildrenWatch)
     result = self.successResultOf(result)
     self.assertEqual(result[0], self.tx_client.kazoo_client)
     self.assertEqual(result[1], '/foo')
     self.assertEqual(result[3], False)
     self.assertEqual(result[4], True)
コード例 #5
0
    def test_error(self):
        """
        If the call to :obj:`ChildrenWatch` raises an exception, the returned
        Deferred will fail with that exception.
        """
        def FCW(*args, **kwargs):
            raise RuntimeError('foo')

        result = watch_children(self.tx_client,
                                '/foo',
                                None,
                                ChildrenWatch=FCW)
        f = self.failureResultOf(result)
        self.assertEqual(f.type, RuntimeError)
        self.assertEqual(str(f.value), 'foo')
コード例 #6
0
 def test_kwargs(self):
     """
     ``allow_session_lost`` and ``send_event`` are passed through to the
     ChildrenWatch.
     """
     result = watch_children(self.tx_client,
                             '/foo',
                             None,
                             allow_session_lost=False,
                             send_event=True,
                             ChildrenWatch=FakeChildrenWatch)
     result = self.successResultOf(result)
     self.assertEqual(result[0], self.tx_client.kazoo_client)
     self.assertEqual(result[1], '/foo')
     self.assertEqual(result[3], False)
     self.assertEqual(result[4], True)
コード例 #7
0
ファイル: test_watchers.py プロジェクト: jerith/txkazoo
    def test_basic_watch(self):
        """
        Parameters are passed to :obj:`ChildrenWatch`, and the callback
        function is wrapped such that it is run in the reactor thread and its
        result is returned to the ChildrenWatch. This is important since
        ChildrenWatch interprets the result to determine whether to continue
        triggering callbacks.
        """
        result = watch_children(self.tx_client, '/foo', self._my_callback,
                                ChildrenWatch=FakeChildrenWatch)
        result = self.successResultOf(result)
        self.assertEqual(result[0], self.tx_client.kazoo_client)
        self.assertEqual(result[1], '/foo')
        self.assertEqual(result[3], True)
        self.assertEqual(result[4], False)

        self.assertEqual(
            result[2](['foo', 'bar']),
            ('called back', ['foo', 'bar']))
コード例 #8
0
    def test_basic_watch(self):
        """
        Parameters are passed to :obj:`ChildrenWatch`, and the callback
        function is wrapped such that it is run in the reactor thread and its
        result is returned to the ChildrenWatch. This is important since
        ChildrenWatch interprets the result to determine whether to continue
        triggering callbacks.
        """
        result = watch_children(self.tx_client,
                                '/foo',
                                self._my_callback,
                                ChildrenWatch=FakeChildrenWatch)
        result = self.successResultOf(result)
        self.assertEqual(result[0], self.tx_client.kazoo_client)
        self.assertEqual(result[1], '/foo')
        self.assertEqual(result[3], True)
        self.assertEqual(result[4], False)

        self.assertEqual(result[2](['foo', 'bar']),
                         ('called back', ['foo', 'bar']))