Merge "start rpc deprecation"

This commit is contained in:
Jenkins 2015-08-13 09:48:09 +00:00 committed by Gerrit Code Review
commit 6a7d3feb47
3 changed files with 16 additions and 4 deletions

View File

@ -45,6 +45,11 @@ OPTS = [
default=False,
help='Requeue the event on the collector event queue '
'when the collector fails to dispatch it.'),
cfg.BoolOpt('enable_rpc',
default=False,
help='Enable the RPC functionality of collector. This '
'functionality is now deprecated in favour of notifier '
'publisher and queues.')
]
cfg.CONF.register_opts(OPTS, group="collector")
@ -77,8 +82,11 @@ class CollectorService(os_service.Service):
transport = messaging.get_transport(optional=True)
if transport:
self.rpc_server = messaging.get_rpc_server(
transport, cfg.CONF.publisher_rpc.metering_topic, self)
if cfg.CONF.collector.enable_rpc:
LOG.warning('RPC collector is deprecated in favour of queues. '
'Please switch to notifier publisher.')
self.rpc_server = messaging.get_rpc_server(
transport, cfg.CONF.publisher_rpc.metering_topic, self)
sample_target = oslo_messaging.Target(
topic=cfg.CONF.publisher_notifier.metering_topic)
@ -98,7 +106,8 @@ class CollectorService(os_service.Service):
requeue_event_on_dispatcher_error))
self.event_listener.start()
self.rpc_server.start()
if cfg.CONF.collector.enable_rpc:
self.rpc_server.start()
self.sample_listener.start()
if not cfg.CONF.collector.udp_address:
@ -133,7 +142,7 @@ class CollectorService(os_service.Service):
def stop(self):
self.udp_run = False
if self.rpc_server:
if cfg.CONF.collector.enable_rpc and self.rpc_server:
self.rpc_server.stop()
if self.sample_listener:
utils.kill_listeners([self.sample_listener])

View File

@ -38,6 +38,7 @@ LOG = log.getLogger(__name__)
RPC_OPTS = [
cfg.StrOpt('metering_topic',
default='metering',
deprecated_for_removal=True,
help='The topic that ceilometer uses for metering messages.',
deprecated_group="DEFAULT",
),

View File

@ -209,6 +209,7 @@ class TestCollector(tests_base.BaseTestCase):
@mock.patch.object(collector.CollectorService, 'start_udp')
def test_only_rpc(self, udp_start, rpc_start):
"""Check that only RPC is started if udp_address is empty."""
self.CONF.set_override('enable_rpc', True, group='collector')
self.CONF.set_override('udp_address', '', group='collector')
self.srv.start()
# two calls because two servers (notification and rpc)
@ -228,6 +229,7 @@ class TestCollector(tests_base.BaseTestCase):
@mock.patch('ceilometer.storage.impl_log.LOG')
def test_collector_no_mock(self, mylog):
self.CONF.set_override('enable_rpc', True, group='collector')
self.CONF.set_override('udp_address', '', group='collector')
self.srv.start()
mylog.info.side_effect = lambda *args: self.srv.stop()