Пример #1
0
 def __init__(self, kz_client, interval, partitioner_path, buckets,
              time_boundary, log, got_buckets,
              clock=None):
     """
     :param log: a bound log
     :param kz_client: txKazoo client
     :param partitioner_path: ZooKeeper path, used for partitioning
     :param buckets: iterable of buckets to distribute between
         nodes. Ideally there should be at least as many elements as nodes
         taking part in this partitioner. This should be a sequence of str.
     :param time_boundary: time to wait for partitioning to stabilize.
     :param got_buckets: Callable which will be called with a list of
         buckets when buckets have been allocated to this node.
     :param clock: clock to use for checking the buckets on an interval.
     """
     MultiService.__init__(self)
     self.kz_client = kz_client
     self.partitioner_path = partitioner_path
     self.buckets = buckets
     self.log = log
     self.got_buckets = got_buckets
     self.time_boundary = time_boundary
     ts = TimerService(interval, self.check_partition)
     ts.setServiceParent(self)
     ts.clock = clock
     self._old_buckets = []
Пример #2
0
def setup_selfheal_service(clock, config, dispatcher, health_checker, log):
    """
    Setup selfheal timer service and return it.

    :param clock: :obj:`IReactorTime` provider
    :param dict config: Configuration dict containing selfheal info
    :param dispatcher: Effect dispatcher
    :param health_checker: ``HealthChecker`` object where SelfHeal's health
        check will be added
    :param log: :obj:`BoundLog` logger used by service

    :return: selfheal service or None if relevant config is not found
    :rtype: :obj:`IService`
    """
    if "selfheal" not in config:
        return None
    interval = get_in(["selfheal", "interval"], config, no_default=True)
    selfheal = SelfHeal(clock, dispatcher, config_value, interval, log)
    func, lock = zk.locked_logged_func(
        dispatcher, "/selfheallock", log, "selfheal-lock-acquired",
        selfheal.setup)
    health_checker.checks["selfheal"] = zk.create_health_check(lock)
    sh_timer = TimerService(interval, func)
    sh_timer.clock = clock
    return sh_timer
Пример #3
0
def setup_selfheal_service(clock, config, dispatcher, health_checker, log):
    """
    Setup selfheal timer service and return it.

    :param clock: :obj:`IReactorTime` provider
    :param dict config: Configuration dict containing selfheal info
    :param dispatcher: Effect dispatcher
    :param health_checker: ``HealthChecker`` object where SelfHeal's health
        check will be added
    :param log: :obj:`BoundLog` logger used by service

    :return: selfheal service or None if relevant config is not found
    :rtype: :obj:`IService`
    """
    if "selfheal" not in config:
        return None
    interval = get_in(["selfheal", "interval"], config, no_default=True)
    selfheal = SelfHeal(clock, dispatcher, config_value, interval, log)
    func, lock = zk.locked_logged_func(dispatcher, "/selfheallock", log,
                                       "selfheal-lock-acquired",
                                       selfheal.setup)
    health_checker.checks["selfheal"] = zk.create_health_check(lock)
    sh_timer = TimerService(interval, func)
    sh_timer.clock = clock
    return sh_timer
Пример #4
0
 def __init__(self,
              kz_client,
              interval,
              partitioner_path,
              buckets,
              time_boundary,
              log,
              got_buckets,
              clock=None):
     """
     :param log: a bound log
     :param kz_client: txKazoo client
     :param partitioner_path: ZooKeeper path, used for partitioning
     :param buckets: iterable of buckets to distribute between
         nodes. Ideally there should be at least as many elements as nodes
         taking part in this partitioner. This should be a sequence of str.
     :param time_boundary: time to wait for partitioning to stabilize.
     :param got_buckets: Callable which will be called with a list of
         buckets when buckets have been allocated to this node.
     :param clock: clock to use for checking the buckets on an interval.
     """
     MultiService.__init__(self)
     self.kz_client = kz_client
     self.partitioner_path = partitioner_path
     self.buckets = buckets
     self.log = log
     self.got_buckets = got_buckets
     self.time_boundary = time_boundary
     ts = TimerService(interval, self.check_partition)
     ts.setServiceParent(self)
     ts.clock = clock
     self._old_buckets = []
Пример #5
0
 def __init__(self, reactor):
     MultiService.__init__(self)
     self._deployment_state = DeploymentState()
     timer = TimerService(1, self._wipe_expired)
     timer.clock = reactor
     timer.setServiceParent(self)
     self._information_wipers = pmap()
     self._clock = reactor
Пример #6
0
 def __init__(self, reactor):
     MultiService.__init__(self)
     self._deployment_state = DeploymentState()
     timer = TimerService(1, self._wipe_expired)
     timer.clock = reactor
     timer.setServiceParent(self)
     self._information_wipers = pmap()
     self._clock = reactor
def _convergence_service(reactor, interval, config, subscription_client, k8s, aws):
    def monitorable_converge(*a, **kw):
        d = converge(*a, **kw)
        def finished(passthrough):
            _CONVERGE_COMPLETE.set(reactor.seconds())
            return passthrough
        d.addCallback(finished)
        return d

    safe_converge = divert_errors_to_log(
        monitorable_converge, u"subscription_converger",
    )

    service = TimerService(
        interval,
        safe_converge,
        config,
        subscription_client,
        k8s,
        aws,
    )
    service.clock = reactor
    return service
def _convergence_service(reactor, interval, config, subscription_client, k8s, aws):
    def monitorable_converge(*a, **kw):
        d = converge(*a, **kw)
        def finished(passthrough):
            _CONVERGE_COMPLETE.set(reactor.seconds())
            return passthrough
        d.addCallback(finished)
        return d

    safe_converge = divert_errors_to_log(
        monitorable_converge, u"subscription_converger",
    )

    service = TimerService(
        interval,
        safe_converge,
        config,
        subscription_client,
        k8s,
        aws,
    )
    service.clock = reactor
    return service
Пример #9
0
 def __attrs_post_init__(self):
     super(HeartbeatingClients, self).__init__()
     timer = TimerService(self.interval, self._check_clients)
     timer.clock = self.clock
     self.addService(timer)
def _timer_service(reactor, *a, **kw):
    service = TimerService(*a, **kw)
    service.clock = reactor
    return service
Пример #11
0
def _timer_service(reactor, *a, **kw):
    service = TimerService(*a, **kw)
    service.clock = reactor
    return service