private void runDistcp(Path from, Path to) throws Exception { info("sourcePath: " + from + ", destinationPath: " + to); EmbeddedGobblin embeddedGobblin = new EmbeddedGobblinDistcp(from, to).mrMode(); // Used for global throttling" embeddedGobblin.distributeJar("lib/*"); for (Map.Entry<String, String> entry : this.props.entrySet()) { if (entry.getKey() != null && (entry.getKey()).startsWith(ATTR_PREFIX)) { String key = (entry.getKey()).substring(ATTR_PREFIX.length()); embeddedGobblin.setConfiguration(key, entry.getValue()); } } JobExecutionResult result = embeddedGobblin.run(); if (!result.isSuccessful()) { throw new RuntimeException("Distcp job failed!", result.getErrorCause()); } }
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 boolean isCancelled() { return RunningState.CANCELLED == getFinalState(); }
public static JobExecutionResult createCancelledResult() { return new JobExecutionResult(RunningState.CANCELLED, null); }
@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()); } } }
@Override public JobExecutionResult call() throws JobException, InterruptedException, TimeoutException { jobLauncher.launchJob(bridge); jobState.awaitForDone(Long.MAX_VALUE); return JobExecutionResult.createFromState(jobState); } }
public boolean isSuccessful() { return RunningState.COMMITTED == getFinalState(); }
public static JobExecutionResult createSuccessResult() { return new JobExecutionResult(RunningState.COMMITTED, null); }
@Override public JobExecutionResult get() throws InterruptedException { try { return super.get(); } catch (ExecutionException ee) { return JobExecutionResult.createFailureResult(ee.getCause()); } }
public boolean isFailed() { return RunningState.FAILED == getFinalState(); }
public static JobExecutionResult createFailureResult(Throwable cause) { return new JobExecutionResult(RunningState.FAILED, cause); }