Search in sources :

Example 1 with JobScheduler

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);
    }
}
Also used : JobScheduler(org.apache.gobblin.scheduler.JobScheduler) JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) Properties(java.util.Properties) JobListener(org.apache.gobblin.runtime.listeners.JobListener)

Aggregations

Properties (java.util.Properties)1 JobListener (org.apache.gobblin.runtime.listeners.JobListener)1 JobScheduler (org.apache.gobblin.scheduler.JobScheduler)1 JobDataMap (org.quartz.JobDataMap)1 JobExecutionException (org.quartz.JobExecutionException)1