code: 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();
        }
      }
    }
docs: 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.
  
  In the future, this method may also be used in order to check that the
  current node is still the current writer, even if no edits are being
  written.