sharder: Make stats interval configurable
Change-Id: Ia794a7e21794d2c1212be0e2d163004f85c2ab78
This commit is contained in:
		@@ -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
 | 
			
		||||
#
 | 
			
		||||
 
 | 
			
		||||
@@ -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):
 | 
			
		||||
 
 | 
			
		||||
@@ -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(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user