Search in sources :

Example 6 with ExecutionFailureInfo

use of io.trino.execution.ExecutionFailureInfo in project trino by trinodb.

the class Failures method toFailure.

private static ExecutionFailureInfo toFailure(Throwable throwable, Set<Throwable> seenFailures) {
    if (throwable == null) {
        return null;
    }
    String type;
    HostAddress remoteHost = null;
    if (throwable instanceof Failure) {
        type = ((Failure) throwable).getType();
    } else {
        Class<?> clazz = throwable.getClass();
        type = firstNonNull(clazz.getCanonicalName(), clazz.getName());
    }
    if (throwable instanceof TrinoTransportException) {
        remoteHost = ((TrinoTransportException) throwable).getRemoteHost();
    }
    if (seenFailures.contains(throwable)) {
        return new ExecutionFailureInfo(type, "[cyclic] " + throwable.getMessage(), null, ImmutableList.of(), ImmutableList.of(), null, GENERIC_INTERNAL_ERROR.toErrorCode(), remoteHost);
    }
    seenFailures.add(throwable);
    ExecutionFailureInfo cause = toFailure(throwable.getCause(), seenFailures);
    ErrorCode errorCode = toErrorCode(throwable);
    if (errorCode == null) {
        if (cause == null) {
            errorCode = GENERIC_INTERNAL_ERROR.toErrorCode();
        } else {
            errorCode = cause.getErrorCode();
        }
    }
    return new ExecutionFailureInfo(type, throwable.getMessage(), cause, Arrays.stream(throwable.getSuppressed()).map(failure -> toFailure(failure, seenFailures)).collect(toImmutableList()), Arrays.stream(throwable.getStackTrace()).map(Objects::toString).collect(toImmutableList()), getErrorLocation(throwable), errorCode, remoteHost);
}
Also used : TrinoTransportException(io.trino.spi.TrinoTransportException) Objects(java.util.Objects) ErrorCode(io.trino.spi.ErrorCode) StandardErrorCode(io.trino.spi.StandardErrorCode) HostAddress(io.trino.spi.HostAddress) Failure(io.trino.execution.Failure) ExecutionFailureInfo(io.trino.execution.ExecutionFailureInfo)

Aggregations

ExecutionFailureInfo (io.trino.execution.ExecutionFailureInfo)6 ErrorCode (io.trino.spi.ErrorCode)3 TrinoException (io.trino.spi.TrinoException)3 BasicQueryInfo (io.trino.server.BasicQueryInfo)2 MoreFutures.asVoid (io.airlift.concurrent.MoreFutures.asVoid)1 FailureInfo (io.trino.client.FailureInfo)1 QueryError (io.trino.client.QueryError)1 Failure (io.trino.execution.Failure)1 QueryInfo (io.trino.execution.QueryInfo)1 QueryState (io.trino.execution.QueryState)1 RemoteTask (io.trino.execution.RemoteTask)1 TaskId (io.trino.execution.TaskId)1 TaskState (io.trino.execution.TaskState)1 MemoryRequirements (io.trino.execution.scheduler.PartitionMemoryEstimator.MemoryRequirements)1 HostAddress (io.trino.spi.HostAddress)1 StandardErrorCode (io.trino.spi.StandardErrorCode)1 TrinoTransportException (io.trino.spi.TrinoTransportException)1 Objects (java.util.Objects)1 Test (org.testng.annotations.Test)1