use of org.apache.helix.task.TaskResult in project incubator-gobblin by apache.
the class SingleHelixTaskTest method NonInterruptedExceptionShouldResultInFailedStatus.
@Test
public void NonInterruptedExceptionShouldResultInFailedStatus() throws IOException, InterruptedException {
when(this.mockProcess.waitFor()).thenThrow(new RuntimeException());
final TaskResult result = createAndRunTask();
assertThat(result.getStatus()).isEqualTo(TaskResult.Status.FAILED);
}
use of org.apache.helix.task.TaskResult in project incubator-gobblin by apache.
the class SingleHelixTask method run.
@Override
public TaskResult run() {
try {
logger.info(String.format("Waiting for a single task process to finish. job name: %s. job id: %s", this.jobName, this.jobId));
int exitCode = this.taskProcess.waitFor();
if (exitCode == 0) {
logger.info("Task process finished. job name: {}. job id: {}", this.jobName, this.jobId);
return new TaskResult(TaskResult.Status.COMPLETED, "");
} else {
logger.warn("Task process failed with exitcode ({}). job name: {}. job id: {}", exitCode, this.jobName, this.jobId);
return new TaskResult(TaskResult.Status.FATAL_FAILED, "Exit code: " + exitCode);
}
} catch (final Throwable t) {
logger.error("SingleHelixTask failed due to " + t.getMessage(), t);
return new TaskResult(TaskResult.Status.FAILED, Throwables.getStackTraceAsString(t));
}
}
use of org.apache.helix.task.TaskResult in project ambry by linkedin.
the class DeprecatedContainerCloudSyncTask method run.
@Override
public TaskResult run() {
TaskResult taskResult = null;
Timer.Context deprecationTaskRunTimer = vcrMetrics.deprecationTaskRunTime.time();
try {
logger.info("DeprecatedContainerCloudSyncTask run started.");
Timer.Context accountServiceFetchTimer = vcrMetrics.accountServiceFetchTime.time();
Set<Container> deprecatedContainers = AccountUtils.getDeprecatedContainers(accountService, containerDeletionRetentionDays);
accountServiceFetchTimer.stop();
logger.info("Attempting deprecation of {} containers.", deprecatedContainers.size());
cloudDestination.deprecateContainers(deprecatedContainers);
taskResult = new TaskResult(TaskResult.Status.COMPLETED, "DeprecatedContainerCloudSyncTask completed successfully.");
} catch (CloudStorageException cloudStorageException) {
logger.error("Error in updating deprecated containers from account service to cloud: ", cloudStorageException);
taskResult = new TaskResult(TaskResult.Status.FAILED, "DeprecatedContainerCloudSyncTask failed due to ." + cloudStorageException.getMessage());
} finally {
logger.info("DeprecatedContainerCloudSyncTask done.");
deprecationTaskRunTimer.stop();
}
return taskResult;
}
use of org.apache.helix.task.TaskResult in project incubator-gobblin by apache.
the class GobblinHelixTaskTest method testRun.
@Test(dependsOnMethods = "testPrepareTask")
public void testRun() throws IOException {
TaskResult taskResult = this.gobblinHelixTask.run();
System.out.println(taskResult.getInfo());
Assert.assertEquals(taskResult.getStatus(), TaskResult.Status.COMPLETED);
File outputAvroFile = new File(this.taskOutputDir.toString(), TestHelper.REL_WRITER_FILE_PATH + File.separator + TestHelper.WRITER_FILE_NAME);
Assert.assertTrue(outputAvroFile.exists());
Schema schema = new Schema.Parser().parse(TestHelper.SOURCE_SCHEMA);
TestHelper.assertGenericRecords(outputAvroFile, schema);
}
use of org.apache.helix.task.TaskResult in project incubator-gobblin by apache.
the class SingleHelixTaskTest method failedTaskProcessShouldResultInFailedStatus.
@Test
public void failedTaskProcessShouldResultInFailedStatus() throws IOException, InterruptedException {
when(this.mockProcess.waitFor()).thenReturn(1);
final TaskResult result = createAndRunTask();
assertThat(result.getStatus()).isEqualTo(TaskResult.Status.FATAL_FAILED);
}
Aggregations