Search in sources :

Example 1 with Failure

use of com.facebook.presto.execution.Failure in project presto by prestodb.

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 PrestoTransportException) {
        remoteHost = ((PrestoTransportException) 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()), Lists.transform(asList(throwable.getStackTrace()), toStringFunction()), getErrorLocation(throwable), errorCode, remoteHost);
}
Also used : ErrorCode(com.facebook.presto.spi.ErrorCode) StandardErrorCode(com.facebook.presto.spi.StandardErrorCode) HostAddress(com.facebook.presto.spi.HostAddress) PrestoTransportException(com.facebook.presto.spi.PrestoTransportException) Failure(com.facebook.presto.execution.Failure) ExecutionFailureInfo(com.facebook.presto.execution.ExecutionFailureInfo)

Aggregations

ExecutionFailureInfo (com.facebook.presto.execution.ExecutionFailureInfo)1 Failure (com.facebook.presto.execution.Failure)1 ErrorCode (com.facebook.presto.spi.ErrorCode)1 HostAddress (com.facebook.presto.spi.HostAddress)1 PrestoTransportException (com.facebook.presto.spi.PrestoTransportException)1 StandardErrorCode (com.facebook.presto.spi.StandardErrorCode)1