code: public boolean checkHeartbeatInfo(HeartbeatArgs jtInfo) {
      if (expectedInfo.requestId != jtInfo.requestId){
        LOG.fatal("heartbeat out-of-sync:" + sessionId + 
          " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
          " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
        return false;
      }
      if (expectedInfo.grantId == jtInfo.grantId){
        // perfect match
        if (LOG.isDebugEnabled()) {
          LOG.debug("heartbeat match:" + sessionId); 
        }
        lastSyncTime = System.currentTimeMillis();
        lastHeartbeat.requestId = 0;
        lastHeartbeat.grantId = 0;
        return true;
      }
      // delay
      if ( jtInfo.grantId != lastHeartbeat.grantId) {
        LOG.info("heartbeat mismatch with progress:" + sessionId + 
          " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
          " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
        lastSyncTime = System.currentTimeMillis();
        lastHeartbeat.requestId = jtInfo.requestId;
        lastHeartbeat.grantId = jtInfo.grantId;
        return true;
      }
      if (System.currentTimeMillis() - lastSyncTime > maxDelay) {
        // no progress
        LOG.error("heartbeat out-of-sync:" + sessionId + 
          " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
          " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
        return true;
      }
      LOG.info("heartbeat mismatch with no progress:" + sessionId + 
        " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
        " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
      return true;
    }
docs: Check if the heartbeatInfo between JT and CM are in sync.
  If this method returns false, it means JT and CM are out
  of sync very badly, and the session will be killed.