Search in sources :

Example 1 with JobExecutionStateListeners

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);
}
Also used : JobLauncher(org.apache.gobblin.runtime.JobLauncher) JobExecutionState(org.apache.gobblin.runtime.api.JobExecutionState) Logger(org.slf4j.Logger) JobExecutionUpdatable(org.apache.gobblin.runtime.std.JobExecutionUpdatable) JobExecutionStateListeners(org.apache.gobblin.runtime.std.JobExecutionStateListeners)

Aggregations

JobLauncher (org.apache.gobblin.runtime.JobLauncher)1 JobExecutionState (org.apache.gobblin.runtime.api.JobExecutionState)1 JobExecutionStateListeners (org.apache.gobblin.runtime.std.JobExecutionStateListeners)1 JobExecutionUpdatable (org.apache.gobblin.runtime.std.JobExecutionUpdatable)1 Logger (org.slf4j.Logger)1