private void sendRegistration() {
    Register reg;
    if (nextRegistration != null) {
      reg = nextRegistration;
    } else {
      reg = new Register();
      reg.setTimestamp(System.currentTimeMillis());
      reg.setHostname(this.hostname);
      reg.setAgentVersion(this.agentVersion);
      reg.setPrefix(Configuration.PREFIX_DIR);
    }
    RegistrationResponse response;
    try {
      response = handler.handleRegistration(reg);
    } catch (AmbariException | InvalidStateTransitionException e) {
      LOG.info("Registration failed", e);
      return;
    }
    this.responseId = response.getResponseId();
    this.lastRegistrationResponse  = response;
    this.shouldSendRegistration = false;
    this.nextRegistration = null;
  }
The purpose of this class is to simulate the agent.
ambari-server/src/test/java/org/apache/ambari/server/agent/LocalAgentSimulator.java