def start(self): for target in self.pool.targets: self.target_backends[target.id].start() super(Service, self).start() # Setup a Leader Election, use for ensuring certain tasks are executed # on exactly one pool-manager instance at a time] self._pool_election = coordination.LeaderElection( self._coordinator, '%s:%s' % (self.service_name, self.pool.id)) self._pool_election.start() if CONF['service:pool_manager'].enable_recovery_timer: LOG.info(_LI('Starting periodic recovery timer')) self.tg.add_timer( CONF['service:pool_manager'].periodic_recovery_interval, self.periodic_recovery, CONF['service:pool_manager'].periodic_recovery_interval) if CONF['service:pool_manager'].enable_sync_timer: LOG.info(_LI('Starting periodic synchronization timer')) self.tg.add_timer( CONF['service:pool_manager'].periodic_sync_interval, self.periodic_sync, CONF['service:pool_manager'].periodic_sync_interval)
def setUp(self): super(TestLeaderElectionWithoutBackend, self).setUp() # coordinator = None indicates no coordination backend has been # configured coordinator = None self.election = coordination.LeaderElection(coordinator, 'President')
def start(self): # Build the Pool (and related) Object from Config context = DesignateContext.get_admin_context() pool_id = CONF['service:pool_manager'].pool_id has_targets = False # TODO(kiall): This block of code should be replaced with a cleaner, # limited version. e.g. should retry for X minutes, and # backoff rather than fixed retry intervals. while not has_targets: try: self.pool = self.central_api.get_pool(context, pool_id) if len(self.pool.targets) > 0: has_targets = True else: LOG.error("No targets for %s found.", self.pool) time.sleep(5) # Pool data may not have migrated to the DB yet except exceptions.PoolNotFound: LOG.error("Pool ID %s not found.", pool_id) time.sleep(5) # designate-central service may not have started yet except messaging.exceptions.MessagingTimeout: time.sleep(0.2) # designate-central failed in an unknown way, don't allow another # failing / not started service to cause pool-manager to crash. except Exception: LOG.exception("An unknown exception occurred while " "fetching pool details") time.sleep(5) # Create the necessary Backend instances for each target self._setup_target_backends() for target in self.pool.targets: self.target_backends[target.id].start() super(Service, self).start() # Setup a Leader Election, use for ensuring certain tasks are executed # on exactly one pool-manager instance at a time] self._pool_election = coordination.LeaderElection( self._coordinator, '%s:%s' % (self.service_name, self.pool.id)) self._pool_election.start() if CONF['service:pool_manager'].enable_recovery_timer: interval = CONF['service:pool_manager'].periodic_recovery_interval LOG.info('Starting periodic recovery timer every' ' %(interval)s s', {'interval': interval}) self.tg.add_timer(interval, self.periodic_recovery, interval) if CONF['service:pool_manager'].enable_sync_timer: interval = CONF['service:pool_manager'].periodic_sync_interval LOG.info('Starting periodic synchronization timer every' ' %(interval)s s', {'interval': interval}) self.tg.add_timer(interval, self.periodic_sync, interval)
def setUp(self): super(TestLeaderElection, self).setUp() self.coord_fixture = self.useFixture( fixtures.CoordinatorFixture('zake://', b'InsertNameHere')) self.election = coordination.LeaderElection(self.coordinator, 'President')
def start(self): # Build the Pool (and related) Object from Config context = DesignateContext.get_admin_context() pool_id = CONF['service:pool_manager'].pool_id has_targets = False while not has_targets: try: self.pool = self.central_api.get_pool(context, pool_id) if len(self.pool.targets) > 0: has_targets = True else: LOG.error(_LE("No targets for %s found."), self.pool) time.sleep(5) # Pool data may not have migrated to the DB yet except exceptions.PoolNotFound: LOG.error(_LE("Pool ID %s not found."), pool_id) time.sleep(5) # designate-central service may not have started yet except messaging.exceptions.MessagingTimeout: time.sleep(0.2) # Create the necessary Backend instances for each target self._setup_target_backends() for target in self.pool.targets: self.target_backends[target.id].start() super(Service, self).start() # Setup a Leader Election, use for ensuring certain tasks are executed # on exactly one pool-manager instance at a time] self._pool_election = coordination.LeaderElection( self._coordinator, '%s:%s' % (self.service_name, self.pool.id)) self._pool_election.start() if CONF['service:pool_manager'].enable_recovery_timer: interval = CONF['service:pool_manager'].periodic_recovery_interval LOG.info( _LI('Starting periodic recovery timer every' ' %(interval)s s') % {'interval': interval}) self.tg.add_timer(interval, self.periodic_recovery, interval) if CONF['service:pool_manager'].enable_sync_timer: interval = CONF['service:pool_manager'].periodic_sync_interval LOG.info( _LI('Starting periodic synchronization timer every' ' %(interval)s s') % {'interval': interval}) self.tg.add_timer(interval, self.periodic_sync, interval)