void cancelHostRoleCommands(Collection<HostRoleCommand> hostRoleCommands, String reason) throws AmbariException {
    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(reason);
          agentCommandsPublisher.sendAgentCommand(hostRoleCommand.getHostId(), cancelCommand);
        }
      }

      if (hostRoleCommand.getStatus().isHoldingState()) {
        db.abortHostRole(hostRoleCommand.getHostName(),
            hostRoleCommand.getRequestId(),
            hostRoleCommand.getStageId(), hostRoleCommand.getRole().name());
      }

      // If host role is an Action, we have to send an event
      if (hostRoleCommand.getRoleCommand().equals(RoleCommand.ACTIONEXECUTE)) {
        String clusterName = hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getClusterName();
        processActionDeath(clusterName,
                hostRoleCommand.getHostName(),
                hostRoleCommand.getRole().name());
      }
    }
  }
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