Adopted the oslo's rpc.Service change.

This fixes the collector part of the bug 1075463.

Declaring a consumer topic on the same rpc connection after the consume
thread has started would result the eventlet raise RuntimeError
exception. So all the declaring work should be done before calling
rpc.conn.consume_in_thread().

Using the hook 'initialize_service_hook()' provided by rpc.Service in
oslo to decalre the collector's specific topic consumers before starting
the consuming thread.

Change-Id: I33a98c228d45f7716e46d40d9203188f4e827c11
This commit is contained in:
Lianhao Lu 2012-11-08 16:28:16 +08:00
parent 7e595e8f28
commit 2b30965869
2 changed files with 7 additions and 0 deletions

View File

@ -60,6 +60,8 @@ class CollectorService(service.PeriodicService):
self.storage_engine = storage.get_engine(cfg.CONF)
self.storage_conn = self.storage_engine.get_connection(cfg.CONF)
def initialize_service_hook(self, service):
'''Consumers must be declared before consume_thread start.'''
self.ext_manager = extension_manager.ActivatedExtensionManager(
namespace=self.COLLECTOR_NAMESPACE,
disabled_names=cfg.CONF.disabled_notification_listeners,

View File

@ -57,6 +57,11 @@ class Service(service.Service):
self.conn.create_consumer(self.topic, dispatcher, fanout=True)
# Hook to allow the manager to do other initializations after
# the rpc connection is created.
if callable(getattr(self.manager, 'initialize_service_hook', None)):
self.manager.initialize_service_hook(self)
# Consume from all consumers in a thread
self.conn.consume_in_thread()