Finalize a given {@link JobState.DatasetState} before committing the dataset.

This method is thread-safe.
974887
private void finalizeDatasetStateBeforeCommit(JobState.DatasetState datasetState) {
    for (TaskState taskState : datasetState.getTaskStates()) {
      if (taskState.getWorkingState() != WorkUnitState.WorkingState.SUCCESSFUL
          && this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_FULL_SUCCESS) {
        // The dataset state is set to FAILED if any task failed and COMMIT_ON_FULL_SUCCESS is used
        datasetState.setState(JobState.RunningState.FAILED);
        datasetState.incrementJobFailures();
        return;
      }
    }

    datasetState.setState(JobState.RunningState.SUCCESSFUL);
    datasetState.setNoJobFailure();
  }
840072
def finalize(self):
        
        self.model().sigItemChanged.disconnect(self.repoTreeItemChanged)

        selectionModel = self.selectionModel() # need to store reference to prevent crash in PySide
        selectionModel.currentChanged.disconnect(self.currentItemChanged)
491461
private void setJobCleanupTaskState(Task task) {
    if (task.isJobCleanupTask()) {
      if (jobFailed) {
        task.setJobCleanupTaskState(
            org.apache.hadoop.mapreduce.JobStatus.State.FAILED);
      } else if (jobKilled) {
        task.setJobCleanupTaskState(
            org.apache.hadoop.mapreduce.JobStatus.State.KILLED);
      } else {
        task.setJobCleanupTaskState(
            org.apache.hadoop.mapreduce.JobStatus.State.SUCCEEDED);
      }
    }
  }
481621
def toggleDataset(self, state, dataset=None):
        
        if dataset is None and self.sender():
            dataset = unwrapVariant(self.sender().data())
        
        dataset.setVisible(state)
        self._dataChanged = True
        self.recalculate()
1014648
private void internalUpdateJobStateAndResult(final JobInstance job) {
        transactionTemplate.execute(new TransactionCallbackWithoutResult() {
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                jobInstanceDao.updateStateAndResult(job);
                if (job.isCompleted()) {
                    buildPropertiesService.saveCruiseProperties(job);
                }
            }
        });
    }
241859
def finalize(self):
        
        # todo sort self.result by path_num
        if self.result:
            self.result = sorted(self.result, key=lambda x: x[0])
            p, r = map(list, zip(*self.result))
            self.result = r
1058486
private boolean shouldVerifyCompletenessForDataset(Dataset dataset, List<Pattern> blacklist,
    List<Pattern> whitelist) {
    boolean renamingRequired = this.state.getPropAsBoolean(COMPACTION_RENAME_SOURCE_DIR_ENABLED, DEFAULT_COMPACTION_RENAME_SOURCE_DIR_ENABLED);

    LOG.info ("Should verify completeness with renaming source dir : " + renamingRequired);

    return !datasetAlreadyCompacted(this.fs, dataset, renamingRequired)
        && DatasetFilterUtils.survived(dataset.getName(), blacklist, whitelist);
  }
464604
static void exit(int status) {
        boolean runMoreFinalizers = false;
        synchronized (lock) {
            if (status != 0) runFinalizersOnExit = false;
            switch (state) {
            case RUNNING:       /* Initiate shutdown */
                state = HOOKS;
                break;
            case HOOKS:         /* Stall and halt */
                break;
            case FINALIZERS:
                if (status != 0) {
                    /* Halt immediately on nonzero status */
                    halt(status);
                } else {
                    /* Compatibility with old behavior:
                     * Run more finalizers and then halt
                     */
                    runMoreFinalizers = runFinalizersOnExit;
                }
                break;
            }
        }
        if (runMoreFinalizers) {
            runAllFinalizers();
            halt(status);
        }
        synchronized (Shutdown.class) {
            /* Synchronize on the class object, causing any other thread
             * that attempts to initiate shutdown to stall indefinitely
             */
            sequence();
            halt(status);
        }
    }
233810
private List<Dataset> createJobPropsForDataset(Dataset dataset) {
    LOG.info("Creating compaction jobs for dataset " + dataset + " with priority " + dataset.priority());
    final MRCompactorJobPropCreator jobPropCreator = getJobPropCreator(dataset);
    List<Dataset> datasetsWithProps;
    try {
      datasetsWithProps = jobPropCreator.createJobProps();
    } catch (Throwable t) {
      // If a throwable is caught when creating job properties for a dataset, skip the topic and add the throwable
      // to the dataset.
      datasetsWithProps = ImmutableList.<Dataset> of(jobPropCreator.createFailedJobProps(t));
    }
    return datasetsWithProps;
  }
953497
protected void internalClose() throws SQLException {
		try {
			clearStatementCaches(true);
			if (this.connection != null){ // safety!
				this.connection.close();

				if (!this.connectionTrackingDisabled && this.finalizableRefs != null){
					this.finalizableRefs.remove(this.connection);
				}
			}
			this.logicallyClosed.set(true);
		} catch (SQLException e) {
			throw markPossiblyBroken(e);
		}
	}
