protected void processHostStatus(List<ComponentStatus> componentStatuses, List<CommandReport> reports,
                                   String hostName) throws AmbariException {

    Host host = clusterFsm.getHost(hostName);
    HostHealthStatus.HealthStatus healthStatus = host.getHealthStatus().getHealthStatus();

    if (!healthStatus.equals(HostHealthStatus.HealthStatus.UNKNOWN)) {

      //Host status info could be calculated only if agent returned statuses in heartbeat
      //Or, if a command is executed that can change component status
      boolean calculateHostStatus = false;
      Long clusterId = null;
      if (CollectionUtils.isNotEmpty(componentStatuses)) {
        calculateHostStatus = true;
        clusterId = componentStatuses.stream()
            .findFirst()
            .map(ComponentStatus::getClusterId)
            .orElse(null);
      }

      if (!calculateHostStatus && CollectionUtils.isNotEmpty(reports)) {
        for (CommandReport report : reports) {
          if (RoleCommand.ACTIONEXECUTE.toString().equals(report.getRoleCommand())) {
            continue;
          }

          String service = report.getServiceName();
          if (actionMetadata.getActions(service.toLowerCase()).contains(report.getRole())) {
            continue;
          }
          if (report.getStatus().equals("COMPLETED")) {
            calculateHostStatus = true;
            clusterId = Long.parseLong(report.getClusterId());
            break;
          }
        }
      }

      if (calculateHostStatus) {
        host.calculateHostStatus(clusterId);
      }

      //If host doesn't belong to any cluster
      if ((clusterFsm.getClustersForHost(host.getHostName())).size() == 0) {
        healthStatus = HostHealthStatus.HealthStatus.HEALTHY;
        host.setStatus(healthStatus.name());
      }
    }
  }
Update host status basing on components statuses

@param heartbeat heartbeat to process
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java