use of org.apache.gobblin.runtime.JobException in project incubator-gobblin by apache.
the class GobblinHelixJobScheduler method scheduleJobImmediately.
public Future<?> scheduleJobImmediately(Properties jobProps, JobListener jobListener) {
RetriggeringJobCallable retriggeringJob = new RetriggeringJobCallable(jobProps, jobListener);
final Future<?> future = this.jobExecutor.submit(retriggeringJob);
return new Future() {
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
if (!GobblinHelixJobScheduler.this.isCancelRequested()) {
return false;
}
boolean result = true;
try {
JobLauncher jobLauncher = retriggeringJob.getCurrentJobLauncher();
if (jobLauncher != null) {
jobLauncher.cancelJob(jobListener);
}
} catch (JobException e) {
LOGGER.error("Failed to cancel job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
result = false;
}
if (mayInterruptIfRunning) {
result &= future.cancel(true);
}
return result;
}
@Override
public boolean isCancelled() {
return future.isCancelled();
}
@Override
public boolean isDone() {
return future.isDone();
}
@Override
public Object get() throws InterruptedException, ExecutionException {
return future.get();
}
@Override
public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
return future.get(timeout, unit);
}
};
}
use of org.apache.gobblin.runtime.JobException in project incubator-gobblin by apache.
the class GobblinHelixJobScheduler method handleNewJobConfigArrival.
@Subscribe
public void handleNewJobConfigArrival(NewJobConfigArrivalEvent newJobArrival) {
LOGGER.info("Received new job configuration of job " + newJobArrival.getJobName());
try {
Properties jobConfig = new Properties();
jobConfig.putAll(this.properties);
jobConfig.putAll(newJobArrival.getJobConfig());
metrics.updateTimeBeforeJobScheduling(jobConfig);
if (jobConfig.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY)) {
LOGGER.info("Scheduling job " + newJobArrival.getJobName());
scheduleJob(jobConfig, new MetricsTrackingListener(metrics));
} else {
LOGGER.info("No job schedule found, so running job " + newJobArrival.getJobName());
this.jobExecutor.execute(new NonScheduledJobRunner(newJobArrival.getJobName(), jobConfig, new MetricsTrackingListener(metrics)));
}
} catch (JobException je) {
LOGGER.error("Failed to schedule or run job " + newJobArrival.getJobName(), je);
}
}
use of org.apache.gobblin.runtime.JobException in project incubator-gobblin by apache.
the class PathAlterationListenerAdaptorForMonitor method loadNewJobConfigAndHandleNewJob.
public void loadNewJobConfigAndHandleNewJob(Path path, JobScheduler.Action action) {
// Load the new job configuration and schedule the new job
String customizedInfo = "";
try {
Properties jobProps = SchedulerUtils.loadGenericJobConfig(this.jobScheduler.properties, path, jobConfigFileDirPath);
LOG.debug("Loaded job properties: {}", jobProps);
switch(action) {
case SCHEDULE:
boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
customizedInfo = "schedule";
addToJobNameMap(jobProps);
jobScheduler.scheduleJob(jobProps, runOnce ? new RunOnceJobListener() : new EmailNotificationJobListener());
break;
case RESCHEDULE:
customizedInfo = "reschedule";
rescheduleJob(jobProps);
break;
case UNSCHEDULE:
throw new RuntimeException("Should not call loadNewJobConfigAndHandleNewJob for unscheduling jobs.");
default:
break;
}
} catch (ConfigurationException | IOException e) {
LOG.error("Failed to load from job configuration file " + path.toString(), e);
} catch (JobException je) {
LOG.error("Failed to " + customizedInfo + " new job loaded from job configuration file " + path.toString(), je);
}
}
use of org.apache.gobblin.runtime.JobException in project incubator-gobblin by apache.
the class GobblinServiceJobScheduler method scheduleJob.
/**
* Synchronize the job scheduling because the same flowSpec can be scheduled by different threads.
*/
@Override
public synchronized void scheduleJob(Properties jobProps, JobListener jobListener) throws JobException {
Map<String, Object> additionalJobDataMap = Maps.newHashMap();
additionalJobDataMap.put(ServiceConfigKeys.GOBBLIN_SERVICE_FLOWSPEC, this.scheduledFlowSpecs.get(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY)));
try {
scheduleJob(jobProps, jobListener, additionalJobDataMap, GobblinServiceJob.class);
} catch (Exception e) {
throw new JobException("Failed to schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
}
}
use of org.apache.gobblin.runtime.JobException in project incubator-gobblin by apache.
the class GobblinServiceJobScheduler method runJob.
@Override
public void runJob(Properties jobProps, JobListener jobListener) throws JobException {
try {
Spec flowSpec = this.scheduledFlowSpecs.get(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY));
this.orchestrator.orchestrate(flowSpec);
} catch (Exception e) {
throw new JobException("Failed to run Spec: " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
}
}
Aggregations