def _wait_startup_before_caching(self): # NOTE(lucasagomes): Some events are processed at the service's # startup time and since many services may be started concurrently # we do not want to use a cached hash ring at that point. This # method ensures that we start allowing the use of cached HashRings # once the number of HashRing nodes >= the number of api workers. # If the startup timeout already expired, there's no reason to # keep reading from the DB. At this point this will always # return False if not self._check_hashring_startup: return False api_workers = service._get_api_workers() nodes = db_hash_ring.get_active_nodes( self.admin_ctx, constants.HASH_RING_CACHE_TIMEOUT, self._group, from_host=True) if len(nodes) >= api_workers: LOG.debug("Allow caching, nodes %s>=%s", len(nodes), api_workers) self._check_hashring_startup = False return False LOG.debug("Disallow caching, nodes %s<%s", len(nodes), api_workers) return True
def test_api_workers_from_config(self): cfg.CONF.set_override('api_workers', 1234) self.assertEqual(1234, neutron_service._get_api_workers())
def test_api_workers_default(self): self.assertEqual(processutils.get_worker_count(), neutron_service._get_api_workers())
def test_api_workers_from_config(self): cfg.CONF.set_override('api_workers', 1234) self.assertEqual(1234, service._get_api_workers())
def test_api_workers_default(self): self.assertEqual(processutils.get_worker_count(), service._get_api_workers())