use of org.apache.gobblin.scheduler.JobScheduler in project incubator-gobblin by apache.
the class GobblinHelixJob method executeImpl.
@Override
public void executeImpl(JobExecutionContext context) throws JobExecutionException {
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
final JobScheduler jobScheduler = (JobScheduler) dataMap.get(JobScheduler.JOB_SCHEDULER_KEY);
// the properties may get mutated during job execution and the scheduler reuses it for the next round of scheduling,
// so clone it
final Properties jobProps = (Properties) ((Properties) dataMap.get(JobScheduler.PROPERTIES_KEY)).clone();
final JobListener jobListener = (JobListener) dataMap.get(JobScheduler.JOB_LISTENER_KEY);
try {
if (Boolean.valueOf(jobProps.getProperty(GobblinClusterConfigurationKeys.JOB_EXECUTE_IN_SCHEDULING_THREAD, Boolean.toString(GobblinClusterConfigurationKeys.JOB_EXECUTE_IN_SCHEDULING_THREAD_DEFAULT)))) {
jobScheduler.runJob(jobProps, jobListener);
} else {
cancellable = jobScheduler.scheduleJobImmediately(jobProps, jobListener);
}
} catch (Throwable t) {
throw new JobExecutionException(t);
}
}
Aggregations