Adds proxy functions
Change-Id: I5124a85ea15dd6baf2e624c8c7e857dece7906a5
This commit is contained in:
@@ -39,11 +39,12 @@ class DbDriver(api.ServiceGroupDriver):
|
||||
"""Join the given service with it's group."""
|
||||
|
||||
msg = _('DB_Driver: join new ServiceGroup member %(member_id)s to '
|
||||
'the %(group_id)s group, service = %(service)s')
|
||||
'the %(group_id)s group, service = %(service)s')
|
||||
LOG.debug(msg, {'member_id': member_id, 'group_id': group_id,
|
||||
'service': service})
|
||||
if service is None:
|
||||
raise RuntimeError(_('service is a mandatory argument for DB based'
|
||||
raise RuntimeError(_('service is a mandatory argument for DB '
|
||||
'based'
|
||||
' ServiceGroup driver'))
|
||||
report_interval = service.report_interval
|
||||
if report_interval:
|
||||
@@ -88,7 +89,8 @@ class DbDriver(api.ServiceGroupDriver):
|
||||
state_catalog['report_count'] = report_count
|
||||
|
||||
service.service_ref = db.service_update(ctxt,
|
||||
service.service_ref['id'], state_catalog)
|
||||
service.service_ref['id'],
|
||||
state_catalog)
|
||||
|
||||
if getattr(service, 'model_disconnected', False):
|
||||
service.model_disconnected = False
|
||||
|
||||
@@ -77,7 +77,7 @@ class MemcachedDriver(api.ServiceGroupDriver):
|
||||
|
||||
def _report_state(self, service):
|
||||
"""Update the state of this service in the datastore."""
|
||||
ctxt = context.get_admin_context()
|
||||
context.get_admin_context()
|
||||
try:
|
||||
key = "%(topic)s:%(host)s" % service.service_ref
|
||||
# memcached has data expiration time capability.
|
||||
|
||||
@@ -41,7 +41,7 @@ zk_driver_opts = [
|
||||
default=5,
|
||||
help='Number of seconds to wait until retrying to join the '
|
||||
'session'),
|
||||
]
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(zk_driver_opts, group="zookeeper")
|
||||
@@ -50,6 +50,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ZooKeeperDriver(api.ServiceGroupDriver):
|
||||
|
||||
"""ZooKeeper driver for the service group API."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -58,8 +59,8 @@ class ZooKeeperDriver(api.ServiceGroupDriver):
|
||||
raise ImportError('zookeeper module not found')
|
||||
null = open(os.devnull, "w")
|
||||
self._session = evzookeeper.ZKSession(CONF.zookeeper.address,
|
||||
recv_timeout=
|
||||
CONF.zookeeper.recv_timeout,
|
||||
recv_timeout=CONF.zookeeper
|
||||
.recv_timeout,
|
||||
zklog_fd=null)
|
||||
self._memberships = {}
|
||||
self._monitors = {}
|
||||
@@ -76,7 +77,7 @@ class ZooKeeperDriver(api.ServiceGroupDriver):
|
||||
"""Join the given service with its group."""
|
||||
LOG.debug(_('ZooKeeperDriver: join new member %(id)s to the '
|
||||
'%(gr)s group, service=%(sr)s'),
|
||||
{'id': member_id, 'gr': group, 'sr': service})
|
||||
{'id': member_id, 'gr': group, 'sr': service})
|
||||
member = self._memberships.get((group, member_id), None)
|
||||
if member is None:
|
||||
# the first time to join. Generate a new object
|
||||
@@ -137,9 +138,11 @@ class ZooKeeperDriver(api.ServiceGroupDriver):
|
||||
|
||||
|
||||
class FakeLoopingCall(loopingcall.LoopingCallBase):
|
||||
|
||||
"""The fake Looping Call implementation, created for backward
|
||||
compatibility with a membership based on DB.
|
||||
"""
|
||||
|
||||
def __init__(self, driver, host, group):
|
||||
self._driver = driver
|
||||
self._group = group
|
||||
|
||||
Reference in New Issue
Block a user