request.setIOExceptionHandler( new HttpBackOffIOExceptionHandler(new ExponentialBackOff()).setSleeper(sleeper));
youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { credential.initialize(request); request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff())); } });
youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpRequestInitializer() { @Override public void initialize(HttpRequest request) throws IOException { credential.initialize(request); request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff())); } });
/** * Constructs a new instance from {@link MediaHttpUploader} and {@link HttpRequest}. */ public MediaUploadErrorHandler(MediaHttpUploader uploader, HttpRequest request) { this.uploader = Preconditions.checkNotNull(uploader); originalIOExceptionHandler = request.getIOExceptionHandler(); originalUnsuccessfulHandler = request.getUnsuccessfulResponseHandler(); request.setIOExceptionHandler(this); request.setUnsuccessfulResponseHandler(this); }
/** Initialize {@link HttpRequest} to setup exponential back off and automatic retries. */ @Override public void initialize(HttpRequest request) throws IOException { BackOff backOff = new ExponentialBackOff(); request.setUnsuccessfulResponseHandler(new LoggingResponseHandler(retryPolicy, backOff)); request.setIOExceptionHandler(new LoggingIOExceptionHandler(backOff)); } }
if (request.getIOExceptionHandler() != null) { ioExceptionHandlers.add(request.getIOExceptionHandler()); request.setIOExceptionHandler(null); request.setIOExceptionHandler( makeIoExceptionHandler(ioExceptionHandlers)); request.setUnsuccessfulResponseHandler(
if (request.getIOExceptionHandler() != null) { ioExceptionHandlers.add(request.getIOExceptionHandler()); request.setIOExceptionHandler(null); request.setIOExceptionHandler( makeIoExceptionHandler(ioExceptionHandlers)); request.setUnsuccessfulResponseHandler(
@Override public void initialize(HttpRequest httpRequest) throws IOException { httpRequest.setIOExceptionHandler( new HttpBackOffIOExceptionHandler(new ExponentialBackOff())); httpRequest.setUnsuccessfulResponseHandler( new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff())); } }
@Override public void initialize(HttpRequest httpRequest) throws IOException { httpRequest.setIOExceptionHandler( new HttpBackOffIOExceptionHandler(new ExponentialBackOff())); httpRequest.setUnsuccessfulResponseHandler( new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff())); } }
.setIOExceptionHandler( new HttpIOExceptionHandler() {
request.setParser(new JsonObjectParser(jsonFactory)); request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff())); request.setUnsuccessfulResponseHandler( new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()).setBackOffRequired(
private HttpRequest generateHttpRequest( PropertyResolver propertyResolver, HttpTransport httpTransport) throws IOException { HttpRequest httpRequest = httpTransport .createRequestFactory() .buildGetRequest(new GenericUrl(propertyResolver.getResolvedString())); httpRequest.setUnsuccessfulResponseHandler( new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()) .setBackOffRequired(HttpBackOffUnsuccessfulResponseHandler.BackOffRequired.ALWAYS)); httpRequest.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff())); return httpRequest; }
ImmutableSet.of(HttpStatus.SC_GONE, HttpStatus.SC_SERVICE_UNAVAILABLE)); request.setUnsuccessfulResponseHandler(loggingResponseHandler); request.setIOExceptionHandler(loggingResponseHandler);
ImmutableSet.of(HttpStatus.SC_GONE, HttpStatus.SC_SERVICE_UNAVAILABLE)); request.setUnsuccessfulResponseHandler(loggingResponseHandler); request.setIOExceptionHandler(loggingResponseHandler);
/** Initializes the given request. */ @Override public final void initialize(final HttpRequest request) { request.setReadTimeout(2 * ONEMINITUES); // 2 minutes read timeout final HttpUnsuccessfulResponseHandler backoffHandler = new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()).setSleeper(sleeper); request.setInterceptor(wrappedCredential); request.setUnsuccessfulResponseHandler( (request1, response, supportsRetry) -> { if (wrappedCredential.handleResponse(request1, response, supportsRetry)) { // If credential decides it can handle it, the return code or message indicated // something specific to authentication, and no backoff is desired. return true; } else if (backoffHandler.handleResponse(request1, response, supportsRetry)) { // Otherwise, we defer to the judgement of our internal backoff handler. LOG.info("Retrying " + request1.getUrl().toString()); return true; } else { return false; } }); request.setIOExceptionHandler( new HttpBackOffIOExceptionHandler(new ExponentialBackOff()).setSleeper(sleeper)); } }
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler( new ExponentialBackOff()).setSleeper(sleeper));
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler( new ExponentialBackOff()).setSleeper(sleeper));
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler( new ExponentialBackOff()).setSleeper(sleeper));
request.setIOExceptionHandler( new HttpBackOffIOExceptionHandler(new ExponentialBackOff()) .setSleeper(sleeper));
@Override public void initialize(HttpRequest request) throws IOException { // Set a timeout for hanging-gets. // TODO: Do this exclusively for work requests. request.setReadTimeout(HANGING_GET_TIMEOUT_SEC * 1000); request.setWriteTimeout(this.writeTimeout); LoggingHttpBackOffHandler loggingHttpBackOffHandler = new LoggingHttpBackOffHandler( sleeper, // Back off on retryable http errors and IOExceptions. // A back-off multiplier of 2 raises the maximum request retrying time // to approximately 5 minutes (keeping other back-off parameters to // their default values). new ExponentialBackOff.Builder().setNanoClock(nanoClock).setMultiplier(2).build(), new ExponentialBackOff.Builder().setNanoClock(nanoClock).setMultiplier(2).build(), ignoredResponseCodes); request.setUnsuccessfulResponseHandler(loggingHttpBackOffHandler); request.setIOExceptionHandler(loggingHttpBackOffHandler); // Set response initializer if (responseInterceptor != null) { request.setResponseInterceptor(responseInterceptor); } }