"%(service_down_time)s, report_interval: " "%(report_interval)s>. Setting service_down_time to: "
"%(new_service_down_time)s"),
{'service_down_time': CONF.service_down_time,
'report_interval': report_interval,
'new_service_down_time': new_service_down_time})
CONF.set_override('service_down_time', new_service_down_time)
**** CubicPower OpenStack Study ****
def join(self, member_id, group_id, service=None):
"""Add a new member to the ServiceGroup
@param member_id: the joined member ID
@param group_id: the group name, of the joined member
@param service: the parameter can be used for notifications about
disconnect mode and update some internals
"""
msg = _('Join new ServiceGroup member %(member_id)s to the '
'%(group_id)s group, service = %(service)s')
LOG.debug(msg, {'member_id': member_id, 'group_id': group_id,
'service': service})
return self._driver.join(member_id, group_id, service)
**** CubicPower OpenStack Study ****
def service_is_up(self, member):
"""Check if the given member is up."""
msg = _('Check if the given member [%s] is part of the '
'ServiceGroup, is up')
LOG.debug(msg, member)
return self._driver.is_up(member)
**** CubicPower OpenStack Study ****
def leave(self, member_id, group_id):
"""Explicitly remove the given member from the ServiceGroup
monitoring.
"""
msg = _('Explicitly remove the given member %(member_id)s from the'
'%(group_id)s group monitoring')
LOG.debug(msg, {'member_id': member_id, 'group_id': group_id})
return self._driver.leave(member_id, group_id)
**** CubicPower OpenStack Study ****
def get_all(self, group_id):
"""Returns ALL members of the given group."""
LOG.debug(_('Returns ALL members of the [%s] '
'ServiceGroup'), group_id)
return self._driver.get_all(group_id)
**** CubicPower OpenStack Study ****
def get_one(self, group_id):
"""Returns one member of the given group. The strategy to select
the member is decided by the driver (e.g. random or round-robin).
"""
LOG.debug(_('Returns one member of the [%s] group'), group_id)
return self._driver.get_one(group_id)
**** CubicPower OpenStack Study ****
class ServiceGroupDriver(object):
"""Base class for ServiceGroup drivers."""
**** CubicPower OpenStack Study ****
def join(self, member_id, group_id, service=None):
"""Join the given service with it's group."""
raise NotImplementedError()
**** CubicPower OpenStack Study ****
def is_up(self, member):
"""Check whether the given member is up."""
raise NotImplementedError()
**** CubicPower OpenStack Study ****
def leave(self, member_id, group_id):
"""Remove the given member from the ServiceGroup monitoring."""
raise NotImplementedError()
**** CubicPower OpenStack Study ****
def get_all(self, group_id):
"""Returns ALL members of the given group."""
raise NotImplementedError()
**** CubicPower OpenStack Study ****
def get_one(self, group_id):
"""The default behavior of get_one is to randomly pick one from
the result of get_all(). This is likely to be overridden in the
actual driver implementation.
"""
members = self.get_all(group_id)
if members is None:
return None
length = len(members)
if length == 0:
return None
return random.choice(members)