Exemple #1
0
    def start(self):
        super(Service, self).start()

        self._partitioner = coordination.Partitioner(self._coordinator,
                                                     self.service_name,
                                                     self._coordination_id,
                                                     range(0, 4095))

        self._partitioner.start()
        self._partitioner.watch_partition_change(self._rebalance)

        # TODO(timsim): Remove this when zone_mgr goes away
        zmgr_enabled_tasks = CONF['service:zone_manager'].enabled_tasks
        producer_enabled_tasks = CONF['service:producer'].enabled_tasks
        enabled = zmgr_enabled_tasks
        if producer_enabled_tasks != []:
            enabled = producer_enabled_tasks

        for task in tasks.PeriodicTask.get_extensions(enabled):
            LOG.debug("Registering task %s", task)

            # Instantiate the task
            task = task()

            # Subscribe for partition size updates.
            self._partitioner.watch_partition_change(task.on_partition_change)

            interval = CONF[task.get_canonical_name()].interval
            self.tg.add_timer(interval, task)
    def _get_partitioner(self, partitions, host='a'):
        fixture = self.useFixture(fixtures.CoordinatorFixture('zake://', host))
        group = 'group'
        fixture.coordinator.create_group(group)
        fixture.coordinator.join_group(group)

        return coordination.Partitioner(fixture.coordinator, group, host,
                                        partitions), fixture.coordinator
    def test_cb_on_watch(self):
        partitions = range(0, 10)
        cb = mock.Mock()

        partitioner = coordination.Partitioner(None, 'group', 'meme',
                                               partitions)
        partitioner.start()
        partitioner.watch_partition_change(cb)
        cb.assert_called_with(partitions, None, None)
    def test_start(self):
        # We test starting the partitioner and calling the watch func first
        partitions = range(0, 10)

        cb1 = mock.Mock()
        cb2 = mock.Mock()
        partitioner = coordination.Partitioner(None, 'group', 'meme',
                                               partitions)
        partitioner.watch_partition_change(cb1)
        partitioner.watch_partition_change(cb2)
        partitioner.start()
        cb1.assert_called_with(partitions, None, None)
        cb2.assert_called_with(partitions, None, None)
Exemple #5
0
    def start(self):
        super(Service, self).start()
        self.coordination.start()

        self._partitioner = coordination.Partitioner(
            self.coordination.coordinator, self.service_name,
            self.coordination.coordination_id.encode(), range(0, 4095))

        self._partitioner.start()
        self._partitioner.watch_partition_change(self._rebalance)

        enabled_tasks = CONF['service:producer'].enabled_tasks
        for task in tasks.PeriodicTask.get_extensions(enabled_tasks):
            LOG.debug("Registering task %s", task)

            # Instantiate the task
            task = task()

            # Subscribe for partition size updates.
            self._partitioner.watch_partition_change(task.on_partition_change)

            interval = CONF[task.get_canonical_name()].interval
            self.tg.add_timer(interval, task)
Exemple #6
0
    def __init__(self, threads=None):
        super(Service, self).__init__(threads=threads)

        self._partitioner = coordination.Partitioner(
            self._coordinator, self.service_name, self._coordination_id,
            range(0, 4095))