Renamed start_rpc_listener -> start_rpc_listeners

Now that we explicitly start multiple RPC servers, renamed the method to
reflect behaviour.

blueprint oslo-messaging

Change-Id: I7c51cc1b44b4b4c8899255b9bedce1792c38634e
This commit is contained in:
Ihar Hrachyshka 2014-06-09 14:32:05 +02:00
parent 3aca3f7745
commit 4b5ddba894
8 changed files with 18 additions and 18 deletions

View File

@ -324,10 +324,10 @@ class NeutronPluginBaseV2(object):
"""
pass
def start_rpc_listener(self):
"""Start the rpc listener.
def start_rpc_listeners(self):
"""Start the RPC listeners.
Most plugins start an RPC listener implicitly on initialization. In
Most plugins start RPC listeners implicitly on initialization. In
order to support multiple process RPC, the plugin needs to expose
control over when this is started.
@ -340,13 +340,13 @@ class NeutronPluginBaseV2(object):
"""Return whether the plugin supports multiple RPC workers.
A plugin that supports multiple RPC workers should override the
start_rpc_listener method to ensure that this method returns True and
that start_rpc_listener is called at the appropriate time.
start_rpc_listeners method to ensure that this method returns True and
that start_rpc_listeners is called at the appropriate time.
Alternately, a plugin can override this method to customize detection
of support for multiple rpc workers
.. note:: this method is optional, as it was not part of the originally
defined plugin API.
"""
return (self.__class__.start_rpc_listener !=
NeutronPluginBaseV2.start_rpc_listener)
return (self.__class__.start_rpc_listeners !=
NeutronPluginBaseV2.start_rpc_listeners)

View File

@ -203,8 +203,8 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
flavor = self._get_flavor_by_network_id(context, network['id'])
network[ext_flavor.FLAVOR_NETWORK] = flavor
def start_rpc_listener(self):
return self.plugins[self.rpc_flavor].start_rpc_listener()
def start_rpc_listeners(self):
return self.plugins[self.rpc_flavor].start_rpc_listeners()
def rpc_workers_supported(self):
#NOTE: If a plugin which supports multiple RPC workers is desired

View File

@ -125,7 +125,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
)
def start_rpc_listener(self):
def start_rpc_listeners(self):
self.callbacks = rpc.RpcCallbacks(self.notifier, self.type_manager)
self.topic = topics.PLUGIN
self.conn = rpc_compat.create_connection(new=True)

View File

@ -119,7 +119,7 @@ class RpcWorker(object):
# existing sql connections avoids producing errors later when they are
# discovered to be broken.
session.get_engine().pool.dispose()
self._servers = self._plugin.start_rpc_listener()
self._servers = self._plugin.start_rpc_listeners()
def wait(self):
for server in self._servers:
@ -136,14 +136,14 @@ class RpcWorker(object):
def serve_rpc():
plugin = manager.NeutronManager.get_plugin()
# If 0 < rpc_workers then start_rpc_listener would be called in a
# If 0 < rpc_workers then start_rpc_listeners would be called in a
# subprocess and we cannot simply catch the NotImplementedError. It is
# simpler to check this up front by testing whether the plugin supports
# multiple RPC workers.
if not plugin.rpc_workers_supported():
LOG.debug(_("Active plugin doesn't implement start_rpc_listener"))
LOG.debug(_("Active plugin doesn't implement start_rpc_listeners"))
if 0 < cfg.CONF.rpc_workers:
msg = _("'rpc_workers = %d' ignored because start_rpc_listener "
msg = _("'rpc_workers = %d' ignored because start_rpc_listeners "
"is not implemented.")
LOG.error(msg, cfg.CONF.rpc_workers)
raise NotImplementedError

View File

@ -74,6 +74,6 @@ class Fake2(Fake1):
def fake_func2(self):
return 'fake2'
def start_rpc_listener(self):
def start_rpc_listeners(self):
# return value is only used to confirm this method was called.
return 'OK'

View File

@ -400,5 +400,5 @@ class MetaNeutronPluginV2TestRpcFlavor(base.BaseTestCase):
self.assertEqual(topics.PLUGIN, 'q-plugin')
ret = self.plugin.rpc_workers_supported()
self.assertTrue(ret)
ret = self.plugin.start_rpc_listener()
ret = self.plugin.start_rpc_listeners()
self.assertEqual('OK', ret)

View File

@ -39,7 +39,7 @@ class PortBindingTestCase(test_plugin.NeutronDbPluginV2TestCase):
super(PortBindingTestCase, self).setUp(PLUGIN_NAME)
self.port_create_status = 'DOWN'
self.plugin = manager.NeutronManager.get_plugin()
self.plugin.start_rpc_listener()
self.plugin.start_rpc_listeners()
def _check_response(self, port, vif_type, has_port_filter, bound, status):
self.assertEqual(port[portbindings.VIF_TYPE], vif_type)

View File

@ -53,7 +53,7 @@ class TestMl2SecurityGroups(Ml2SecurityGroupsTestCase,
def setUp(self):
super(TestMl2SecurityGroups, self).setUp()
plugin = manager.NeutronManager.get_plugin()
plugin.start_rpc_listener()
plugin.start_rpc_listeners()
def test_security_group_get_port_from_device(self):
with self.network() as n: