@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); } }
@Override public void scheduleJob(Properties jobProps, JobListener jobListener) throws JobException { try { while (!startServicesCompleted) { LOGGER.info("{} service is not fully up, waiting here...", this.getClass().getName()); Thread.sleep(1000); } scheduleJob(jobProps, jobListener, Maps.newHashMap(), GobblinHelixJob.class); } catch (Exception e) { throw new JobException("Failed to schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e); } }
/** * 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); } }
public Future<?> scheduleJobImmediately(Properties jobProps, JobListener jobListener) throws JobException { try { return scheduleJobImmediately(jobProps, jobListener, buildJobLauncher(jobProps)); } catch (Exception e) { throw new JobException("Job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY) + " cannot be immediately scheduled.", e); } }
/** * Unschedule and delete a job. * * @param jobName Job name * @throws JobException when there is anything wrong unschedule the job */ public void unscheduleJob(String jobName) throws JobException { if (this.scheduledJobs.containsKey(jobName)) { try { this.scheduler.getScheduler().deleteJob(this.scheduledJobs.remove(jobName)); } catch (SchedulerException se) { LOG.error("Failed to unschedule and delete job " + jobName, se); throw new JobException("Failed to unschedule and delete job " + jobName, se); } } }
/** * Run a job. * * <p> * This method runs the job immediately without going through the Quartz scheduler. * This is particularly useful for testing. * </p> * * @param jobProps Job configuration properties * @param jobListener {@link JobListener} used for callback, can be <em>null</em> if no callback is needed. * @throws JobException when there is anything wrong with running the job */ public void runJob(Properties jobProps, JobListener jobListener) throws JobException { try { runJob(jobProps, jobListener, buildJobLauncher(jobProps)); } catch (Exception e) { throw new JobException("Failed to run job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e); } }
/** * <p> In some cases, the job launcher will be early stopped. * It can be due to the large volume of input source data. * In such case, we need to re-launch the same job until * the job launcher determines it is safe to stop. */ private void runJobLauncherLoop() throws JobException { try { while (true) { currentJobLauncher = this.jobScheduler.buildJobLauncher(jobProps); // in "run once" case, job scheduler will remove current job from the scheduler boolean isEarlyStopped = this.jobScheduler.runJob(jobProps, jobListener, currentJobLauncher); boolean isRetriggerEnabled = this.isRetriggeringEnabled(); if (isEarlyStopped && isRetriggerEnabled) { log.info("Job {} will be re-triggered.", jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY)); } else { break; } currentJobLauncher = null; } } catch (Exception e) { log.error("Failed to run job {}", jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e); throw new JobException("Failed to run job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e); } }
static void waitJobInitialization( HelixManager helixManager, String workFlowName, String jobName, long timeoutMillis) throws Exception { WorkflowContext workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName); // If the helix job is deleted from some other thread or a completely external process, // method waitJobCompletion() needs to differentiate between the cases where // 1) workflowContext did not get initialized ever, in which case we need to keep waiting, or // 2) it did get initialized but deleted soon after, in which case we should stop waiting // To overcome this issue, we wait here till workflowContext gets initialized long start = System.currentTimeMillis(); while (workflowContext == null || workflowContext.getJobState(TaskUtil.getNamespacedJobName(workFlowName, jobName)) == null) { if (System.currentTimeMillis() - start > timeoutMillis) { log.error("Job cannot be initialized within {} milliseconds, considered as an error", timeoutMillis); throw new JobException("Job cannot be initialized within {} milliseconds, considered as an error"); } workflowContext = TaskDriver.getWorkflowContext(helixManager, workFlowName); Thread.sleep(1000); log.info("Waiting for work flow initialization."); } log.info("Work flow {} initialized", workFlowName); }
throw new JobException("Failed to launch and run job " + jobName, t);
} catch (SchedulerException se) { LOG.error("Failed to schedule job " + jobName, se); throw new JobException("Failed to schedule job " + jobName, se);
throw new JobException(String.format("Previous instance of job %s is still running, skipping this scheduled run", this.jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY)));
throw new JobException("Failed to check unfinished commit sequences", e);
private void notifyListeners(JobContext jobContext, JobListener jobListener, String timerEventName, JobListenerAction action) throws JobException { TimingEvent timer = this.eventSubmitter.getTimingEvent(timerEventName); try (CloseableJobListener parallelJobListener = getParallelCombinedJobListener(this.jobContext.getJobState(), jobListener)) { action.apply(parallelJobListener, jobContext); } catch (Exception e) { throw new JobException("Failed to execute all JobListeners", e); } finally { timer.stop(this.eventMetadataGenerator.getMetadata(this.jobContext, EventName.getEnumFromEventId(timerEventName))); } }
throw new JobException("Failed to check unfinished commit sequences", e);
this.eventSubmitter.submit(JobEvent.WORK_UNITS_MISSING); jobState.setState(JobState.RunningState.FAILED); throw new JobException("Failed to get work units for job " + jobId); throw new JobException(String.format("Job %s failed", jobId)); } else { notifyListeners(this.jobContext, jobListener, TimingEvent.LauncherTimings.JOB_SUCCEEDED, new JobListenerAction() {
@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); } }
@Override public void scheduleJob(Properties jobProps, JobListener jobListener) throws JobException { try { while (!startServicesCompleted) { LOGGER.info("{} service is not fully up, waiting here...", this.getClass().getName()); Thread.sleep(1000); } scheduleJob(jobProps, jobListener, Maps.newHashMap(), GobblinHelixJob.class); } catch (Exception e) { throw new JobException("Failed to schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e); } }
/** * 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); } }
public Future<?> scheduleJobImmediately(Properties jobProps, JobListener jobListener) throws JobException { try { return scheduleJobImmediately(jobProps, jobListener, buildJobLauncher(jobProps)); } catch (Exception e) { throw new JobException("Job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY) + " cannot be immediately scheduled.", e); } }
/** * Unschedule and delete a job. * * @param jobName Job name * @throws JobException when there is anything wrong unschedule the job */ public void unscheduleJob(String jobName) throws JobException { if (this.scheduledJobs.containsKey(jobName)) { try { this.scheduler.getScheduler().deleteJob(this.scheduledJobs.remove(jobName)); } catch (SchedulerException se) { LOG.error("Failed to unschedule and delete job " + jobName, se); throw new JobException("Failed to unschedule and delete job " + jobName, se); } } }