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:
parent
7e595e8f28
commit
2b30965869
@ -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,
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user