Search in sources :

Example 6 with ErrorCode

use of com.facebook.presto.spi.ErrorCode in project presto by prestodb.

the class TestHttpRemoteTask method runTest.

private void runTest(FailureScenario failureScenario, boolean useThriftEncoding) throws Exception {
    AtomicLong lastActivityNanos = new AtomicLong(System.nanoTime());
    TestingTaskResource testingTaskResource = new TestingTaskResource(lastActivityNanos, failureScenario);
    HttpRemoteTaskFactory httpRemoteTaskFactory = createHttpRemoteTaskFactory(testingTaskResource, useThriftEncoding);
    RemoteTask remoteTask = createRemoteTask(httpRemoteTaskFactory);
    testingTaskResource.setInitialTaskInfo(remoteTask.getTaskInfo());
    remoteTask.start();
    waitUntilIdle(lastActivityNanos);
    httpRemoteTaskFactory.stop();
    assertTrue(remoteTask.getTaskStatus().getState().isDone(), format("TaskStatus is not in a done state: %s", remoteTask.getTaskStatus()));
    ErrorCode actualErrorCode = getOnlyElement(remoteTask.getTaskStatus().getFailures()).getErrorCode();
    switch(failureScenario) {
        case TASK_MISMATCH:
        case TASK_MISMATCH_WHEN_VERSION_IS_HIGH:
            assertTrue(remoteTask.getTaskInfo().getTaskStatus().getState().isDone(), format("TaskInfo is not in a done state: %s", remoteTask.getTaskInfo()));
            assertEquals(actualErrorCode, REMOTE_TASK_MISMATCH.toErrorCode());
            break;
        case REJECTED_EXECUTION:
            // for a rejection to occur, the http client must be shutdown, which means we will not be able to ge the final task info
            assertEquals(actualErrorCode, REMOTE_TASK_ERROR.toErrorCode());
            break;
        default:
            throw new UnsupportedOperationException();
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) RemoteTask(com.facebook.presto.execution.RemoteTask) ErrorCode(com.facebook.presto.spi.ErrorCode)

Example 7 with ErrorCode

use of com.facebook.presto.spi.ErrorCode in project presto by prestodb.

the class PrestoSparkExecutionExceptionFactory method isRetryable.

private static boolean isRetryable(ExecutionFailureInfo executionFailureInfo) {
    ErrorCode errorCode = executionFailureInfo.getErrorCode();
    if (errorCode == null) {
        return true;
    }
    ErrorType type = errorCode.getType();
    return type == INTERNAL_ERROR || type == EXTERNAL;
}
Also used : ErrorType(com.facebook.presto.spi.ErrorType) ErrorCode(com.facebook.presto.spi.ErrorCode)

Aggregations

ErrorCode (com.facebook.presto.spi.ErrorCode)7 PrestoException (com.facebook.presto.spi.PrestoException)2 Logger (com.facebook.airlift.log.Logger)1 Session (com.facebook.presto.Session)1 FailureInfo (com.facebook.presto.client.FailureInfo)1 QueryError (com.facebook.presto.client.QueryError)1 Type (com.facebook.presto.common.type.Type)1 EMPTY_STAGE_STATS (com.facebook.presto.execution.BasicStageExecutionStats.EMPTY_STAGE_STATS)1 ExecutionFailureInfo (com.facebook.presto.execution.ExecutionFailureInfo)1 Failure (com.facebook.presto.execution.Failure)1 QueryOutputInfo (com.facebook.presto.execution.QueryExecution.QueryOutputInfo)1 QueryState (com.facebook.presto.execution.QueryState)1 DISPATCHING (com.facebook.presto.execution.QueryState.DISPATCHING)1 FINISHED (com.facebook.presto.execution.QueryState.FINISHED)1 FINISHING (com.facebook.presto.execution.QueryState.FINISHING)1 PLANNING (com.facebook.presto.execution.QueryState.PLANNING)1 QUEUED (com.facebook.presto.execution.QueryState.QUEUED)1 RUNNING (com.facebook.presto.execution.QueryState.RUNNING)1 STARTING (com.facebook.presto.execution.QueryState.STARTING)1 TERMINAL_QUERY_STATES (com.facebook.presto.execution.QueryState.TERMINAL_QUERY_STATES)1