org.apache.http.client.ServiceUnavailableRetryStrategy Java Examples
The following examples show how to use
org.apache.http.client.ServiceUnavailableRetryStrategy.
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: HttpClientUtil.java From ATest with GNU General Public License v3.0 | 6 votes |
public static CloseableHttpClient getHttpClient(final int executionCount, int retryInterval) { ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy = new MyServiceUnavailableRetryStrategy.Builder() .executionCount(executionCount).retryInterval(retryInterval).build(); return HttpClientBuilder.create().setRetryHandler(new HttpRequestRetryHandler() { @Override public boolean retryRequest(IOException e, int count, HttpContext contr) { if (count >= executionCount) { // Do not retry if over max retry count return false; } if (e instanceof InterruptedIOException) { // Timeout return true; } return true; } }).setServiceUnavailableRetryStrategy(serviceUnavailableRetryStrategy) .setConnectionManager(new PoolingHttpClientConnectionManager()).build(); }
Example #2
Source File: HttpClientUtil.java From ATest with GNU General Public License v3.0 | 6 votes |
public static CloseableHttpClient getHttpClient(final int executionCount, int retryInterval) { ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy = new MyServiceUnavailableRetryStrategy.Builder() .executionCount(executionCount).retryInterval(retryInterval).build(); return HttpClientBuilder.create().setRetryHandler(new HttpRequestRetryHandler() { @Override public boolean retryRequest(IOException e, int count, HttpContext contr) { if (count >= executionCount) { // Do not retry if over max retry count return false; } if (e instanceof InterruptedIOException) { // Timeout return true; } return true; } }).setServiceUnavailableRetryStrategy(serviceUnavailableRetryStrategy) .setConnectionManager(new PoolingHttpClientConnectionManager()).build(); }
Example #3
Source File: HttpUtils.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static synchronized CloseableHttpClient getClient() { if (HttpUtils.client == null) { HttpUtils.client = HttpClientBuilder.create() .setConnectionManager(new PoolingHttpClientConnectionManager()) .setServiceUnavailableRetryStrategy(new ServiceUnavailableRetryStrategy() { private int interval = 1; @Override // retry at most 4 times if a 5xx status code is received, or no status line is present public boolean retryRequest(final HttpResponse resp, final int executionCount, final HttpContext context) { if (executionCount > 4) { return false; } if (resp.getStatusLine() == null) { return true; } final int statusCode = resp.getStatusLine().getStatusCode(); return 500 <= statusCode && statusCode < 600; } @Override public long getRetryInterval() { final int retryInterval = interval; interval *= 2; return retryInterval; } }) .build(); } return HttpUtils.client; }
Example #4
Source File: SimpleHttpClientFactoryBean.java From springboot-shiro-cas-mybatis with MIT License | 4 votes |
public ServiceUnavailableRetryStrategy getServiceUnavailableRetryStrategy() { return this.serviceUnavailableRetryStrategy; }
Example #5
Source File: SimpleHttpClientFactoryBean.java From springboot-shiro-cas-mybatis with MIT License | 4 votes |
public void setServiceUnavailableRetryStrategy(final ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy) { this.serviceUnavailableRetryStrategy = serviceUnavailableRetryStrategy; }
Example #6
Source File: HttpClientFactory.java From multiapps-controller with Apache License 2.0 | 4 votes |
private ServiceUnavailableRetryStrategy createServiceUnavailableRetryStrategy() { return new DefaultServiceUnavailableRetryStrategy(3, 2000); }
Example #7
Source File: ShutdownClientFactory.java From multiapps-controller with Apache License 2.0 | 4 votes |
private ServiceUnavailableRetryStrategy createServiceUnavailableRetryStrategy() { return new DefaultServiceUnavailableRetryStrategy(RETRY_COUNT, RETRY_INTERVAL_IN_MILLIS); }
Example #8
Source File: OctaneAuthenticatingRestConnection.java From FortifyBugTrackerUtility with MIT License | 4 votes |
@Override protected ServiceUnavailableRetryStrategy getServiceUnavailableRetryStrategy() { return new OctaneUnauthorizedRetryStrategy(); }
Example #9
Source File: CommonsDataLoader.java From dss with GNU Lesser General Public License v2.1 | 4 votes |
public void setServiceUnavailableRetryStrategy(final ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy) { this.serviceUnavailableRetryStrategy = serviceUnavailableRetryStrategy; }