use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.
the class FailedDispatchQueryFactory method createFailedDispatchQuery.
public FailedDispatchQuery createFailedDispatchQuery(Session session, String query, Optional<ResourceGroupId> resourceGroup, Throwable throwable) {
ExecutionFailureInfo failure = toFailure(throwable);
FailedDispatchQuery failedDispatchQuery = new FailedDispatchQuery(session, query, locationFactory.createQueryLocation(session.getQueryId()), resourceGroup, failure, executor);
BasicQueryInfo queryInfo = failedDispatchQuery.getBasicQueryInfo();
queryMonitor.queryCreatedEvent(queryInfo);
queryMonitor.queryImmediateFailureEvent(queryInfo, failure);
return failedDispatchQuery;
}
use of com.facebook.presto.execution.ExecutionFailureInfo 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);
}
use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.
the class PrestoSparkExecutionExceptionFactory method toPrestoSparkExecutionException.
public PrestoSparkExecutionException toPrestoSparkExecutionException(Throwable throwable) {
ExecutionFailureInfo failureInfo = toFailure(throwable);
byte[] serialized = codec.toJsonBytes(failureInfo);
byte[] compressed = compress(serialized);
String encodedExecutionFailureInfo = Base64.getEncoder().encodeToString(compressed);
if (isRetryable(failureInfo)) {
return new PrestoSparkRetryableExecutionException(throwable.getMessage(), encodedExecutionFailureInfo, throwable);
} else {
return new PrestoSparkNonRetryableExecutionException(throwable.getMessage(), encodedExecutionFailureInfo, throwable);
}
}
use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.
the class PrestoSparkExecutionExceptionFactory method extractExecutionFailureInfo.
private Optional<ExecutionFailureInfo> extractExecutionFailureInfo(String message) {
Matcher matcher = PATTERN.matcher(message);
if (matcher.matches()) {
String encodedFailureInfo = matcher.group(1);
byte[] decoded = Base64.getDecoder().decode(encodedFailureInfo);
byte[] decompressed = decompress(decoded);
ExecutionFailureInfo failureInfo = codec.fromJson(decompressed);
return Optional.of(failureInfo);
}
return Optional.empty();
}
use of com.facebook.presto.execution.ExecutionFailureInfo in project presto by prestodb.
the class TestPrestoSparkExecutionExceptionFactory method testRoundTrip.
@Test
public void testRoundTrip() {
String causeMessage = "cause message";
IOException cause = new IOException(causeMessage);
String suppressedMessage = "suppressed message";
IllegalArgumentException suppressed = new IllegalArgumentException(suppressedMessage);
String message = "presto exception message";
PrestoException prestoException = new PrestoException(NOT_SUPPORTED, message, cause);
prestoException.addSuppressed(suppressed);
PrestoSparkExecutionException executionException = factory.toPrestoSparkExecutionException(prestoException);
Optional<ExecutionFailureInfo> failure = factory.extractExecutionFailureInfo(executionException);
assertTrue(failure.isPresent());
assertFailure(failure.get().toFailure(), prestoException);
ExceptionFailure exceptionFailure = new ExceptionFailure(executionException, asScalaBuffer(ImmutableList.of()));
SparkException sparkException = new SparkException(SPARK_EXCEPTION_STRING + exceptionFailure.toErrorString());
failure = factory.extractExecutionFailureInfo(sparkException);
assertTrue(failure.isPresent());
assertFailure(failure.get().toFailure(), prestoException);
}
Aggregations