sharder: Make stats interval configurable

Change-Id: Ia794a7e21794d2c1212be0e2d163004f85c2ab78
This commit is contained in:
Tim Burke 2021-10-01 14:35:09 -07:00
parent fcf434a298
commit 5b9a90b65d
3 changed files with 11 additions and 4 deletions

View File

@ -491,6 +491,9 @@ use = egg:swift#xprofile
# us less likely to bomb out on a LockTimeout.
# broker_timeout = 60
#
# Time in seconds to wait between emitting stats to logs
# stats_interval = 3600.0
#
# Time in seconds to wait between sharder cycles
# interval = 30.0
#

View File

@ -724,6 +724,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
raise SystemExit(
'Unable to load internal client from config: %r (%s)' %
(internal_client_conf_path, err))
self.stats_interval = float(conf.get('stats_interval', '3600'))
self.reported = 0
def _zero_stats(self):
@ -880,7 +881,7 @@ class ContainerSharder(ContainerSharderConf, ContainerReplicator):
self.reported = now
def _periodic_report_stats(self):
if (time.time() - self.reported) >= 3600: # once an hour
if (time.time() - self.reported) >= self.stats_interval:
self._report_stats()
def _check_node(self, node):

View File

@ -178,7 +178,8 @@ class TestSharder(BaseTestSharder):
'shard_replication_quorum': 2,
'existing_shard_replication_quorum': 2,
'max_shrinking': 1,
'max_expanding': -1
'max_expanding': -1,
'stats_interval': 3600,
}
sharder, mock_ic = self._do_test_init({}, expected, use_logger=False)
self.assertEqual(
@ -228,7 +229,8 @@ class TestSharder(BaseTestSharder):
'existing_shard_replication_quorum': 0,
'max_shrinking': 5,
'max_expanding': 4,
'rows_per_shard': 13000000
'rows_per_shard': 13000000,
'stats_interval': 300,
}
expected = {
'mount_check': False, 'bind_ip': '10.11.12.13', 'port': 62010,
@ -253,7 +255,8 @@ class TestSharder(BaseTestSharder):
'shard_replication_quorum': 1,
'existing_shard_replication_quorum': 0,
'max_shrinking': 5,
'max_expanding': 4
'max_expanding': 4,
'stats_interval': 300,
}
sharder, mock_ic = self._do_test_init(conf, expected)
mock_ic.assert_called_once_with(