in src/main/java/org/apache/sling/discovery/base/connectors/announcement/CachedAnnouncement.java [97:121]
final long registerPing(Announcement incomingAnnouncement, BaseConfig config) {
lastPing = System.currentTimeMillis();
announcement.registerPing(incomingAnnouncement);
if (incomingAnnouncement.isInherited()) {
// then we are the client, we inherited this announcement from the server
// hence we have no power to do any backoff instructions towards the server
// (since the server decides about backoff-ing). hence returning 0 here
// but taking note of what the server instructed us in terms of backoff
backoffIntervalSeconds = incomingAnnouncement.getBackoffInterval();
logger.debug("registerPing: inherited announcement - hence returning 0");
return 0;
}
if (incomingAnnouncement.getResetBackoff()) {
// on resetBackoff we reset the firstHeartbeat and start
// from 0 again
firstPing = lastPing;
logger.debug("registerPing: got a resetBackoff - hence returning 0");
return 0;
}
final long stableSince = lastPing - firstPing;
final long numStableTimeouts = stableSince / (1000 * config.getConnectorPingTimeout());
final long backoffFactor = Math.min(numStableTimeouts, config.getBackoffStableFactor());
backoffIntervalSeconds = backoffFactor * config.getConnectorPingInterval();
return backoffIntervalSeconds;
}