public Integer getMaxTimeout(Configuration configuration) {

    Set<String> timeoutKeys = new HashSet<>();

    // !!! FIXME a TaskWrapper should have only one task.
    for (TaskWrapper wrapper : tasks) {
      timeoutKeys.addAll(wrapper.getTimeoutKeys());
    }

    Integer defaultTimeout = Integer.valueOf(configuration.getDefaultAgentTaskTimeout(false));

    if (CollectionUtils.isEmpty(timeoutKeys)) {
      return defaultTimeout;
    }

    Integer timeout = null;

    for (String key : timeoutKeys) {
      String configValue = configuration.getProperty(key);

      if (StringUtils.isNotBlank(configValue)) {
        try {
          Integer configTimeout = Integer.valueOf(configValue);

          if (null == timeout || configTimeout > timeout) {
            timeout = configTimeout;
          }

        } catch (Exception e) {
          LOG.warn("Could not parse {}/{} to a timeout value", key, configValue);
        }
      } else {
        LOG.warn("Configuration {} not found to compute timeout", key);
      }
    }

    return null == timeout ? defaultTimeout : timeout;
  }
Gets the maximum timeout for any task that this {@code StageWrapper} encapsulates.  TaskWrappers
are homogeneous across the stage, but timeouts are defined in Upgrade Packs
at the task, so each one should be checked individually.

<p>
WARNING:  This method relies on incorrect assumptions about {@link StageWrapper}s and the {@link TaskWrapper}s
that are contained in them.  Orchestration is currently forcing a StageWrapper to have only one TaskWrapper,
even though they could have many per the code.

In addition, a TaskWrapper should have a one-to-one reference with the Task it contains.  That will be
fixed in a future release.
</p>

@param configuration the configuration instance.  StageWrappers are not injectable, so pass
                     this in.
@return the maximum timeout, or the default agent execution timeout if none are found.  Never {@code null}.
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/orchestrate/StageWrapper.java