@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobFailure(jobContext); } });
@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobStart(jobContext); } });
@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobCancellation(jobContext); } });
@Test public void testParallelJobListener() throws Exception { JobContext jobContext = mock(JobContext.class); JobListener mockJobListener1 = mock(JobListener.class); JobListener mockJobListener2 = mock(JobListener.class); CloseableJobListener closeableJobListener = JobListeners.parallelJobListener(Lists.newArrayList(mockJobListener1, mockJobListener2)); closeableJobListener.onJobCompletion(jobContext); closeableJobListener.onJobCancellation(jobContext); closeableJobListener.close(); verify(mockJobListener1, times(1)).onJobCompletion(jobContext); verify(mockJobListener1, times(1)).onJobCancellation(jobContext); verify(mockJobListener2, times(1)).onJobCompletion(jobContext); verify(mockJobListener2, times(1)).onJobCancellation(jobContext); } }
@Override public void onJobCancellation(JobContext jobContext) throws Exception { super.onJobCancellation(jobContext); jobLauncherMetrics.totalJobsCancelled.incrementAndGet(); } }
@Override public Void call() throws Exception { jobListener.onJobCompletion(jobContext); return null; } });
/** * 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); } }
@Override public void onJobPrepare(JobContext jobContext) throws Exception { super.onJobPrepare(jobContext); _jobContext = jobContext; if (_jobState.getRunningState() == null) { _jobState.switchToPending(); } _jobState.switchToRunning(); if (_instrumentationEnabled && null != _launcherMetrics) { _launcherMetrics.getNumJobsLaunched().inc(); } }
@Override public Void call() throws Exception { jobListener.onJobPrepare(jobContext); return null; } });
@Override public void onJobStart(JobContext jobContext) throws Exception { super.onJobStart(jobContext); }
/** * Chains a given {@link List} of {@link JobListener}s into a single {@link JobListener}. The specified {@link JobListener}s * will all be executed in parallel. * * @param jobListeners is a {@link List} of {@link JobListener}s that need to be executed * * @return a {@link CloseableJobListener}, which is similar to {@link JobListener}, except * {@link CloseableJobListener#close()} will block until all {@link JobListener}s have finished their executions. */ public static CloseableJobListener parallelJobListener(List<JobListener> jobListeners) { Iterables.removeIf(jobListeners, Predicates.isNull()); return new ParallelJobListener(jobListeners); }
@Override public void onJobCancellation(JobContext jobContext) throws Exception { super.onJobCancellation(jobContext); _jobState.switchToCancelled(); if (_instrumentationEnabled && null != _launcherMetrics) { _launcherMetrics.getNumJobsCancelled().inc(); } } }
@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobCompletion(jobContext); } });
@Override public Void call() throws Exception { jobListener.onJobCancellation(jobContext); return null; } });
@Override public Void call() throws Exception { jobListener.onJobFailure(jobContext); return null; } });
@Override public Void call() throws Exception { jobListener.onJobStart(jobContext); return null; } });
@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobPrepare(jobContext); } });
@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobCompletion(jobContext); } });
@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobFailure(jobContext); } });
@Override public void apply(JobListener jobListener, JobContext jobContext) throws Exception { jobListener.onJobFailure(jobContext); } });