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);
}
}
Aggregations