public ExecutionCommand getExecutionCommand() {
    if (executionCommand != null) {
      return executionCommand;
    }

    if( null == jsonExecutionCommand ){
      throw new RuntimeException(
          "Invalid ExecutionCommandWrapper, both object and string representations are null");
    }

    try {
      executionCommand = gson.fromJson(jsonExecutionCommand, ExecutionCommand.class);

      // sanity; if no configurations, just initialize to prevent NPEs
      if (null == executionCommand.getConfigurations()) {
        executionCommand.setConfigurations(new TreeMap<>());
      }

      Map<String, Map<String, String>> configurations = executionCommand.getConfigurations();

      // For a configuration type, both tag and an actual configuration can be stored
      // Configurations from the tag is always expanded and then over-written by the actual
      // global:version1:{a1:A1,b1:B1,d1:D1} + global:{a1:A2,c1:C1,DELETED_d1:x} ==>
      // global:{a1:A2,b1:B1,c1:C1}
      Long clusterId = hostRoleCommandDAO.findByPK(
          executionCommand.getTaskId()).getStage().getClusterId();

      Cluster cluster = clusters.getClusterById(clusterId);

      // Execution commands may have configs already set during their creation.
      // However, these configs become stale at runtime when other
      // ExecutionCommands run and change the desired configs (like ConfigureAction).
      boolean overrideConfigs = executionCommand.isOverrideConfigs();
      if (overrideConfigs) {
        Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs();

        Map<String, Map<String, String>> configurationTags = configHelper.getEffectiveDesiredTags(
            cluster, executionCommand.getHostname(), desiredConfigs);

        LOG.debug(
            "While scheduling task {} on cluster {}, configurations are being refreshed using desired configurations of {}",
            executionCommand.getTaskId(), cluster.getClusterName(), desiredConfigs);

        configurations = configHelper.getEffectiveConfigProperties(cluster, configurationTags);
        executionCommand.setConfigurations(configurations);
      }

      // provide some basic information about a cluster upgrade if there is one
      // in progress
      UpgradeEntity upgrade = cluster.getUpgradeInProgress();
      if (null != upgrade) {
        UpgradeContext upgradeContext = upgradeContextFactory.create(cluster, upgrade);
        UpgradeSummary upgradeSummary = upgradeContext.getUpgradeSummary();

        executionCommand.setUpgradeSummary(upgradeSummary);
      }

      // setting repositoryFile
      final Host host = cluster.getHost(executionCommand.getHostname());  // can be null on internal commands
      final String serviceName = executionCommand.getServiceName(); // can be null on executing special RU tasks
      CommandRepository commandRepository = executionCommand.getRepositoryFile();

      if (null == commandRepository && null != host && null != serviceName) {
          commandRepository = repoVersionHelper.getCommandRepository(cluster, cluster.getService(serviceName), host, executionCommand.getComponentName());
      }

      setVersions(cluster, commandRepository);

      executionCommand.setRepositoryFile(commandRepository);
    } catch (ClusterNotFoundException cnfe) {
      // it's possible that there are commands without clusters; in such cases,
      // just return the de-serialized command and don't try to read configs
      LOG.warn(
          "Unable to lookup the cluster by ID; assuming that there is no cluster and therefore no configs for this execution command: {}",
          cnfe.getMessage());

      return executionCommand;
    } catch (AmbariException e) {
      throw new RuntimeException(e);
    }

    return executionCommand;
  }
Gets the execution command by either de-serializing the backing JSON
command or returning the encapsulated instance which has already been
de-serialized.
<p/>
If the {@link ExecutionCommand} has configuration tags which need to be
refreshed, then this method will lookup the appropriate configuration tags
before building the final configurations to set ont he command. Therefore,
the {@link ExecutionCommand} is allowed to have no configuration tags as
long as it has been instructed to set updated ones at execution time.

@return
ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java