private void sendHeartBeat() throws AmbariException {
    HeartBeat hb;
    if (nextHeartbeat != null) {
      hb = nextHeartbeat;
    } else {
      hb = new HeartBeat();
      hb.setResponseId(responseId);
      hb.setHostname(hostname);
      hb.setTimestamp(System.currentTimeMillis());
    }
    HeartBeatResponse response = handler.handleHeartBeat(hb);
    this.responseId = response.getResponseId();
    this.lastHeartBeatResponse = response;
    this.nextHeartbeat = null;
  }
The purpose of this class is to simulate the agent.
ambari-server/src/test/java/org/apache/ambari/server/agent/LocalAgentSimulator.java