public State getProjectedState(String host, String component) {
    RoleCommand lastCommand = null;

    ListIterator<Stage> iterator = stages.listIterator(stages.size());
    while (lastCommand == null && iterator.hasPrevious()) {
      Stage stage = iterator.previous();

      Map<String, Map<String, HostRoleCommand>> stageCommands = stage.getHostRoleCommands();
      if (stageCommands != null) {
        Map<String, HostRoleCommand> hostCommands = stageCommands.get(host);
        if (hostCommands != null) {
          HostRoleCommand roleCommand = hostCommands.get(component);
          if (roleCommand != null && roleCommand.getRoleCommand() != RoleCommand.SERVICE_CHECK) {
            lastCommand = roleCommand.getRoleCommand();
          }
        }
      }
    }

    State resultingState = null;
    if (lastCommand != null) {
      switch(lastCommand) {
        case INSTALL:
        case STOP:
          resultingState = State.INSTALLED;
          break;
        case START:
          resultingState = State.STARTED;
          break;
        case UNINSTALL:
          resultingState = State.INIT;
          break;
        default:
          resultingState = State.UNKNOWN;
      }
    }
    return resultingState;
  }
Determine the projected state for a host component from the existing stages.

@param host       host name
@param component  component name

@return the projected state of a host component after all stages successfully complete
        or null if the host component state is not modified in the current stages
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestStageContainer.java