code: @Override
    public int getResubmissionAttempts() {
      final String containerIdString = YarnUtilities.getContainerIdString();
      final ApplicationAttemptId appAttemptID = YarnUtilities.getAppAttemptId(containerIdString);
  
      if (containerIdString == null || appAttemptID == null) {
        LOG.log(Level.WARNING, "Was not able to fetch application attempt, container ID is [" + containerIdString +
            "] and application attempt is [" + appAttemptID + "]. Determining restart based on previous containers.");
  
        if (this.isRestartByPreviousContainers()) {
          LOG.log(Level.WARNING, "Driver is a restarted instance based on the number of previous containers. " +
              "As returned by the Resource Manager. Returning default resubmission attempts " +
              DEFAULT_RESTART_RESUBMISSION_ATTEMPTS + ".");
          return DEFAULT_RESTART_RESUBMISSION_ATTEMPTS;
        }
  
        return 0;
      }
  
      int appAttempt = appAttemptID.getAttemptId();
  
      LOG.log(Level.FINE, "Application attempt: " + appAttempt);
      assert appAttempt > 0;
      return appAttempt - 1;
    }
docs: Determines the number of times the Driver has been submitted based on the container ID environment
  variable provided by YARN. If that fails, determine whether the application master is a restart
  based on the number of previous containers reported by YARN. In the failure scenario, returns 1 if restart, 0
  otherwise.
  @return positive value if the application master is a restarted instance, 0 otherwise.