Skip to content

Commit

Permalink
Merge pull request #365 from DataDog/vickenty/sleep-more
Browse files Browse the repository at this point in the history
Sleep after over-long iteration
  • Loading branch information
vickenty authored Jul 7, 2021
2 parents e29eeef + a5e7d16 commit 4cba711
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/datadog/jmxfetch/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,15 @@ void start() {
try {
long loopPeriod = appConfig.getCheckPeriod();
long sleepPeriod = loopPeriod - duration;
if (sleepPeriod <= 0) {
if (sleepPeriod < loopPeriod / 2) {
log.debug(
"The collection cycle took longer that the configured check period,"
+ " the next cycle will start immediatly");
+ " the next cycle will be delayed");
sleepPeriod = loopPeriod / 2;
} else {
log.debug("Sleeping for " + sleepPeriod + " ms.");
Thread.sleep(sleepPeriod);
}
Thread.sleep(sleepPeriod);
} catch (InterruptedException e) {
log.warn(e.getMessage(), e);
}
Expand Down

0 comments on commit 4cba711

Please sign in to comment.