@Override public <V> void onRetry(Attempt<V> attempt) { if (attempt.hasException()) { log.error("Error allocating slot", attempt.getExceptionCause()); } } })
@Override public <V> void onRetry(Attempt<V> attempt) { if (attempt.hasException()) { LOG.warn("Caught exception. This may be retried.", attempt.getExceptionCause()); Instrumented.markMeter(retryMeter); failedWrites++; } } });
@Override public <V> void onRetry(Attempt<V> attempt) { if (attempt.hasException()) { LOG.error("Caught exception during bulk indexing: {}, retrying (attempt #{}).", attempt.getExceptionCause(), attempt.getAttemptNumber()); } else if (attempt.getAttemptNumber() > 1) { LOG.info("Bulk indexing finally successful (attempt #{}).", attempt.getAttemptNumber()); } } })
/** * Gets the exception thrown by the call * * @return the exception thrown by the call * @throws IllegalStateException if the call didn't throw an exception, * as indicated by {@link #hasException()} */ public Throwable getException() throws IllegalStateException { checkState(hasException(), "The attempt resulted in a result, not in an exception"); return throwable; }
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions", "unchecked"}) @Override public long computeSleepTime(Attempt lastAttempt) { if (lastAttempt.hasException()) { Throwable cause = lastAttempt.getExceptionCause(); if (exceptionClass.isAssignableFrom(cause.getClass())) { return function.apply((T) cause); } } return 0L; } }
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions", "unchecked"}) @Override public long computeSleepTime(Attempt lastAttempt) { if (lastAttempt.hasException()) { Throwable cause = lastAttempt.getException(); if (exceptionClass.isAssignableFrom(cause.getClass())) { return function.apply((T) cause); } } return 0L; } }
@Override public <V> void onRetry(Attempt<V> attempt) { if (attempt.hasException()) { log.error("Error allocating slot", attempt.getExceptionCause()); } } })
@Override public boolean apply(Attempt<V> attempt) { if (!attempt.hasException()) { return false; } return exceptionClass.isAssignableFrom(attempt.getExceptionCause().getClass()); } }
@Override public boolean apply(Attempt<V> attempt) { if (!attempt.hasException()) { return false; } return delegate.apply(attempt.getExceptionCause()); } }
@Override public <V> void onRetry(Attempt<V> attempt) { if (attempt.hasException()) { LOG.info("Retrying to create queue in 61 seconds. {}", attempt.getExceptionCause().getMessage()); } } })
@Override public boolean test(Attempt<?> attempt) { return attempt.hasException() && delegate.test(attempt.getException()); } }
@Override public boolean test(Attempt<?> attempt) { return attempt.hasException() && exceptionClass.isAssignableFrom(attempt.getException().getClass()); } }
/** * If the last {@link Attempt} had an Exception, ensure it is available in * the stack trace. * * @param message Exception description to be added to the stack trace * @param attempt what happened the last time we failed */ private RetryException(String message, Attempt<?> attempt) { super(message, attempt.hasException() ? attempt.getException() : null); this.lastFailedAttempt = attempt; }
@Override public <V> void onRetry(Attempt<V> attempt) { if (attempt.hasException()) { LOG.warn("Caught exception. This may be retried.", attempt.getExceptionCause()); Instrumented.markMeter(retryMeter); failedWrites++; } } });
private static <T> void onRequestAttempt(Attempt<T> attempt) { if (attempt.hasException()) { log.warn("Failed request attempt {}", attempt.getAttemptNumber(), attempt.getExceptionCause()); } }
private <V> void onRestorePollPodsAttempt(Attempt<V> attempt) { if (attempt.hasException()) { LOG.warn("restore: failed polling pods, attempt = {}", attempt.getAttemptNumber(), attempt.getExceptionCause()); } }
@Override public <V> void onRetry(Attempt<V> attempt) { if (attempt.hasException()) { LOG.error("Caught exception during bulk indexing: {}, retrying (attempt #{}).", attempt.getExceptionCause(), attempt.getAttemptNumber()); } else if (attempt.getAttemptNumber() > 1) { LOG.info("Bulk indexing finally successful (attempt #{}).", attempt.getAttemptNumber()); } } })
private byte[] retrieveBytes(String url) { MutableInt retry = new MutableInt(0); try { return retryer.call(() -> request(url, retry)); } catch (ExecutionException e) { throw Throwables.propagate(e.getCause()); } catch (RetryException e) { if (e.getLastFailedAttempt().hasException()) { throw new RuntimeException("Max retries exceeded", e.getLastFailedAttempt().getExceptionCause()); } else { throw new RuntimeException("Max retries exceeded", e); } } }
private void assertExceptionAttempt(Attempt actualAttempt, Class<?> expectedExceptionClass) { assertFalse(actualAttempt.hasResult()); assertTrue(actualAttempt.hasException()); assertTrue(expectedExceptionClass.isInstance(actualAttempt.getException())); }
private void assertResultAttempt(Attempt actualAttempt, Object expectedResult) { assertFalse(actualAttempt.hasException()); assertTrue(actualAttempt.hasResult()); assertEquals(expectedResult, actualAttempt.getResult()); }