Search in sources :

Example 1 with StateStore

use of org.apache.gobblin.metastore.StateStore in project incubator-gobblin by apache.

the class GobblinHelixJobLauncher method persistWorkUnit.

/**
 * Persist a single {@link WorkUnit} (flattened) to a file.
 */
private String persistWorkUnit(final Path workUnitFileDir, final WorkUnit workUnit, ParallelRunner stateSerDeRunner) throws IOException {
    final StateStore stateStore;
    String workUnitFileName = workUnit.getId();
    if (workUnit instanceof MultiWorkUnit) {
        workUnitFileName += MULTI_WORK_UNIT_FILE_EXTENSION;
        stateStore = stateStores.getMwuStateStore();
    } else {
        workUnitFileName += WORK_UNIT_FILE_EXTENSION;
        stateStore = stateStores.getWuStateStore();
    }
    Path workUnitFile = new Path(workUnitFileDir, workUnitFileName);
    final String fileName = workUnitFile.getName();
    final String storeName = workUnitFile.getParent().getName();
    stateSerDeRunner.submitCallable(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            stateStore.put(storeName, fileName, workUnit);
            return null;
        }
    }, "Serialize state to store " + storeName + " file " + fileName);
    return workUnitFile.toString();
}
Also used : Path(org.apache.hadoop.fs.Path) MultiWorkUnit(org.apache.gobblin.source.workunit.MultiWorkUnit) StateStore(org.apache.gobblin.metastore.StateStore) JobException(org.apache.gobblin.runtime.JobException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 StateStore (org.apache.gobblin.metastore.StateStore)1 JobException (org.apache.gobblin.runtime.JobException)1 MultiWorkUnit (org.apache.gobblin.source.workunit.MultiWorkUnit)1 Path (org.apache.hadoop.fs.Path)1