use of org.apache.gobblin.runtime.JobException 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);
}
}
use of org.apache.gobblin.runtime.JobException in project incubator-gobblin by apache.
the class PathAlterationListenerAdaptorForMonitor method unscheduleJobAtPath.
private void unscheduleJobAtPath(Path path) {
try {
Path pathWithoutSchemeOrAuthority = PathUtils.getPathWithoutSchemeAndAuthority(path);
String jobName = this.jobNameMap.get(pathWithoutSchemeOrAuthority);
if (jobName == null) {
LOG.info("Could not find a scheduled job to unschedule with path " + pathWithoutSchemeOrAuthority);
return;
}
LOG.info("Unscheduling job " + jobName);
this.jobScheduler.unscheduleJob(jobName);
this.jobNameMap.remove(pathWithoutSchemeOrAuthority);
} catch (JobException je) {
LOG.error("Could not unschedule job " + this.jobNameMap.get(path));
}
}
use of org.apache.gobblin.runtime.JobException in project incubator-gobblin by apache.
the class GobblinHelixJobLauncher method waitForJobCompletion.
private void waitForJobCompletion() throws InterruptedException {
LOGGER.info("Waiting for job to complete...");
boolean timeoutEnabled = Boolean.parseBoolean(this.jobProps.getProperty(ConfigurationKeys.HELIX_JOB_TIMEOUT_ENABLED_KEY, ConfigurationKeys.DEFAULT_HELIX_JOB_TIMEOUT_ENABLED));
long timeoutInSeconds = Long.parseLong(this.jobProps.getProperty(ConfigurationKeys.HELIX_JOB_TIMEOUT_SECONDS, ConfigurationKeys.DEFAULT_HELIX_JOB_TIMEOUT_SECONDS));
long endTime = System.currentTimeMillis() + timeoutInSeconds * 1000;
while (!timeoutEnabled || System.currentTimeMillis() <= endTime) {
WorkflowContext workflowContext = TaskDriver.getWorkflowContext(this.helixManager, this.helixQueueName);
if (workflowContext != null) {
org.apache.helix.task.TaskState helixJobState = workflowContext.getJobState(this.jobResourceName);
if (helixJobState == org.apache.helix.task.TaskState.COMPLETED || helixJobState == org.apache.helix.task.TaskState.FAILED || helixJobState == org.apache.helix.task.TaskState.STOPPED) {
return;
}
}
Thread.sleep(1000);
}
helixTaskDriverWaitToStop(this.helixQueueName, 10L);
try {
cancelJob(this.jobListener);
} catch (JobException e) {
throw new RuntimeException("Unable to cancel job " + jobContext.getJobName() + ": ", e);
}
this.helixTaskDriver.resume(this.helixQueueName);
LOGGER.info("stopped the queue, deleted the job");
}
Aggregations