Java 类com.google.api.client.http.HttpIOExceptionHandler 实例源码

项目:bigdata-interop    文件:ChainingHttpRequestInitializer.java   
@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));
}
项目:bigdata-interop    文件:ChainingHttpRequestInitializer.java   
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;
    }
  };
}
项目:bigdata-interop    文件:RetryHttpInitializer.java   
/**
 * @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.
 */
public LoggingResponseHandler(
    HttpUnsuccessfulResponseHandler delegateResponseHandler,
    HttpIOExceptionHandler delegateIOExceptionHandler,
    Set<Integer> responseCodesToLog) {
  this.delegateResponseHandler = delegateResponseHandler;
  this.delegateIOExceptionHandler = delegateIOExceptionHandler;
  this.responseCodesToLog = ImmutableSet.copyOf(responseCodesToLog);
}