367589
private void commitDataset(Collection<TaskState> taskStates, DataPublisher publisher) {

    try {
      publisher.publish(taskStates);
    } catch (Throwable t) {
      log.error("Failed to commit dataset", t);
      setTaskFailureException(taskStates, t);
    }
  }
345939
public void finishDefinition(){
		sequencer = null;
		states = ImmutableBiMap.copyOf(states);
		Map<S, Set<T>> validTransitionsCopied = new HashMap<S, Set<T>>();
		for (Map.Entry<S, Set<T>> entry: validTransitions.entrySet()){
			validTransitionsCopied.put(entry.getKey(), ImmutableSet.copyOf(entry.getValue()));
		}
		validTransitions = ImmutableMap.copyOf(validTransitions);
	}
658342
private void deleteStateStore(URI jobSpecUri) throws IOException {
    int EXPECTED_NUM_URI_TOKENS = 3;
    String[] uriTokens = jobSpecUri.getPath().split("/");

    if (null == this.datasetStateStore) {
      log.warn("Job state store deletion failed as datasetstore is not initialized.");
      return;
    }
    if (uriTokens.length != EXPECTED_NUM_URI_TOKENS) {
      log.error("Invalid URI {}.", jobSpecUri);
      return;
    }

    String jobName = uriTokens[EXPECTED_NUM_URI_TOKENS - 1];
    this.datasetStateStore.delete(jobName);
    log.info("JobSpec {} deleted with statestore.", jobSpecUri);
  }
654702
public void connecDataSet(IntermediateDataSet dataSet) {
		if (dataSet == null) {
			throw new NullPointerException();
		}
		if (this.source != null) {
			throw new IllegalStateException("The edge is already connected.");
		}
		if (!dataSet.getId().equals(sourceId)) {
			throw new IllegalArgumentException("The data set to connect does not match the sourceId.");
		}
		
		this.source = dataSet;
	}
116267
@Deprecated
  public static void populateState(Dataset dataset, Optional<Job> job, FileSystem fs) {
    dataset.jobProps().setProp(SlaEventKeys.DATASET_URN_KEY, dataset.getUrn());
    dataset.jobProps().setProp(SlaEventKeys.PARTITION_KEY,
        dataset.jobProps().getProp(MRCompactor.COMPACTION_JOB_DEST_PARTITION, ""));
    dataset.jobProps().setProp(SlaEventKeys.DEDUPE_STATUS_KEY, getOutputDedupeStatus(dataset.jobProps()));
    dataset.jobProps().setProp(SlaEventKeys.PREVIOUS_PUBLISH_TS_IN_MILLI_SECS_KEY, getPreviousPublishTime(dataset, fs));
    dataset.jobProps().setProp(SlaEventKeys.RECORD_COUNT_KEY, getRecordCount(job));
  }
764875
protected Optional<Dataset> createJobProps(Dataset dataset) throws IOException {
    if (this.recompactFromOutputPaths && (!latePathsFound(dataset))) {
      LOG.info(String.format("Skipping recompaction for %s since there is no late data in %s",
          new Object[] { dataset.inputPaths(), dataset.inputLatePaths() }));
      return Optional.absent();
    }

    State jobProps = new State();
    jobProps.addAll(this.state);
    jobProps.setProp(MRCompactor.COMPACTION_ENABLE_SUCCESS_FILE, false);
    jobProps.setProp(MRCompactor.COMPACTION_INPUT_DEDUPLICATED, this.inputDeduplicated);
    jobProps.setProp(MRCompactor.COMPACTION_OUTPUT_DEDUPLICATED, this.outputDeduplicated);
    jobProps.setProp(MRCompactor.COMPACTION_SHOULD_DEDUPLICATE, !this.inputDeduplicated && this.outputDeduplicated);

    if (this.recompactFromOutputPaths || !MRCompactor.datasetAlreadyCompacted(this.fs, dataset, renameSourceDirEnabled)) {
      if (renameSourceDirEnabled) {
        Set<Path> newUnrenamedDirs = MRCompactor.getDeepestLevelUnrenamedDirsWithFileExistence(this.fs, dataset.inputPaths());
        if (getAllFilePathsRecursively(newUnrenamedDirs).isEmpty()) {
          return Optional.absent();
        }
        LOG.info ("[{}] has unprocessed directories for first time compaction: {}", dataset.getDatasetName(), newUnrenamedDirs);
        dataset.overwriteInputPaths(newUnrenamedDirs);
        dataset.setRenamePaths(newUnrenamedDirs);
      } else {
        addInputLateFilesForFirstTimeCompaction(jobProps, dataset);
      }

      LOG.info(String.format("Created MR job properties for input %s and output %s.", dataset.inputPaths(),
              dataset.outputPath()));
      dataset.setJobProps(jobProps);
      return Optional.of(dataset);
    } else {
      return obtainDatasetWithJobProps (jobProps, dataset);
    }
  }
323232
public static void assertState(String message, DataSet dataSet) throws DBAssertionError {
    DBAssert.stateAssertion(CallInfo.create(message), dataSet);
  }