Limit publisher updated event to 1 in 3 minutes

Change-Id: Id71f01fe36d84d0f8bb80bf099a2211054995827
This commit is contained in:
Omer Anson 2016-04-14 14:47:47 +03:00
parent 9c85585550
commit 8324f97483
4 changed files with 25 additions and 1 deletions

View File

@ -104,6 +104,8 @@ function configure_df_plugin {
iniset $NEUTRON_CONF df enable_df_pub_sub "$DF_PUB_SUB"
iniset $NEUTRON_CONF df pub_sub_use_multiproc "$DF_PUB_SUB_USE_MULTIPROC"
iniset $NEUTRON_CONF df publishers_ips "$PUBLISHERS_HOSTS"
iniset $NEUTRON_CONF df publisher_rate_limit_timeout "$PUBLISHER_RATE_LIMIT_TIMEOUT"
iniset $NEUTRON_CONF df publisher_rate_limit_count "$PUBLISHER_RATE_LIMIT_COUNT"
iniset $NEUTRON_CONF df_dnat_app external_network_bridge "br-ex"
iniset $NEUTRON_CONF df_dnat_app int_peer_patch_port "patch-ex"
iniset $NEUTRON_CONF df_dnat_app ex_peer_patch_port "patch-int"

View File

@ -19,3 +19,6 @@ export PYTHONPATH=$PYTHONPATH:$DRAGONFLOW_DIR
DF_MONITOR_TABLE_POLL_TIME=${DF_MONITOR_TABLE_POLL_TIME:-30}
DF_PUB_SUB=${DF_PUB_SUB:-"False"}
DF_PUB_SUB_USE_MULTIPROC=${DF_PUB_SUB_USE_MULTIPROC:-"True"}
PUBLISHER_RATE_LIMIT_TIMEOUT=${PUBLISHER_RATE_LIMIT_TIMEOUT:-180}
PUBLISHER_RATE_LIMIT_COUNT=${PUBLISHER_RATE_LIMIT_COUNT:-1}

View File

@ -80,6 +80,22 @@ df_opts = [
default=300,
help=_('Publisher idle timeout before it is removed from the table')
),
cfg.IntOpt(
'publisher_rate_limit_timeout',
default=180,
help=_(
'Limit update of publishers\' table timestamp to '
'$publisher_rate_limit_count per this many seconds.'
)
),
cfg.IntOpt(
'publisher_rate_limit_count',
default=1,
help=_(
'Limit update of publishers\' table timestamp to '
'this many times per $publisher_rate_limit_timeout seconds.'
)
),
cfg.FloatOpt('monitor_table_poll_time',
default=30,
help=_('Poll monitored tables every this number of seconds')),

View File

@ -44,7 +44,10 @@ class PublisherService(object):
nb_driver_class = importutils.import_class(cfg.CONF.df.nb_db_class)
self.db = nb_driver_class()
self.uuid = pub_sub_api.generate_publisher_uuid()
self._rate_limit = df_utils.RateLimiter(2, 30)
self._rate_limit = df_utils.RateLimiter(
cfg.CONF.df.publisher_rate_limit_count,
cfg.CONF.df.publisher_rate_limit_timeout,
)
def _get_publisher(self):
pub_sub_driver = df_utils.load_driver(