Skip to content

Commit

Permalink
reduce time spending in poll
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Khominich committed Aug 6, 2019
1 parent 8279b78 commit a66412f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,11 @@ public List<SourceRecord> poll() throws InterruptedException {
// If not in the middle of an update, wait for next update time
final long nextUpdate = querier.getLastUpdate()
+ config.getInt(JdbcSourceTaskConfig.POLL_INTERVAL_MS_CONFIG);
final long untilNext = nextUpdate - time.milliseconds();
if (untilNext > 0) {
log.trace("Waiting {} ms to poll {} next", untilNext, querier.toString());
time.sleep(untilNext);
final long now = time.milliseconds();
final long sleepMs = Math.min(nextUpdate - now, 100);
if (sleepMs > 0) {
log.trace("Waiting {} ms to poll {} next", nextUpdate - now, querier.toString());
time.sleep(sleepMs);
continue; // Re-check stop flag before continuing
}
}
Expand Down

0 comments on commit a66412f

Please sign in to comment.