in src/main/java/com/amazonaws/services/dynamodbv2/AmazonDynamoDBLockClient.java [1224:1256]
public void run() {
while (true) {
try {
if (this.shuttingDown) {
throw new InterruptedException(); // sometimes libraries wrap interrupted and other exceptions
}
final long timeWorkBegins = LockClientUtils.INSTANCE.millisecondTime();
final Map<String, LockItem> workingCopyOfLocks = new HashMap<>(this.locks);
for (final Entry<String, LockItem> lockEntry : workingCopyOfLocks.entrySet()) {
try {
this.sendHeartbeat(lockEntry.getValue());
} catch (final LockNotGrantedException x) {
logger.debug("Heartbeat failed for " + lockEntry, x);
} catch (final RuntimeException x) {
logger.warn("Exception sending heartbeat for " + lockEntry, x);
}
}
final long timeElapsed = LockClientUtils.INSTANCE.millisecondTime() - timeWorkBegins;
if (this.shuttingDown) {
throw new InterruptedException(); // sometimes libraries wrap interrupted and other exceptions
}
/* If we want to hearbeat every 9 seconds, and it took 3 seconds to send the heartbeats, we only sleep 6 seconds */
Thread.sleep(Math.max(this.heartbeatPeriodInMilliseconds - timeElapsed, 0));
} catch (final InterruptedException e) {
logger.info("Heartbeat thread recieved interrupt, exiting run() (possibly exiting thread)", e);
return;
} catch (final RuntimeException x) {
logger.warn("Exception sending heartbeat", x);
}
}
}