void cancelCommandOnTimeout(Collection<HostRoleCommand> hostRoleCommands, Multimap<Long, AgentCommand> commandsToEnqueue) {
    for (HostRoleCommand hostRoleCommand : hostRoleCommands) {
      // There are no server actions in actionQueue
      if (!Role.AMBARI_SERVER_ACTION.equals(hostRoleCommand.getRole())) {
        if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED ||
              hostRoleCommand.getStatus() == HostRoleStatus.IN_PROGRESS) {
          CancelCommand cancelCommand = new CancelCommand();
          cancelCommand.setTargetTaskId(hostRoleCommand.getTaskId());
          cancelCommand.setReason("Stage timeout");
          commandsToEnqueue.put(hostRoleCommand.getHostId(), cancelCommand);
        }
      }
    }
  }
Cancels host role commands (those that are not finished yet).
Dequeues host role commands that have been added to ActionQueue,
and automatically generates and adds to ActionQueue CANCEL_COMMANDs
for all hostRoleCommands that have already been sent to an agent for
execution.
@param hostRoleCommands a list of hostRoleCommands
@param reason why the request is being cancelled
ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java