Python tooz.coordination.get_coordinator() Examples
The following are 11
code examples of tooz.coordination.get_coordinator().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tooz.coordination
, or try the search function
.
Example #1
Source File: coordination.py From st2 with Apache License 2.0 | 6 votes |
def coordinator_setup(start_heart=True): """ Sets up the client for the coordination service. URL examples for connection: zake:// file:///tmp redis://username:password@host:port mysql://username:password@host:port/dbname """ url = cfg.CONF.coordination.url lock_timeout = cfg.CONF.coordination.lock_timeout member_id = get_member_id() if url: coordinator = coordination.get_coordinator(url, member_id, lock_timeout=lock_timeout) else: # Use a no-op backend # Note: We don't use tooz to obtain a reference since for this to work we would need to # register a plugin inside setup.py entry_point and use python setup.py develop for tests # to work coordinator = NoOpDriver(member_id) coordinator.start(start_heart=start_heart) return coordinator
Example #2
Source File: coordination.py From st2 with Apache License 2.0 | 6 votes |
def get_coordinator(start_heart=True, use_cache=True): """ :param start_heart: True to start heartbeating process. :type start_heart: ``bool`` :param use_cache: True to use cached coordinator instance. False should only be used in tests. :type use_cache: ``bool`` """ global COORDINATOR if not configured(): LOG.warn('Coordination backend is not configured. Code paths which use coordination ' 'service will use best effort approach and race conditions are possible.') if not use_cache: return coordinator_setup(start_heart=start_heart) if not COORDINATOR: COORDINATOR = coordinator_setup(start_heart=start_heart) LOG.debug('Initializing and caching new coordinator instance: %s' % (str(COORDINATOR))) else: LOG.debug('Using cached coordinator instance: %s' % (str(COORDINATOR))) return COORDINATOR
Example #3
Source File: coordination.py From ironic-inspector with Apache License 2.0 | 6 votes |
def start(self, heartbeat=True): """Start coordinator. :param heartbeat: Whether spawns a new thread to keep heartbeating with the tooz backend. Unless there is periodic task to do heartbeat manually, it should be always set to True. """ if self.started: return member_id = '.'.join([COORDINATION_PREFIX, self.prefix, CONF.host]).encode('ascii') self.coordinator = coordination.get_coordinator( CONF.coordination.backend_url, member_id) self.coordinator.start(start_heart=heartbeat) self.started = True LOG.debug('Coordinator started successfully.')
Example #4
Source File: metricd.py From gnocchi with Apache License 2.0 | 5 votes |
def get_coordinator_and_start(member_id, url): coord = coordination.get_coordinator(url, member_id) coord.start(start_heart=True) return coord
Example #5
Source File: coordination.py From compute-hyperv with Apache License 2.0 | 5 votes |
def start(self): if self.started: return # NOTE(bluex): Tooz expects member_id as a byte string. member_id = (self.prefix + self.agent_id).encode('ascii') self.coordinator = coordination.get_coordinator( cfg.CONF.coordination.backend_url, member_id) self.coordinator.start(start_heart=True) self.started = True
Example #6
Source File: __init__.py From networking-generic-switch with Apache License 2.0 | 5 votes |
def __init__(self, device_cfg): super(NetmikoSwitch, self).__init__(device_cfg) device_type = self.config.get('device_type', '') # use part that is after 'netmiko_' device_type = device_type.partition('netmiko_')[2] if device_type not in netmiko.platforms: raise exc.GenericSwitchNetmikoNotSupported( device_type=device_type) self.config['device_type'] = device_type if CONF.ngs.session_log_file: self.config['session_log'] = CONF.ngs.session_log_file self.config['session_log_record_writes'] = True self.config['session_log_file_mode'] = 'append' self.locker = None if CONF.ngs_coordination.backend_url: self.locker = coordination.get_coordinator( CONF.ngs_coordination.backend_url, ('ngs-' + CONF.host).encode('ascii')) self.locker.start() atexit.register(self.locker.stop) self.lock_kwargs = { 'locks_pool_size': int(self.ngs_config['ngs_max_connections']), 'locks_prefix': self.config.get( 'host', '') or self.config.get('ip', ''), 'timeout': CONF.ngs_coordination.acquire_timeout}
Example #7
Source File: coordination.py From manila with Apache License 2.0 | 5 votes |
def start(self): """Connect to coordination back end.""" if self.started: return # NOTE(gouthamr): Tooz expects member_id as a byte string. member_id = (self.prefix + self.agent_id).encode('ascii') self.coordinator = coordination.get_coordinator( cfg.CONF.coordination.backend_url, member_id) self.coordinator.start(start_heart=True) self.started = True
Example #8
Source File: orchestrator.py From cloudkitty with Apache License 2.0 | 5 votes |
def __init__(self): self._coord = coordination.get_coordinator( CONF.orchestrator.coordination_url, uuidutils.generate_uuid().encode('ascii')) self._state = state.StateManager() self._storage = storage.get_storage() self._coord.start(start_heart=True)
Example #9
Source File: orchestrator.py From cloudkitty with Apache License 2.0 | 5 votes |
def __init__(self, worker_id): self._worker_id = worker_id super(Orchestrator, self).__init__(self._worker_id) self.fetcher = driver.DriverManager( FETCHERS_NAMESPACE, CONF.fetcher.backend, invoke_on_load=True, ).driver self.collector = collector.get_collector() self.storage = storage.get_storage() self._state = state.StateManager() # RPC self.server = None self._rating_endpoint = RatingEndpoint(self) self._scope_endpoint = ScopeEndpoint() self._init_messaging() # DLM self.coord = coordination.get_coordinator( CONF.orchestrator.coordination_url, uuidutils.generate_uuid().encode('ascii')) self.coord.start(start_heart=True) self._check_state = functools.partial( _check_state, self, CONF.collect.period)
Example #10
Source File: coordination.py From tacker with Apache License 2.0 | 5 votes |
def start(self): if self.started: return # NOTE(bluex): Tooz expects member_id as a byte string. member_id = (self.prefix + self.agent_id).encode('ascii') self.coordinator = coordination.get_coordinator( cfg.CONF.coordination.backend_url, member_id) self.coordinator.start(start_heart=True) self.started = True
Example #11
Source File: coordination.py From ironic-inspector with Apache License 2.0 | 5 votes |
def get_coordinator(prefix=None): global _COORDINATOR if _COORDINATOR is None: _COORDINATOR = Coordinator(prefix=prefix) return _COORDINATOR