@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = exceptionToPolicyMap.get(e.getClass()); if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce); }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = null; // ignore Remote Exception if (e instanceof RemoteException) { // do nothing } else { policy = exceptionToPolicyMap.get(e.getClass()); } if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry( e, retries, failovers, isIdempotentOrAtMostOnce); } }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = null; if (e instanceof RemoteException) { policy = exceptionNameToPolicyMap.get( ((RemoteException) e).getClassName()); } if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce); } }
/** * Get time for next login retry. This will allow the thread to retry with * exponential back-off, until tgt endtime. * Last retry is {@link #kerberosMinSecondsBeforeRelogin} before endtime. * * @param tgtEndTime EndTime of the tgt. * @param now Current time. * @param rp The retry policy. * @return Time for next login retry. */ @VisibleForTesting static long getNextTgtRenewalTime(final long tgtEndTime, final long now, final RetryPolicy rp) throws Exception { final long lastRetryTime = tgtEndTime - kerberosMinSecondsBeforeRelogin; final RetryPolicy.RetryAction ra = rp.shouldRetry(null, metrics.renewalFailures.value(), 0, false); return Math.min(lastRetryTime, now + ra.delayMillis); }
action = connectionRetryPolicy.shouldRetry(ioe, curRetries, 0, true); } catch(Exception e) { throw e instanceof IOException? (IOException)e: new IOException(e);
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isMethodIdempotent) throws Exception { if (e instanceof ServiceException) { //unwrap ServiceException final Throwable cause = e.getCause(); if (cause != null && cause instanceof Exception) { e = (Exception)cause; } } //see (1) and (2) in the javadoc of this method. final RetryPolicy p; if (e instanceof RetriableException || RetryPolicies.getWrappedRetriableException(e) != null) { // RetriableException or RetriableException wrapped p = multipleLinearRandomRetry; } else if (e instanceof RemoteException) { final RemoteException re = (RemoteException)e; p = re.getClassName().equals(remoteExceptionToRetry) ? multipleLinearRandomRetry : RetryPolicies.TRY_ONCE_THEN_FAIL; } else if (e instanceof IOException || e instanceof ServiceException) { p = multipleLinearRandomRetry; } else { //non-IOException p = RetryPolicies.TRY_ONCE_THEN_FAIL; } LOG.debug("RETRY {}) policy={}", retries, p.getClass().getSimpleName(), e); return p.shouldRetry(e, retries, failovers, isMethodIdempotent); }
static RetryInfo newRetryInfo(RetryPolicy policy, Exception e, Counters counters, boolean idempotentOrAtMostOnce, long expectedFailoverCount) throws Exception { RetryAction max = null; long maxRetryDelay = 0; Exception ex = null; final Iterable<Exception> exceptions = e instanceof MultiException ? ((MultiException) e).getExceptions().values() : Collections.singletonList(e); for (Exception exception : exceptions) { final RetryAction a = policy.shouldRetry(exception, counters.retries, counters.failovers, idempotentOrAtMostOnce); if (a.action != RetryAction.RetryDecision.FAIL) { // must be a retry or failover if (a.delayMillis > maxRetryDelay) { maxRetryDelay = a.delayMillis; } } if (max == null || max.action.compareTo(a.action) < 0) { max = a; if (a.action == RetryAction.RetryDecision.FAIL) { ex = exception; } } } return new RetryInfo(maxRetryDelay, max, expectedFailoverCount, ex); }
action = retryPolicy.shouldRetry(ioe, 0, numFailovers, isIdempotent); } catch (Exception e) { if (e instanceof IOException) {
return fallbackPolicy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce);
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean idempotent) throws Exception { return idempotent ? next.shouldRetry(e, retries, failovers, true) : RetryAction.FAIL; }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { return e instanceof IOException ? next.shouldRetry(e, retries, failovers, true) : RetryAction.FAIL; } }
public boolean shouldRetry(Exception e, int retries) throws Exception { RetryPolicy policy = exceptionToPolicyMap.get(e.getClass()); if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries); }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = exceptionToPolicyMap.get(e.getClass()); if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce); }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = exceptionToPolicyMap.get(e.getClass()); if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce); }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = exceptionToPolicyMap.get(e.getClass()); if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce); }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = exceptionToPolicyMap.get(e.getClass()); if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce); }
public boolean shouldRetry(Exception e, int retries) throws Exception { RetryPolicy policy = exceptionToPolicyMap.get(e.getClass()); if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry(e, retries); }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = null; // ignore Remote Exception if (e instanceof RemoteException) { // do nothing } else { policy = exceptionToPolicyMap.get(e.getClass()); } if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry( e, retries, failovers, isIdempotentOrAtMostOnce); } }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = null; // ignore Remote Exception if (e instanceof RemoteException) { // do nothing } else { policy = exceptionToPolicyMap.get(e.getClass()); } if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry( e, retries, failovers, isIdempotentOrAtMostOnce); } }
@Override public RetryAction shouldRetry(Exception e, int retries, int failovers, boolean isIdempotentOrAtMostOnce) throws Exception { RetryPolicy policy = null; // ignore Remote Exception if (e instanceof RemoteException) { // do nothing } else { policy = exceptionToPolicyMap.get(e.getClass()); } if (policy == null) { policy = defaultPolicy; } return policy.shouldRetry( e, retries, failovers, isIdempotentOrAtMostOnce); } }