use of org.apache.gobblin.runtime.std.JobExecutionStateListeners in project incubator-gobblin by apache.
the class JobLauncherExecutionDriver method create.
/**
* Creates a new JobExecutionDriver which acts as an adapter to the legacy {@link JobLauncher} API.
* @param sysConfig the system/environment config
* @param jobSpec the JobSpec to be executed
* @param jobLauncherType an optional jobLauncher type; the value follows the convention of
* {@link JobLauncherFactory#newJobLauncher(java.util.Properties, java.util.Properties, String).
* If absent, {@link JobLauncherFactory#newJobLauncher(java.util.Properties, java.util.Properties)}
* will be used which looks for the {@link ConfigurationKeys#JOB_LAUNCHER_TYPE_KEY}
* in the system configuration.
* @param jobExecStateListener an optional listener to listen for state changes in the execution.
* @param log an optional logger to be used; if none is specified, a default one
* will be instantiated.
*/
public static JobLauncherExecutionDriver create(Configurable sysConfig, JobSpec jobSpec, Optional<JobLauncherFactory.JobLauncherType> jobLauncherType, Optional<Logger> log, boolean instrumentationEnabled, JobExecutionLauncher.StandardMetrics launcherMetrics, SharedResourcesBroker<GobblinScopeTypes> instanceBroker) {
Logger actualLog = log.isPresent() ? log.get() : LoggerFactory.getLogger(JobLauncherExecutionDriver.class);
JobExecutionStateListeners callbackDispatcher = new JobExecutionStateListeners(actualLog);
JobExecutionUpdatable jobExec = JobExecutionUpdatable.createFromJobSpec(jobSpec);
JobExecutionState jobState = new JobExecutionState(jobSpec, jobExec, Optional.<JobExecutionStateListener>of(callbackDispatcher));
JobLauncher jobLauncher = createLauncher(sysConfig, jobSpec, actualLog, jobLauncherType.isPresent() ? Optional.of(jobLauncherType.get().toString()) : Optional.<String>absent(), instanceBroker);
JobListenerToJobStateBridge bridge = new JobListenerToJobStateBridge(actualLog, jobState, instrumentationEnabled, launcherMetrics);
DriverRunnable runnable = new DriverRunnable(jobLauncher, bridge, jobState, callbackDispatcher, jobExec);
return new JobLauncherExecutionDriver(jobSpec, actualLog, runnable);
}
Aggregations