Search in sources :

Example 1 with Failure

use of io.trino.execution.Failure 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)1 Failure (io.trino.execution.Failure)1 ErrorCode (io.trino.spi.ErrorCode)1 HostAddress (io.trino.spi.HostAddress)1 StandardErrorCode (io.trino.spi.StandardErrorCode)1 TrinoTransportException (io.trino.spi.TrinoTransportException)1 Objects (java.util.Objects)1