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


Python coordination.get_coordinator方法代码示例

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


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

示例1: coordinator_setup

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
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 
开发者ID:StackStorm,项目名称:st2,代码行数:27,代码来源:coordination.py

示例2: get_coordinator

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
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 
开发者ID:StackStorm,项目名称:st2,代码行数:26,代码来源:coordination.py

示例3: start

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
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.') 
开发者ID:openstack,项目名称:ironic-inspector,代码行数:20,代码来源:coordination.py

示例4: get_coordinator_and_start

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
def get_coordinator_and_start(member_id, url):
    coord = coordination.get_coordinator(url, member_id)
    coord.start(start_heart=True)
    return coord 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:6,代码来源:metricd.py

示例5: start

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
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:openstack,项目名称:compute-hyperv,代码行数:12,代码来源:coordination.py

示例6: __init__

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
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} 
开发者ID:openstack,项目名称:networking-generic-switch,代码行数:29,代码来源:__init__.py

示例7: start

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
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 
开发者ID:openstack,项目名称:manila,代码行数:13,代码来源:coordination.py

示例8: __init__

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
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) 
开发者ID:openstack,项目名称:cloudkitty,代码行数:9,代码来源:orchestrator.py

示例9: get_coordinator

# 需要导入模块: from tooz import coordination [as 别名]
# 或者: from tooz.coordination import get_coordinator [as 别名]
def get_coordinator(prefix=None):
    global _COORDINATOR
    if _COORDINATOR is None:
        _COORDINATOR = Coordinator(prefix=prefix)
    return _COORDINATOR 
开发者ID:openstack,项目名称:ironic-inspector,代码行数:7,代码来源:coordination.py


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