com.google.api.client.http.HttpIOExceptionHandler Java Examples

The following examples show how to use com.google.api.client.http.HttpIOExceptionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChainingHttpRequestInitializer.java    From hadoop-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(HttpRequest request) throws IOException {
  List<HttpIOExceptionHandler> ioExceptionHandlers = new ArrayList<>();
  List<HttpUnsuccessfulResponseHandler> unsuccessfulResponseHandlers = new ArrayList<>();
  List<HttpExecuteInterceptor> interceptors = new ArrayList<>();
  List<HttpResponseInterceptor> responseInterceptors = new ArrayList<>();
  for (HttpRequestInitializer initializer : initializers) {
    initializer.initialize(request);
    if (request.getIOExceptionHandler() != null) {
      ioExceptionHandlers.add(request.getIOExceptionHandler());
      request.setIOExceptionHandler(null);
    }
    if (request.getUnsuccessfulResponseHandler() != null) {
      unsuccessfulResponseHandlers.add(request.getUnsuccessfulResponseHandler());
      request.setUnsuccessfulResponseHandler(null);
    }
    if (request.getInterceptor() != null) {
      interceptors.add(request.getInterceptor());
      request.setInterceptor(null);
    }
    if (request.getResponseInterceptor() != null) {
      responseInterceptors.add(request.getResponseInterceptor());
      request.setResponseInterceptor(null);
    }
  }
  request.setIOExceptionHandler(
      makeIoExceptionHandler(ioExceptionHandlers));
  request.setUnsuccessfulResponseHandler(
      makeUnsuccessfulResponseHandler(unsuccessfulResponseHandlers));
  request.setInterceptor(
      makeInterceptor(interceptors));
  request.setResponseInterceptor(
      makeResponseInterceptor(responseInterceptors));
}
 
Example #2
Source File: ChainingHttpRequestInitializer.java    From hadoop-connectors with Apache License 2.0 5 votes vote down vote up
private HttpIOExceptionHandler makeIoExceptionHandler(
    final Iterable<HttpIOExceptionHandler> ioExceptionHandlers) {
  return new HttpIOExceptionHandler() {
    @Override
    public boolean handleIOException(HttpRequest request, boolean supportsRetry)
        throws IOException {
      for (HttpIOExceptionHandler handler : ioExceptionHandlers) {
        if (handler.handleIOException(request, supportsRetry)) {
          return true;
        }
      }
      return false;
    }
  };
}
 
Example #3
Source File: RetryHttpInitializer.java    From hadoop-connectors with Apache License 2.0 5 votes vote down vote up
/**
 * @param delegateResponseHandler The HttpUnsuccessfulResponseHandler to invoke to really handle
 *     errors.
 * @param delegateIOExceptionHandler The HttpIOExceptionResponseHandler to delegate to.
 * @param responseCodesToLog The set of response codes to log URLs for.
 * @param responseCodesToLogWithRateLimit The set of response codes to log URLs for with reate
 *     limit.
 */
public LoggingResponseHandler(
    HttpUnsuccessfulResponseHandler delegateResponseHandler,
    HttpIOExceptionHandler delegateIOExceptionHandler,
    Set<Integer> responseCodesToLog,
    Set<Integer> responseCodesToLogWithRateLimit) {
  this.delegateResponseHandler = delegateResponseHandler;
  this.delegateIOExceptionHandler = delegateIOExceptionHandler;
  this.responseCodesToLog = ImmutableSet.copyOf(responseCodesToLog);
  this.responseCodesToLogWithRateLimit = ImmutableSet.copyOf(responseCodesToLogWithRateLimit);
}
 
Example #4
Source File: RetryInitializer.java    From firebase-admin-java with Apache License 2.0 4 votes vote down vote up
private HttpIOExceptionHandler newIOExceptionHandler() {
  return new HttpBackOffIOExceptionHandler(retryConfig.newBackOff())
      .setSleeper(retryConfig.getSleeper());
}
 
Example #5
Source File: ForceOAuthClient.java    From salesforce-jdbc with MIT License 4 votes vote down vote up
private HttpIOExceptionHandler buildIOExceptionHandler() {
    return new HttpBackOffIOExceptionHandler(getBackOff());
}