From b031cb68c43b49ac95e682c73c4edaa868f1d232 Mon Sep 17 00:00:00 2001 From: tantra35 Date: Thu, 28 Nov 2019 00:45:19 +0300 Subject: [PATCH] honor collection time between collection steps --- .../com/automattic/elasticsearch/statsd/StatsdService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/automattic/elasticsearch/statsd/StatsdService.java b/src/main/java/com/automattic/elasticsearch/statsd/StatsdService.java index bbec7d7..bbf18a2 100644 --- a/src/main/java/com/automattic/elasticsearch/statsd/StatsdService.java +++ b/src/main/java/com/automattic/elasticsearch/statsd/StatsdService.java @@ -117,6 +117,8 @@ public class StatsdReporterThread implements Runnable { public void run() { try { while (!StatsdService.this.closed.get()) { + long startTime = System.currentTimeMillis(); + ClusterState state; try { state = StatsdService.this.clusterService.state(); @@ -207,8 +209,10 @@ public void run() { } } + long elapsedTime = System.currentTimeMillis() - startTime; + try { - Thread.sleep(StatsdService.this.statsdRefreshInternal.millis()); + Thread.sleep(StatsdService.this.statsdRefreshInternal.millis() - elapsedTime); } catch (InterruptedException e1) { continue; }