public static JobExecutionResult createFailureResult(Throwable cause) { return new JobExecutionResult(RunningState.FAILED, cause); }
public static JobExecutionResult createFromState(JobExecutionState state) { Preconditions.checkArgument(null != state.getRunningState()); Preconditions.checkArgument(state.getRunningState().isDone()); if (state.getRunningState().isSuccess()) { return JobExecutionResult.createSuccessResult(); } else if (state.getRunningState().isCancelled()) { return JobExecutionResult.createCancelledResult(); } else { // FIXME we need to capture error(s) return JobExecutionResult.createFailureResult( new RuntimeException("Gobblin job failed:" + state.getJobExecution())); } } }
@Override public JobExecutionResult call() throws JobException, InterruptedException, TimeoutException { jobLauncher.launchJob(bridge); jobState.awaitForDone(Long.MAX_VALUE); return JobExecutionResult.createFromState(jobState); } }
@Test(timeOut = 30000) public void testTaskFailsWithException() throws Exception { // Test that the job runner fails with a reasonable amount of time if a custom task throws an exception JobExecutionResult result = new EmbeddedGobblin("alwaysThrowsJob").setConfiguration(ConfigurationKeys.SOURCE_CLASS_KEY, FailsWithExceptionTaskFactory.Source.class.getName()) .run(); Assert.assertFalse(result.isSuccessful()); }
public boolean isFailed() { return RunningState.FAILED == getFinalState(); }
@Override public JobExecutionResult get() throws InterruptedException { try { return super.get(); } catch (ExecutionException ee) { return JobExecutionResult.createFailureResult(ee.getCause()); } }
@Test public void testWorkUnitStreamForAllFailures () throws Exception { File basePath = Files.createTempDir(); basePath.deleteOnExit(); GenericRecord r1 = createRandomRecord(); // verify 24 hours for (int i = 1; i < 24; ++i) { String path = "Identity/MemberAccount/minutely/2017/04/03/" + i + "/20_30/run_2017-04-03-10-20"; File jobDir = new File(basePath, path); Assert.assertTrue(jobDir.mkdirs()); writeFileWithContent(jobDir, "file_random", r1, 20); } EmbeddedGobblin embeddedGobblin = createEmbeddedGobblinForAllFailures("workunit_stream_all_failure", basePath.getAbsolutePath().toString()); JobExecutionResult result = embeddedGobblin.run(); Assert.assertFalse(result.isSuccessful()); }
public boolean isCancelled() { return RunningState.CANCELLED == getFinalState(); }
@Override public JobExecutionResult get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { try { return super.get(timeout, unit); } catch (ExecutionException ee) { return JobExecutionResult.createFailureResult(ee.getCause()); } } }
@Test public void testWorkUnitStream () throws Exception { File basePath = Files.createTempDir(); basePath.deleteOnExit(); GenericRecord r1 = createRandomRecord(); // verify 24 hours for (int i = 22; i < 24; ++i) { String path = "Identity/MemberAccount/minutely/2017/04/03/" + i + "/20_30/run_2017-04-03-10-20"; File jobDir = new File(basePath, path); Assert.assertTrue(jobDir.mkdirs()); writeFileWithContent(jobDir, "file_random", r1, 20); } EmbeddedGobblin embeddedGobblin = createEmbeddedGobblin("workunit_stream", basePath.getAbsolutePath().toString()); JobExecutionResult result = embeddedGobblin.run(); Assert.assertTrue(result.isSuccessful()); }
public static JobExecutionResult createFromState(JobExecutionState state) { Preconditions.checkArgument(null != state.getRunningState()); Preconditions.checkArgument(state.getRunningState().isDone()); if (state.getRunningState().isSuccess()) { return JobExecutionResult.createSuccessResult(); } else if (state.getRunningState().isCancelled()) { return JobExecutionResult.createCancelledResult(); } else { // FIXME we need to capture error(s) return JobExecutionResult.createFailureResult( new RuntimeException("Gobblin job failed:" + state.getJobExecution())); } } }
public static JobExecutionResult createCancelledResult() { return new JobExecutionResult(RunningState.CANCELLED, null); }
public boolean isSuccessful() { return RunningState.COMMITTED == getFinalState(); }
@Override public JobExecutionResult get() throws InterruptedException { try { return super.get(); } catch (ExecutionException ee) { return JobExecutionResult.createFailureResult(ee.getCause()); } }
@Override public JobExecutionResult call() throws JobException, InterruptedException, TimeoutException { jobLauncher.launchJob(bridge); jobState.awaitForDone(Long.MAX_VALUE); return JobExecutionResult.createFromState(jobState); } }
@Test public void testDedup() throws Exception { File basePath = Files.createTempDir(); basePath.deleteOnExit(); File jobDir = new File(basePath, "Identity/MemberAccount/minutely/2017/04/03/10/20_30/run_2017-04-03-10-20"); Assert.assertTrue(jobDir.mkdirs()); GenericRecord r1 = createRandomRecord(); GenericRecord r2 = createRandomRecord(); writeFileWithContent(jobDir, "file1", r1, 20); writeFileWithContent(jobDir, "file2", r2, 18); EmbeddedGobblin embeddedGobblin = createEmbeddedGobblin("dedup", basePath.getAbsolutePath().toString()); JobExecutionResult result = embeddedGobblin.run(); Assert.assertTrue(result.isSuccessful()); }
public static JobExecutionResult createSuccessResult() { return new JobExecutionResult(RunningState.COMMITTED, null); }
public boolean isSuccessful() { return RunningState.COMMITTED == getFinalState(); }
@Override public JobExecutionResult get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { try { return super.get(timeout, unit); } catch (ExecutionException ee) { return JobExecutionResult.createFailureResult(ee.getCause()); } } }
@Test public void testNonDedup() throws Exception { File basePath = Files.createTempDir(); basePath.deleteOnExit(); File jobDir = new File(basePath, "Identity/MemberAccount/minutely/2017/04/03/10/20_30/run_2017-04-03-10-20"); Assert.assertTrue(jobDir.mkdirs()); GenericRecord r1 = createRandomRecord(); GenericRecord r2 = createRandomRecord(); writeFileWithContent(jobDir, "file1", r1, 20); writeFileWithContent(jobDir, "file2", r2, 18); EmbeddedGobblin embeddedGobblin = createEmbeddedGobblin("non-dedup", basePath.getAbsolutePath().toString()); JobExecutionResult result = embeddedGobblin.run(); Assert.assertTrue(result.isSuccessful()); }