Search in sources :

Example 6 with TaskResult

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();
}
Also used : Path(java.nio.file.Path) TaskResult(org.apache.helix.task.TaskResult) Test(org.testng.annotations.Test)

Example 7 with TaskResult

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));
    }
}
Also used : Closer(com.google.common.io.Closer) TaskResult(org.apache.helix.task.TaskResult)

Aggregations

TaskResult (org.apache.helix.task.TaskResult)7 Test (org.testng.annotations.Test)4 Closer (com.google.common.io.Closer)1 File (java.io.File)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 Schema (org.apache.avro.Schema)1 HelixDataAccessor (org.apache.helix.HelixDataAccessor)1 HelixProperty (org.apache.helix.HelixProperty)1 PropertyKey (org.apache.helix.PropertyKey)1 ZNRecord (org.apache.helix.ZNRecord)1