code: private boolean canCommitDataset(JobState.DatasetState datasetState) {
      // Only commit a dataset if 1) COMMIT_ON_PARTIAL_SUCCESS is used, or 2)
      // COMMIT_ON_FULL_SUCCESS is used and all of the tasks of the dataset have succeeded.
      return this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_PARTIAL_SUCCESS
          || this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_SUCCESSFUL_TASKS || (
          this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_FULL_SUCCESS
              && datasetState.getState() == JobState.RunningState.SUCCESSFUL);
    }
docs: Check if it is OK to commit the output data of a dataset.
  
  <p>
  A dataset can be committed if and only if any of the following conditions is satisfied:
  
  <ul>
  <li>The {@link JobCommitPolicy#COMMIT_ON_PARTIAL_SUCCESS} policy is used.</li>
  <li>The {@link JobCommitPolicy#COMMIT_SUCCESSFUL_TASKS} policy is used.</li>
  <li>The {@link JobCommitPolicy#COMMIT_ON_FULL_SUCCESS} policy is used and all of the tasks succeed.</li>
  </ul>
  </p>
  This method is thread-safe.