@Override public void onFailure(Throwable t) { result.setException(unwrapUserException(t)); } },
return (context, headers) -> newProxy(clientInterface, new DriftInvocationHandler(serviceMetadata.getName(), methods, context, headers));
return (context, headers) -> newProxy(clientInterface, new DriftInvocationHandler(serviceMetadata.getName(), methods, context, headers));
@Override public void onFailure(Throwable t) { result.setException(unwrapUserException(t)); } },
return unwrapUserException(future); throw unwrapUserException(e.getCause());
return unwrapUserException(future); throw unwrapUserException(e.getCause());
public ExceptionClassification classifyException(Throwable throwable, boolean idempotent) { if (throwable instanceof ConnectionFailedException) { return new ExceptionClassification(Optional.of(TRUE), DOWN); } if (idempotent && throwable instanceof RequestTimeoutException) { // We don't know if the server is overloaded, or if this specific // request just takes to long, so just mark the server as normal. return new ExceptionClassification(Optional.of(TRUE), NORMAL); } if (throwable instanceof MessageTooLargeException) { return new ExceptionClassification(Optional.of(FALSE), NORMAL); } // interrupted exceptions are always an immediate failure if (throwable instanceof InterruptedException || throwable instanceof InterruptedIOException) { return new ExceptionClassification(Optional.of(FALSE), NORMAL); } // allow classifier to return a hard result ExceptionClassification result = exceptionClassifier.classifyException(unwrapUserException(throwable)); if (result.isRetry().isPresent()) { return result; } if (idempotent && throwable instanceof TTransportException) { // We don't know if there is a problem with this server or if this // is a general network error, so just mark the server as normal. return new ExceptionClassification(Optional.of(TRUE), NORMAL); } return result; }
public ExceptionClassification classifyException(Throwable throwable, boolean idempotent) { if (throwable instanceof ConnectionFailedException) { return new ExceptionClassification(Optional.of(TRUE), DOWN); } if (idempotent && throwable instanceof RequestTimeoutException) { // We don't know if the server is overloaded, or if this specific // request just takes to long, so just mark the server as normal. return new ExceptionClassification(Optional.of(TRUE), NORMAL); } if (throwable instanceof MessageTooLargeException) { return new ExceptionClassification(Optional.of(FALSE), NORMAL); } // interrupted exceptions are always an immediate failure if (throwable instanceof InterruptedException || throwable instanceof InterruptedIOException) { return new ExceptionClassification(Optional.of(FALSE), NORMAL); } // allow classifier to return a hard result ExceptionClassification result = exceptionClassifier.classifyException(unwrapUserException(throwable)); if (result.isRetry().isPresent()) { return result; } if (idempotent && throwable instanceof TTransportException) { // We don't know if there is a problem with this server or if this // is a general network error, so just mark the server as normal. return new ExceptionClassification(Optional.of(TRUE), NORMAL); } return result; }