use of com.facebook.presto.thrift.api.udf.ThriftUdfServiceException in project presto by prestodb.
the class ThriftSqlFunctionExecutor method invokeUdfWithRetry.
private static CompletableFuture<ThriftUdfResult> invokeUdfWithRetry(ThriftUdfService thriftUdfService, ThriftUdfRequest request) {
CompletableFuture<ThriftUdfResult> resultFuture = invokeUdf(thriftUdfService, request);
for (int i = 0; i < DEFAULT_RETRY_ATTEMPTS; i++) {
resultFuture = resultFuture.thenApply(CompletableFuture::completedFuture).exceptionally(t -> {
Throwable e = t.getCause();
if (e instanceof PrestoException) {
throw (PrestoException) e;
}
if (e instanceof ThriftUdfServiceException && ((ThriftUdfServiceException) e).isRetryable()) {
return invokeUdf(thriftUdfService, request);
}
PrestoException prestoException = e instanceof ThriftUdfServiceException ? toPrestoException((ThriftUdfServiceException) e) : new PrestoException(GENERIC_INTERNAL_ERROR, e);
throw prestoException;
}).thenCompose(identity());
}
return resultFuture;
}
use of com.facebook.presto.thrift.api.udf.ThriftUdfServiceException in project presto by prestodb.
the class ExceptionUtils method toPrestoException.
public static PrestoException toPrestoException(ThriftUdfServiceException thriftException) {
ThriftUdfServiceException exception = formatException(thriftException);
PrestoException prestoException = new PrestoException(toThriftUdfErrorCodeSupplier(thriftException.getErrorCode()), exception);
return prestoException;
}
Aggregations