use of org.apache.gobblin.runtime.listeners.RunOnceJobListener in project incubator-gobblin by apache.
the class JobScheduler method scheduleGeneralConfiguredJobs.
/**
* Schedule Gobblin jobs in general position
*/
private void scheduleGeneralConfiguredJobs() throws ConfigurationException, JobException, IOException {
LOG.info("Scheduling configured jobs");
for (Properties jobProps : loadGeneralJobConfigs()) {
if (!jobProps.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY)) {
// A job without a cron schedule is considered a one-time job
jobProps.setProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "true");
}
boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
scheduleJob(jobProps, runOnce ? new RunOnceJobListener() : new EmailNotificationJobListener());
this.listener.addToJobNameMap(jobProps);
}
}
use of org.apache.gobblin.runtime.listeners.RunOnceJobListener 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.listeners.RunOnceJobListener in project incubator-gobblin by apache.
the class PathAlterationListenerAdaptorForMonitor method rescheduleJob.
private void rescheduleJob(Properties jobProps) throws JobException {
String jobName = jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY);
Path jobPath = getJobPath(jobProps);
// First unschedule and delete the old job
if (this.jobNameMap.containsKey(jobPath)) {
jobScheduler.unscheduleJob(this.jobNameMap.get(jobPath));
this.jobNameMap.remove(jobPath);
}
boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
// Reschedule the job with the new job configuration
jobScheduler.scheduleJob(jobProps, runOnce ? new RunOnceJobListener() : new EmailNotificationJobListener());
addToJobNameMap(jobProps);
LOG.debug("[JobScheduler] The new job " + jobName + " is rescheduled.");
}
use of org.apache.gobblin.runtime.listeners.RunOnceJobListener in project incubator-gobblin by apache.
the class PathAlterationListenerAdaptorForMonitor method loadNewCommonConfigAndHandleNewJob.
public void loadNewCommonConfigAndHandleNewJob(Path path, JobScheduler.Action action) {
String customizedInfoAction = "";
String customizedInfoResult = "";
try {
for (Properties jobProps : SchedulerUtils.loadGenericJobConfigs(jobScheduler.properties, path, jobConfigFileDirPath)) {
try {
switch(action) {
case SCHEDULE:
boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
customizedInfoAction = "schedule";
customizedInfoResult = "creation or equivalent action";
addToJobNameMap(jobProps);
jobScheduler.scheduleJob(jobProps, runOnce ? new RunOnceJobListener() : new EmailNotificationJobListener());
break;
case RESCHEDULE:
customizedInfoAction = "reschedule";
customizedInfoResult = "change";
rescheduleJob(jobProps);
break;
case UNSCHEDULE:
throw new RuntimeException("Should not call loadNewCommonConfigAndHandleNewJob for unscheduling jobs.");
default:
break;
}
} catch (JobException je) {
LOG.error("Failed to " + customizedInfoAction + " job reloaded from job configuration file " + jobProps.getProperty(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY), je);
}
}
} catch (ConfigurationException | IOException e) {
LOG.error("Failed to reload job configuration files affected by " + customizedInfoResult + " to " + path.toString(), e);
}
}
Aggregations