Search in sources :

Example 1 with TaskResult

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

Example 2 with TaskResult

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

Example 3 with TaskResult

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;
}
Also used : Container(com.github.ambry.account.Container) Timer(com.codahale.metrics.Timer) TaskResult(org.apache.helix.task.TaskResult)

Example 4 with 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);
}
Also used : Schema(org.apache.avro.Schema) TaskResult(org.apache.helix.task.TaskResult) File(java.io.File) Test(org.testng.annotations.Test)

Example 5 with TaskResult

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

Aggregations

TaskResult (org.apache.helix.task.TaskResult)9 Test (org.testng.annotations.Test)4 StatsSnapshot (com.github.ambry.server.StatsSnapshot)2 HashMap (java.util.HashMap)2 Histogram (com.codahale.metrics.Histogram)1 Timer (com.codahale.metrics.Timer)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Container (com.github.ambry.account.Container)1 HostAccountStorageStatsWrapper (com.github.ambry.server.HostAccountStorageStatsWrapper)1 AggregatedAccountStorageStats (com.github.ambry.server.storagestats.AggregatedAccountStorageStats)1 Pair (com.github.ambry.utils.Pair)1 Closer (com.google.common.io.Closer)1 File (java.io.File)1 Path (java.nio.file.Path)1 Map (java.util.Map)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.zookeeper.datamodel.ZNRecord)1