public void processStatusReports(List<ComponentStatus> componentStatuses, String hostname) throws AmbariException {
    Set<Cluster> clusters = clusterFsm.getClustersForHost(hostname);
    for (Cluster cl : clusters) {
      for (ComponentStatus status : componentStatuses) {
        if (status.getClusterId().equals(cl.getClusterId())) {
          try {
            Service svc = cl.getService(status.getServiceName());

            String componentName = status.getComponentName();
            if (svc.getServiceComponents().containsKey(componentName)) {
              ServiceComponent svcComp = svc.getServiceComponent(
                  componentName);
              ServiceComponentHost scHost = svcComp.getServiceComponentHost(
                  hostname);
              if (status.getStatus() != null) {
                org.apache.ambari.server.state.State prevState = scHost.getState();
                org.apache.ambari.server.state.State liveState =
                    org.apache.ambari.server.state.State.valueOf(org.apache.ambari.server.state.State.class,
                        status.getStatus());
                //ignore reports from status commands if component is in INIT or any "in progress" state
                if (prevState.equals(org.apache.ambari.server.state.State.INSTALLED)
                    || prevState.equals(org.apache.ambari.server.state.State.STARTED)
                    || prevState.equals(org.apache.ambari.server.state.State.UNKNOWN)) {
                  scHost.setState(liveState);
                  if (!prevState.equals(liveState)) {
                    LOG.info("State of service component " + componentName
                        + " of service " + status.getServiceName()
                        + " of cluster " + status.getClusterId()
                        + " has changed from " + prevState + " to " + liveState
                        + " at host " + hostname
                        + " according to STATUS_COMMAND report");
                  }
                }
              }

              Map<String, Object> extra = status.getExtra();
              if (null != extra && !extra.isEmpty()) {
                try {
                  if (extra.containsKey("processes")) {
                    @SuppressWarnings("unchecked")
                    List<Map<String, String>> list = (List<Map<String, String>>) extra.get("processes");
                    scHost.setProcesses(list);
                  }
                } catch (Exception e) {
                  LOG.error("Could not access extra JSON for " +
                      scHost.getServiceComponentName() + " from " +
                      scHost.getHostName() + ": " + status.getExtra() +
                      " (" + e.getMessage() + ")");
                }
              }

              heartbeatMonitor.getAgentRequests()
                  .setExecutionDetailsRequest(hostname, componentName, status.getSendExecCmdDet());
            } else {
              // TODO: What should be done otherwise?
            }
          } catch (ServiceNotFoundException e) {
            LOG.warn("Received a live status update for a non-initialized"
                + " service"
                + ", clusterId=" + status.getClusterId()
                + ", serviceName=" + status.getServiceName());
            // FIXME ignore invalid live update and continue for now?
            continue;
          } catch (ServiceComponentNotFoundException e) {
            LOG.warn("Received a live status update for a non-initialized"
                + " servicecomponent"
                + ", clusterId=" + status.getClusterId()
                + ", serviceName=" + status.getServiceName()
                + ", componentName=" + status.getComponentName());
            // FIXME ignore invalid live update and continue for now?
            continue;
          } catch (ServiceComponentHostNotFoundException e) {
            LOG.warn("Received a live status update for a non-initialized"
                + " service"
                + ", clusterId=" + status.getClusterId()
                + ", serviceName=" + status.getServiceName()
                + ", componentName=" + status.getComponentName()
                + ", hostname=" + hostname);
            // FIXME ignore invalid live update and continue for now?
            continue;
          } catch (RuntimeException e) {
            LOG.warn("Received a live status with invalid payload"
                + " service"
                + ", clusterId=" + status.getClusterId()
                + ", serviceName=" + status.getServiceName()
                + ", componentName=" + status.getComponentName()
                + ", hostname=" + hostname
                + ", error=" + e.getMessage());
            continue;
          }
        }
      }
    }

    Host host = clusterFsm.getHost(hostname);
    long now = System.currentTimeMillis();
    // If the host is waiting for component status updates, notify it
    if (componentStatuses.size() > 0
        && host.getState().equals(HostState.WAITING_FOR_HOST_STATUS_UPDATES)) {
      try {
        LOG.debug("Got component status updates for host {}", hostname);
        host.handleEvent(new HostStatusUpdatesReceivedEvent(hostname, now));
      } catch (InvalidStateTransitionException e) {
        LOG.warn("Failed to notify the host about component status updates for host {}", hostname, e);
      }
    }
  }
Process reports of status commands
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java