public Collection<HostRoleCommand> getLogicalTasks() {
    // sync logical task state with physical tasks
    for (HostRoleCommand logicalTask : logicalTasks.values()) {
      // set host on command detail if it is set to null
      String commandDetail = logicalTask.getCommandDetail();
      if (commandDetail != null && commandDetail.contains("null") && hostname != null) {
        logicalTask.setCommandDetail(commandDetail.replace("null", hostname));
      }
      Long physicalTaskId = physicalTasks.get(logicalTask.getTaskId());
      if (physicalTaskId != null) {
        HostRoleCommand physicalTask = topology.getAmbariContext().getPhysicalTask(physicalTaskId);
        if (physicalTask != null) {
          logicalTask.setStatus(physicalTask.getStatus());
          logicalTask.setCommandDetail(physicalTask.getCommandDetail());
          logicalTask.setCustomCommandName(physicalTask.getCustomCommandName());
          //todo: once we retry on failures, start/end times could span multiple physical tasks
          logicalTask.setStartTime(physicalTask.getStartTime());
          logicalTask.setOriginalStartTime(physicalTask.getOriginalStartTime());
          logicalTask.setEndTime(physicalTask.getEndTime());
          logicalTask.setErrorLog(physicalTask.getErrorLog());
          logicalTask.setExitCode(physicalTask.getExitCode());
          logicalTask.setExecutionCommandWrapper(physicalTask.getExecutionCommandWrapper());
          //todo: may be handled at a higher level than physical task
          logicalTask.setLastAttemptTime(physicalTask.getLastAttemptTime());
          logicalTask.setOutputLog(physicalTask.getOutputLog());
          logicalTask.setStderr(physicalTask.getStderr());
          logicalTask.setStdout(physicalTask.getStdout());
          logicalTask.setStructuredOut(physicalTask.getStructuredOut());
        }
      }
      if (logicalTask.getStatus() == HostRoleStatus.PENDING && status != HostRoleStatus.PENDING) {
        logicalTask.setStatus(status);
      }
    }
    return logicalTasks.values();
  }
Only to be used when replaying persisted requests upon server startup.

@param requestId    logical request id
@param id           host request id
@param predicate    host predicate
@param topology     cluster topology
@param entity       host request entity
ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java