Allows to change defaults opts

This change introduces to possibility for the consumer application
to change the default oslo.messaging config options.

Same API interface as oslo.db have been taken.
The first option is executor_thread_pool_size.

This option was called rpc_thread_pool_size, but because it's used by
notification and rpc 'executor_thread_pool_size' looks a better name.

Changing executor_thread_pool_size default will be useful for ceilometer
the default of 64 is really to small to consume many notifications at
once for batching them. When is clearly sufficient for rpc stuffs.

Change-Id: Iea0d7a72e38d27c600403c815258aa5eee0d0c8c
This commit is contained in:
Mehdi Abaakouk 2015-07-18 14:32:34 +02:00
parent 10bc6244aa
commit d94d6d6892
4 changed files with 35 additions and 4 deletions

View File

@ -465,7 +465,8 @@ class ZmqBaseReactor(ConsumerBase):
self.sockets = []
self.subscribe = {}
self.pool = eventlet.greenpool.GreenPool(conf.rpc_thread_pool_size)
self.pool = eventlet.greenpool.GreenPool(
conf.executor_thread_pool_size)
def register(self, proxy, in_addr, zmq_type_in,
in_bind=True, subscribe=None):

View File

@ -25,9 +25,10 @@ from oslo_utils import excutils
from oslo_messaging._executors import base
_pool_opts = [
cfg.IntOpt('rpc_thread_pool_size',
cfg.IntOpt('executor_thread_pool_size',
default=64,
help='Size of RPC thread pool.'),
deprecated_name="rpc_thread_pool_size",
help='Size of executor thread pool.'),
]
@ -103,7 +104,8 @@ class PooledExecutor(base.ExecutorBase):
def start(self):
if self._executor is None:
self._executor = self._executor_cls(self.conf.rpc_thread_pool_size)
self._executor = self._executor_cls(
self.conf.executor_thread_pool_size)
self._tombstone.clear()
if self._poller is None or not self._poller.is_alive():
self._poller = self._thread_cls(target=self._runner)

View File

@ -76,3 +76,23 @@ def list_opts():
:returns: a list of (group_name, opts) tuples
"""
return [(g, copy.deepcopy(o)) for g, o in _opts]
def set_defaults(conf, executor_thread_pool_size=None):
"""Set defaults for configuration variables.
Overrides default options values.
:param conf: Config instance specified to set default options in it. Using
of instances instead of a global config object prevents conflicts between
options declaration.
:type conf: oslo.config.cfg.ConfigOpts instance.
:keyword executor_thread_pool_size: Size of executor thread pool.
:type executor_thread_pool_size: int
:default executor_thread_pool_size: None
"""
if executor_thread_pool_size is not None:
conf.set_default('executor_thread_pool_size',
executor_thread_pool_size)

View File

@ -15,6 +15,9 @@
import stevedore
import testtools
import mock
from oslo_messaging._executors import impl_thread
try:
from oslo_messaging import opts
except ImportError:
@ -55,3 +58,8 @@ class OptsTestCase(test_utils.BaseTestCase):
self.assertIsNotNone(result)
self._test_list_opts(result)
def test_defaults(self):
impl_thread.ThreadExecutor(self.conf, mock.Mock(), mock.Mock())
opts.set_defaults(self.conf, executor_thread_pool_size=100)
self.assertEqual(100, self.conf.executor_thread_pool_size)