当前位置: 首页>>代码示例>>Python>>正文


Python coordination.get_coordinator函数代码示例

本文整理汇总了Python中tooz.coordination.get_coordinator函数的典型用法代码示例。如果您正苦于以下问题:Python get_coordinator函数的具体用法?Python get_coordinator怎么用?Python get_coordinator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_coordinator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_base_dir_win32

    def test_base_dir_win32(self):
        coord = coordination.get_coordinator(
            'file:///C:/path/', self._FAKE_MEMBER_ID)
        self.assertEqual('C:\\path\\', coord._dir)

        coord = coordination.get_coordinator(
            'file:////share_addr/share_path/', self._FAKE_MEMBER_ID)
        self.assertEqual('\\\\share_addr\\share_path\\', coord._dir)

        # Administrative shares should be handled properly.
        coord = coordination.get_coordinator(
            'file:////c$/path/', self._FAKE_MEMBER_ID)
        self.assertEqual('\\\\c$\\path\\', coord._dir)
开发者ID:openstack,项目名称:tooz,代码行数:13,代码来源:test_file.py

示例2: coordinator_setup

def coordinator_setup(start_heart=True):
    """
    Sets up the client for the coordination service.

    URL examples for connection:
        zake://
        file:///tmp
        redis://username:[email protected]:port
        mysql://username:[email protected]: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
开发者ID:StackStorm,项目名称:st2,代码行数:25,代码来源:coordination.py

示例3: tooz_make_change

def tooz_make_change(driver, url, session, vol_id, initial, destination,
                     attach_status):
    global coordinator
    global lock
    global acquired

    # If coordinator is not the one we want we cannot reuse it
    if not isinstance(coordinator, driver):
        if coordinator:
            coordinator.stop()

        # Create new coordinator and lock
        coordinator = coordination.get_coordinator(url, str(session))
        coordinator.start()
        lock = coordinator.get_lock(vol_id)

    # When going from available to any other state we acquire the lock
    if initial == 'available':
        # If this is a retry we've already acquired the lock
        if not acquired:
            while not lock.acquire():
                coordinator.heartbeat()
                time.sleep(0.01)
            acquired = True

    n = 0
    while n == 0:
        n = safe_update(session, vol_id,
                        {'status': destination,
                         'attach_status': attach_status},
                        {'status': initial})
    coordinator.heartbeat()
    if destination == 'available':
        lock.release()
        acquired = False
开发者ID:Akrog,项目名称:test-cinder-atomic-states,代码行数:35,代码来源:_tooz_gl.py

示例4: __init__

    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

        transformers = transformer.get_transformers()
        self.collector = collector.get_collector(transformers)
        self.storage = storage.get_storage()
        self._state = state.StateManager()

        # RPC
        self.server = None
        self._rating_endpoint = RatingEndpoint(self)
        self._init_messaging()

        # DLM
        self.coord = coordination.get_coordinator(
            CONF.orchestrator.coordination_url,
            uuidutils.generate_uuid().encode('ascii'))
        self.coord.start(start_heart=True)
开发者ID:openstack,项目名称:cloudkitty,代码行数:25,代码来源:orchestrator.py

示例5: coordinator_setup

def coordinator_setup():
    """
    Sets up the client for the coordination service.

    URL examples for connection:
        zake://
        file:///tmp
        redis://username:[email protected]:port
        mysql://username:[email protected]:port/dbname
    """
    url = cfg.CONF.coordination.url
    lock_timeout = cfg.CONF.coordination.lock_timeout
    proc_info = system_info.get_process_info()
    member_id = six.b('%s_%d' % (proc_info['hostname'], proc_info['pid']))

    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()
    return coordinator
开发者ID:lyandut,项目名称:st2,代码行数:26,代码来源:coordination.py

示例6: test_client_failure_heartbeat

 def test_client_failure_heartbeat(self, mock_client_cls):
     mock_client = mock.MagicMock()
     mock_client_cls.return_value = mock_client
     member_id = str(uuid.uuid4()).encode('ascii')
     coord = coordination.get_coordinator(self.FAKE_URL, member_id)
     coord.start()
     mock_client.set.side_effect = socket.timeout('timed-out')
     self.assertRaises(coordination.ToozConnectionError, coord.heartbeat)
开发者ID:yunjianfei,项目名称:tooz,代码行数:8,代码来源:test_memcache.py

示例7: _get_lock_distributed

    def _get_lock_distributed(name):
        if not LockManager._coordinator:
            LOG.debug("Initialized coordinator with connect string %s", LockManager._connect_string)
            LockManager._coordinator = coordination.get_coordinator(
                LockManager._connect_string, "vmware-neutron-plugin"
            )

        LOG.debug("Retrieved lock for ", name)
        return LockManager._coordinator.get_lock(name)
开发者ID:wubala,项目名称:vmware-nsx,代码行数:9,代码来源:locking.py

示例8: test_client_run_watchers_mixin

 def test_client_run_watchers_mixin(self, mock_client_cls,
                                    mock_run_watchers):
     mock_client = mock.MagicMock()
     mock_client_cls.return_value = mock_client
     member_id = tests.get_random_uuid()
     coord = coordination.get_coordinator(self.FAKE_URL, member_id)
     coord.start()
     coord.run_watchers()
     self.assertTrue(mock_run_watchers.called)
开发者ID:openstack,项目名称:tooz,代码行数:9,代码来源:test_memcache.py

示例9: test_client_failure_leave

 def test_client_failure_leave(self, mock_client_cls):
     mock_client = mock.MagicMock()
     mock_client_cls.return_value = mock_client
     member_id = tests.get_random_uuid()
     coord = coordination.get_coordinator(self.FAKE_URL, member_id)
     coord.start()
     mock_client.gets.side_effect = socket.timeout('timed-out')
     fut = coord.leave_group(tests.get_random_uuid())
     self.assertRaises(coordination.ToozConnectionError, fut.get)
开发者ID:openstack,项目名称:tooz,代码行数:9,代码来源:test_memcache.py

示例10: test_client_run_watchers_mixin

 def test_client_run_watchers_mixin(self, mock_client_cls,
                                    mock_run_watchers):
     mock_client = mock.MagicMock()
     mock_client_cls.return_value = mock_client
     member_id = str(uuid.uuid4()).encode('ascii')
     coord = coordination.get_coordinator(self.FAKE_URL, member_id)
     coord.start()
     coord.run_watchers()
     self.assertTrue(mock_run_watchers.called)
开发者ID:csfreak,项目名称:tooz,代码行数:9,代码来源:test_memcache.py

示例11: start

    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
开发者ID:j-griffith,项目名称:cinder,代码行数:10,代码来源:coordination.py

示例12: __init__

 def __init__(self, conf):
     super(CarbonaraBasedStorage, self).__init__(conf)
     try:
         self.coord = coordination.get_coordinator(
             conf.coordination_url,
             str(uuid.uuid4()).encode('ascii'))
         self.coord.start(start_heart=True)
     except Exception as e:
         raise storage.StorageError("Unable to start coordinator: %s" % e)
     self.aggregation_workers_number = conf.aggregation_workers_number
开发者ID:shushen,项目名称:gnocchi,代码行数:10,代码来源:_carbonara.py

示例13: __init__

    def __init__(self, worker_id, conf, namespaces=None):
        namespaces = namespaces or ['compute', 'central']
        group_prefix = conf.polling.partitioning_group_prefix

        super(AgentManager, self).__init__(worker_id)

        self.conf = conf

        if type(namespaces) is not list:
            namespaces = [namespaces]

        # we'll have default ['compute', 'central'] here if no namespaces will
        # be passed
        extensions = (self._extensions('poll', namespace, self.conf).extensions
                      for namespace in namespaces)
        # get the extensions from pollster builder
        extensions_fb = (self._extensions_from_builder('poll', namespace)
                         for namespace in namespaces)

        self.extensions = list(itertools.chain(*list(extensions))) + list(
            itertools.chain(*list(extensions_fb)))

        if not self.extensions:
            LOG.warning('No valid pollsters can be loaded from %s '
                        'namespaces', namespaces)

        discoveries = (self._extensions('discover', namespace,
                                        self.conf).extensions
                       for namespace in namespaces)
        self.discoveries = list(itertools.chain(*list(discoveries)))
        self.polling_periodics = None

        self.hashrings = None
        self.partition_coordinator = None
        if self.conf.coordination.backend_url:
            # XXX uuid4().bytes ought to work, but it requires ascii for now
            coordination_id = str(uuid.uuid4()).encode('ascii')
            self.partition_coordinator = coordination.get_coordinator(
                self.conf.coordination.backend_url, coordination_id)

        # Compose coordination group prefix.
        # We'll use namespaces as the basement for this partitioning.
        namespace_prefix = '-'.join(sorted(namespaces))
        self.group_prefix = ('%s-%s' % (namespace_prefix, group_prefix)
                             if group_prefix else namespace_prefix)

        self.notifier = oslo_messaging.Notifier(
            messaging.get_transport(self.conf),
            driver=self.conf.publisher_notifier.telemetry_driver,
            publisher_id="ceilometer.polling")

        self._keystone = None
        self._keystone_last_exception = None
开发者ID:openstack,项目名称:ceilometer,代码行数:53,代码来源:manager.py

示例14: __init__

 def __init__(self, conf):
     super(CarbonaraBasedStorage, self).__init__(conf)
     self.coord = coordination.get_coordinator(
         conf.coordination_url,
         str(uuid.uuid4()).encode('ascii'))
     self.coord.start()
     if conf.aggregation_workers_number is None:
         try:
             self.aggregation_workers_number = multiprocessing.cpu_count()
         except NotImplementedError:
             self.aggregation_workers_number = 2
     else:
         self.aggregation_workers_number = conf.aggregation_workers_number
开发者ID:openstack-yak,项目名称:gnocchi,代码行数:13,代码来源:_carbonara.py

示例15: __init__

    def __init__(self, backend_url):
        self.coordinator = None
        self.member_id = uuidutils.generate_uuid()

        if backend_url:
            try:
                self.coordinator = coordination.get_coordinator(
                    backend_url, self.member_id)
                self.coordinator.start()
                LOG.info('Coordination backend loaded successfully.')
            except coordination.ToozError:
                LOG.error('Error connecting to coordination backend.')
                raise
开发者ID:openstack,项目名称:sahara,代码行数:13,代码来源:coordinator.py


注:本文中的tooz.coordination.get_coordinator函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。