code: public YarnSubmissionHelper setPreserveEvaluators(final boolean preserveEvaluators) {
      if (preserveEvaluators) {
        // when supported, set KeepContainersAcrossApplicationAttempts to be true
        // so that when driver (AM) crashes, evaluators will still be running and we can recover later.
        if (YarnTypes.isAtOrAfterVersion(YarnTypes.MIN_VERSION_KEEP_CONTAINERS_AVAILABLE)) {
          LOG.log(
              Level.FINE,
              "Hadoop version is {0} or after with KeepContainersAcrossApplicationAttempts supported," +
                  " will set it to true.",
              YarnTypes.MIN_VERSION_KEEP_CONTAINERS_AVAILABLE);
  
          applicationSubmissionContext.setKeepContainersAcrossApplicationAttempts(true);
        } else {
          LOG.log(Level.WARNING,
              "Hadoop version does not yet support KeepContainersAcrossApplicationAttempts. Driver restarts " +
                  "will not support recovering evaluators.");
  
          applicationSubmissionContext.setKeepContainersAcrossApplicationAttempts(false);
        }
      } else {
        applicationSubmissionContext.setKeepContainersAcrossApplicationAttempts(false);
      }
  
      return this;
    }
docs: Set whether or not the resource manager should preserve evaluators across driver restarts.
  @param preserveEvaluators
  @return