Search in sources :

Example 11 with JobException

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);
    }
}
Also used : JobException(org.apache.gobblin.runtime.JobException) EmailNotificationJobListener(org.apache.gobblin.runtime.listeners.EmailNotificationJobListener) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IOException(java.io.IOException) Properties(java.util.Properties) RunOnceJobListener(org.apache.gobblin.runtime.listeners.RunOnceJobListener)

Example 12 with JobException

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));
    }
}
Also used : Path(org.apache.hadoop.fs.Path) JobException(org.apache.gobblin.runtime.JobException)

Example 13 with JobException

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");
}
Also used : JobException(org.apache.gobblin.runtime.JobException) WorkflowContext(org.apache.helix.task.WorkflowContext)

Aggregations

JobException (org.apache.gobblin.runtime.JobException)13 UnableToInterruptJobException (org.quartz.UnableToInterruptJobException)6 Properties (java.util.Properties)5 FlowSpec (org.apache.gobblin.runtime.api.FlowSpec)3 IOException (java.io.IOException)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 Spec (org.apache.gobblin.runtime.api.Spec)2 EmailNotificationJobListener (org.apache.gobblin.runtime.listeners.EmailNotificationJobListener)2 RunOnceJobListener (org.apache.gobblin.runtime.listeners.RunOnceJobListener)2 JobExecutionException (org.quartz.JobExecutionException)2 Subscribe (com.google.common.eventbus.Subscribe)1 Closer (com.google.common.io.Closer)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Future (java.util.concurrent.Future)1 TimeUnit (java.util.concurrent.TimeUnit)1 Tag (org.apache.gobblin.metrics.Tag)1 JobLauncher (org.apache.gobblin.runtime.JobLauncher)1 Path (org.apache.hadoop.fs.Path)1 WorkflowContext (org.apache.helix.task.WorkflowContext)1