use of org.apache.helix.task.TaskResult in project incubator-gobblin by apache.
the class SingleHelixTaskTest method successTaskProcessShouldResultInCompletedStatus.
@Test
public void successTaskProcessShouldResultInCompletedStatus() throws IOException, InterruptedException {
when(this.mockProcess.waitFor()).thenReturn(0);
final TaskResult result = createAndRunTask();
assertThat(result.getStatus()).isEqualTo(TaskResult.Status.COMPLETED);
final Path expectedPath = Paths.get(WORK_UNIT_FILE_PATH);
verify(this.mockLauncher).launch(JOB_ID, expectedPath);
verify(this.mockProcess).waitFor();
}
use of org.apache.helix.task.TaskResult in project incubator-gobblin by apache.
the class GobblinHelixTask method run.
@Override
public TaskResult run() {
try (Closer closer = Closer.create()) {
closer.register(MDC.putCloseable(ConfigurationKeys.JOB_NAME_KEY, this.jobName));
closer.register(MDC.putCloseable(ConfigurationKeys.JOB_KEY_KEY, this.jobKey));
this.task.run();
return new TaskResult(TaskResult.Status.COMPLETED, "");
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return new TaskResult(TaskResult.Status.CANCELED, "");
} catch (Throwable t) {
_logger.error("GobblinHelixTask failed due to " + t.getMessage(), t);
return new TaskResult(TaskResult.Status.FAILED, Throwables.getStackTraceAsString(t));
}
}
Aggregations