private void heartbeatIfNecessary ( ) throws IOException { if ( lastHeartbeatStopwatch . elapsedMillis ( ) > HEARTBEAT_INTERVAL_MILLIS || ! lastHeartbeatStopwatch . isRunning ( ) ) { try { getProxy ( ) . heartbeat ( createReqInfo ( ) ) ; } finally { // Don't send heartbeats more often than the configured interval, // even if they fail. lastHeartbeatStopwatch . reset ( ) . start ( ) ; } } }
When we ve entered an out - of - sync state it s still useful to periodically send an empty RPC to the server such that it has the up to date committedTxId . This acts as a sanity check during recovery and also allows that node s metrics to be up - to - date about its lag .