com.google.api.client.http.HttpRequest.setIOExceptionHandler()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中com.google.api.client.http.HttpRequest.setIOExceptionHandler()方法的一些代码示例,展示了HttpRequest.setIOExceptionHandler()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.setIOExceptionHandler()方法的具体详情如下:
包路径:com.google.api.client.http.HttpRequest
类名称:HttpRequest
方法名:setIOExceptionHandler

HttpRequest.setIOExceptionHandler介绍

暂无

代码示例

代码示例来源:origin: GoogleCloudPlatform/java-docs-samples

request.setIOExceptionHandler(
  new HttpBackOffIOExceptionHandler(new ExponentialBackOff()).setSleeper(sleeper));

代码示例来源:origin: stackoverflow.com

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()));
 }
});

代码示例来源:origin: stackoverflow.com

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()));
 }
});

代码示例来源:origin: com.google.api-client/google-api-client

/**
 * 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);
}

代码示例来源:origin: com.google.enterprise.cloudsearch/google-cloudsearch-connector-sdk

/** 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));
 }
}

代码示例来源:origin: GoogleCloudPlatform/bigdata-interop

if (request.getIOExceptionHandler() != null) {
  ioExceptionHandlers.add(request.getIOExceptionHandler());
  request.setIOExceptionHandler(null);
request.setIOExceptionHandler(
  makeIoExceptionHandler(ioExceptionHandlers));
request.setUnsuccessfulResponseHandler(

代码示例来源:origin: com.google.cloud.bigdataoss/util

if (request.getIOExceptionHandler() != null) {
  ioExceptionHandlers.add(request.getIOExceptionHandler());
  request.setIOExceptionHandler(null);
request.setIOExceptionHandler(
  makeIoExceptionHandler(ioExceptionHandlers));
request.setUnsuccessfulResponseHandler(

代码示例来源:origin: com.google.cloud.bigdataoss/util

@Override
 public void initialize(HttpRequest httpRequest) throws IOException {
  httpRequest.setIOExceptionHandler(
    new HttpBackOffIOExceptionHandler(new ExponentialBackOff()));
  httpRequest.setUnsuccessfulResponseHandler(
    new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()));
 }
}

代码示例来源:origin: GoogleCloudPlatform/bigdata-interop

@Override
 public void initialize(HttpRequest httpRequest) throws IOException {
  httpRequest.setIOExceptionHandler(
    new HttpBackOffIOExceptionHandler(new ExponentialBackOff()));
  httpRequest.setUnsuccessfulResponseHandler(
    new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()));
 }
}

代码示例来源:origin: com.google.cloud.genomics/google-genomics-utils

.setIOExceptionHandler(
  new HttpIOExceptionHandler() {

代码示例来源:origin: com.google.auth/google-auth-library-oauth2-http

request.setParser(new JsonObjectParser(jsonFactory));
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(new ExponentialBackOff()));
request.setUnsuccessfulResponseHandler(
  new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()).setBackOffRequired(

代码示例来源:origin: codice/ddf

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;
}

代码示例来源:origin: GoogleCloudPlatform/bigdata-interop

ImmutableSet.of(HttpStatus.SC_GONE, HttpStatus.SC_SERVICE_UNAVAILABLE));
request.setUnsuccessfulResponseHandler(loggingResponseHandler);
request.setIOExceptionHandler(loggingResponseHandler);

代码示例来源:origin: com.google.cloud.bigdataoss/util

ImmutableSet.of(HttpStatus.SC_GONE, HttpStatus.SC_SERVICE_UNAVAILABLE));
request.setUnsuccessfulResponseHandler(loggingResponseHandler);
request.setIOExceptionHandler(loggingResponseHandler);

代码示例来源:origin: org.apache.beam/beam-examples-java

/** 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));
 }
}

代码示例来源:origin: GoogleCloudPlatform/cloud-pubsub-samples-java

request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(
  new ExponentialBackOff()).setSleeper(sleeper));

代码示例来源:origin: GoogleCloudPlatform/cloud-pubsub-samples-java

request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(
  new ExponentialBackOff()).setSleeper(sleeper));

代码示例来源:origin: GoogleCloudPlatform/cloud-pubsub-samples-java

request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(
  new ExponentialBackOff()).setSleeper(sleeper));

代码示例来源:origin: GoogleCloudPlatform/cloud-pubsub-samples-java

request.setIOExceptionHandler(
    new HttpBackOffIOExceptionHandler(new ExponentialBackOff())
        .setSleeper(sleeper));

代码示例来源:origin: org.apache.beam/beam-sdks-java-extensions-google-cloud-platform-core

@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);
 }
}

相关文章