@Override public RemotingOkHttpCall newCall(Request request) { return newCallWithMutableState(addRateLimitIdTag(request), backoffStrategyFactory.get(), MAX_NUM_RELOCATIONS); }
@Override public RemotingOkHttpCall newCall(Request request) { return newCallWithMutableState(addRateLimitIdTag(request), backoffStrategyFactory.get(), MAX_NUM_RELOCATIONS); }
@Override public void onFailure(Call call, IOException exception) { urls.markAsFailed(request().url()); // Fail call if backoffs are exhausted or if no retry URL can be determined. Optional<Duration> backoff = backoffStrategy.nextBackoff(); if (!backoff.isPresent()) { callback.onFailure(call, new IOException("Failed to complete the request due to an " + "IOException", exception)); return; } Optional<HttpUrl> redirectTo = urls.redirectToNext(request().url()); if (!redirectTo.isPresent()) { callback.onFailure(call, new IOException("Failed to determine valid failover URL for '" + request().url() + "' and base URLs " + urls.getBaseUrls())); return; } Request redirectedRequest = request().newBuilder() .url(redirectTo.get()) .build(); RemotingOkHttpCall retryCall = client.newCallWithMutableState(redirectedRequest, backoffStrategy, maxNumRelocations - 1); log.debug("Rescheduling call after backoff", SafeArg.of("backoffMillis", backoff.get().toMillis()), exception); scheduleExecution(() -> retryCall.enqueue(callback), backoff.get()); }
@Override public void onFailure(Call call, IOException exception) { urls.markAsFailed(request().url()); // Fail call if backoffs are exhausted or if no retry URL can be determined. Optional<Duration> backoff = backoffStrategy.nextBackoff(); if (!backoff.isPresent()) { callback.onFailure(call, new IOException("Failed to complete the request due to an " + "IOException", exception)); return; } Optional<HttpUrl> redirectTo = urls.redirectToNext(request().url()); if (!redirectTo.isPresent()) { callback.onFailure(call, new IOException("Failed to determine valid failover URL for '" + request().url() + "' and base URLs " + urls.getBaseUrls())); return; } Request redirectedRequest = request().newBuilder() .url(redirectTo.get()) .build(); RemotingOkHttpCall retryCall = client.newCallWithMutableState(redirectedRequest, backoffStrategy, maxNumRelocations - 1); log.debug("Rescheduling call after backoff", SafeArg.of("backoffMillis", backoff.get().toMillis()), exception); scheduleExecution(() -> retryCall.enqueue(callback), backoff.get()); }