Search in sources :

Example 6 with TimingEvent

use of org.apache.gobblin.metrics.event.TimingEvent in project incubator-gobblin by apache.

the class LocalJobLauncher method runWorkUnitStream.

@Override
protected void runWorkUnitStream(WorkUnitStream workUnitStream) throws Exception {
    String jobId = this.jobContext.getJobId();
    final JobState jobState = this.jobContext.getJobState();
    Iterator<WorkUnit> workUnitIterator = workUnitStream.getWorkUnits();
    if (!workUnitIterator.hasNext()) {
        LOG.warn("No work units to run");
        return;
    }
    TimingEvent workUnitsRunTimer = this.eventSubmitter.getTimingEvent(TimingEvent.RunJobTimings.WORK_UNITS_RUN);
    Iterator<WorkUnit> flattenedWorkUnits = new MultiWorkUnitUnpackingIterator(workUnitStream.getWorkUnits());
    Iterator<WorkUnit> workUnitsWithJobState = Iterators.transform(flattenedWorkUnits, new Function<WorkUnit, WorkUnit>() {

        @Override
        public WorkUnit apply(WorkUnit workUnit) {
            workUnit.addAllIfNotExist(jobState);
            return workUnit;
        }
    });
    GobblinMultiTaskAttempt.runWorkUnits(this.jobContext, workUnitsWithJobState, this.taskStateTracker, this.taskExecutor, GobblinMultiTaskAttempt.CommitPolicy.IMMEDIATE);
    if (this.cancellationRequested) {
        // Wait for the cancellation execution if it has been requested
        synchronized (this.cancellationExecution) {
            if (this.cancellationExecuted) {
                return;
            }
        }
    }
    workUnitsRunTimer.stop();
    LOG.info(String.format("All tasks of job %s have completed", jobId));
    if (jobState.getState() == JobState.RunningState.RUNNING) {
        jobState.setState(JobState.RunningState.SUCCESSFUL);
    }
}
Also used : MultiWorkUnitUnpackingIterator(org.apache.gobblin.runtime.util.MultiWorkUnitUnpackingIterator) JobState(org.apache.gobblin.runtime.JobState) WorkUnit(org.apache.gobblin.source.workunit.WorkUnit) TimingEvent(org.apache.gobblin.metrics.event.TimingEvent)

Aggregations

TimingEvent (org.apache.gobblin.metrics.event.TimingEvent)6 JobState (org.apache.gobblin.runtime.JobState)2 WorkUnit (org.apache.gobblin.source.workunit.WorkUnit)2 Closer (com.google.common.io.Closer)1 IOException (java.io.IOException)1 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)1 CloseableJobListener (org.apache.gobblin.runtime.listeners.CloseableJobListener)1 JobListener (org.apache.gobblin.runtime.listeners.JobListener)1 JobLockException (org.apache.gobblin.runtime.locks.JobLockException)1 MultiWorkUnitUnpackingIterator (org.apache.gobblin.runtime.util.MultiWorkUnitUnpackingIterator)1 WorkUnitStreamSource (org.apache.gobblin.source.WorkUnitStreamSource)1 BasicWorkUnitStream (org.apache.gobblin.source.workunit.BasicWorkUnitStream)1 MultiWorkUnit (org.apache.gobblin.source.workunit.MultiWorkUnit)1 WorkUnitStream (org.apache.gobblin.source.workunit.WorkUnitStream)1 Path (org.apache.hadoop.fs.Path)1