private CommandReport execute(HostRoleCommand hostRoleCommand, ExecutionCommand executionCommand)
        throws AmbariException, InterruptedException {

      if (hostRoleCommand == null) {
        throw new AmbariException("Missing HostRoleCommand data");
      } else if (executionCommand == null) {
        throw new AmbariException("Missing ExecutionCommand data");
      } else {
        Map<String, String> roleParams = executionCommand.getRoleParams();
        if (roleParams == null) {
          throw new AmbariException("Missing RoleParams data");
        } else {
          String actionClassname = roleParams.get(ServerAction.ACTION_NAME);

          if (actionClassname == null) {
            throw new AmbariException("Missing action classname for server action");
          } else {
            Map<String, ServiceInfo> services = new HashMap<String, ServiceInfo>();
            UpgradeSummary upgradeSummary = executionCommand.getUpgradeSummary();
            if (upgradeSummary != null) {
              Map<String, UpgradeServiceSummary> upgradeServiceSummaries = upgradeSummary.services;
              LOG.debug("UpgradeServiceSummary: " + upgradeServiceSummaries);
              AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
              AmbariMetaInfo ambariMetaInfo = ambariManagementController.getAmbariMetaInfo();
              String serviceName = executionCommand.getServiceName();
              if (serviceName != null && !serviceName.isEmpty()){
                LOG.info(String.format("Server action %s is associated with service %s", actionClassname, serviceName));
                //Execution stage of a given service, only need to examine stack information for this one service
                UpgradeServiceSummary serviceSummary = upgradeServiceSummaries.get(serviceName);
                addServiceInfo(services, ambariMetaInfo, serviceSummary.sourceStackId, serviceName);
              } else {
                LOG.info(String.format("Server action %s is not associated with a service", actionClassname));
                //Load all Jars
                for(String key: upgradeServiceSummaries.keySet()){
                  UpgradeServiceSummary serviceSummary = upgradeServiceSummaries.get(key);
                  addServiceInfo(services, ambariMetaInfo, serviceSummary.sourceStackId, key);
                }
              }
              LOG.info(String.format("Attempt to load server action classes from %s", services.keySet().toString()));
            }
            ServerAction action = createServerAction(actionClassname, services);
            if (action == null) {
              throw new AmbariException("Failed to create server action: " + actionClassname);
            } else {
              // Set properties on the action:
              action.setExecutionCommand(executionCommand);
              action.setHostRoleCommand(hostRoleCommand);

              return action.execute(getRequestSharedDataContext(hostRoleCommand.getRequestId()));
            }
          }
        }
      }
    }
Attempts to execute the task specified using data from the supplied HostRoleCommand and
ExecutionCommand.
<p/>
Retrieves the role parameters from the supplied ExecutionCommand and queries it for the
"ACTON_NAME" property.  The returned String is expected to be the classname of a ServerAction
implementation.  If so, an instance of the implementation class is created and executed
yielding a CommandReport to (eventually) return back to the parent thread.

@param hostRoleCommand  The HostRoleCommand the HostRoleCommand for the relevant task
@param executionCommand the ExecutionCommand for the relevant task
@return the resulting CommandReport
@throws AmbariException
@throws InterruptedException
ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java