本文整理汇总了Java中org.apache.http.client.ServiceUnavailableRetryStrategy类的典型用法代码示例。如果您正苦于以下问题:Java ServiceUnavailableRetryStrategy类的具体用法?Java ServiceUnavailableRetryStrategy怎么用?Java ServiceUnavailableRetryStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceUnavailableRetryStrategy类属于org.apache.http.client包,在下文中一共展示了ServiceUnavailableRetryStrategy类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AutoRetryHttpClient
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
public AutoRetryHttpClient(
final HttpClient client, final ServiceUnavailableRetryStrategy retryStrategy) {
super();
if (client == null) {
throw new IllegalArgumentException("HttpClient may not be null");
}
if (retryStrategy == null) {
throw new IllegalArgumentException(
"ServiceUnavailableRetryStrategy may not be null");
}
this.backend = client;
this.retryStrategy = retryStrategy;
}
示例2: ServiceUnavailableRetryExec
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
public ServiceUnavailableRetryExec(
final ClientExecChain requestExecutor,
final ServiceUnavailableRetryStrategy retryStrategy) {
super();
Args.notNull(requestExecutor, "HTTP request executor");
Args.notNull(retryStrategy, "Retry strategy");
this.requestExecutor = requestExecutor;
this.retryStrategy = retryStrategy;
}
示例3: AutoRetryHttpClient
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
public AutoRetryHttpClient(
final HttpClient client, final ServiceUnavailableRetryStrategy retryStrategy) {
super();
Args.notNull(client, "HttpClient");
Args.notNull(retryStrategy, "ServiceUnavailableRetryStrategy");
this.backend = client;
this.retryStrategy = retryStrategy;
}
示例4: getHttpClientBuilder
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
public static HttpClientBuilder getHttpClientBuilder(final String charset, String proxyIp,
int proxyPort) {
HttpClientBuilder builder = HttpClients.custom();
Charset chartset = charset == null ? Charset.forName(CHARSET_UTF8)
: Charset.forName(charset);
ConnectionConfig.Builder connBuilder = ConnectionConfig.custom().setCharset(chartset);
RequestConfig.Builder reqBuilder = RequestConfig.custom();
reqBuilder.setExpectContinueEnabled(false);
reqBuilder.setSocketTimeout(10 * 60 * 1000);
reqBuilder.setConnectTimeout(10 * 60 * 1000);
reqBuilder.setMaxRedirects(10);
if (StringUtils.isNotBlank(proxyIp) && proxyPort > 0) {
logger.info("using proxy {}:{} to request ", proxyIp, String.valueOf(proxyPort));
HttpHost proxy = new HttpHost(proxyIp, proxyPort);
reqBuilder.setProxy(proxy);
}
ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy = new DefaultServiceUnavailableRetryStrategy(
3, 3000);
builder.setServiceUnavailableRetryStrategy(serviceUnavailableRetryStrategy);
// 模拟浏览器,解决一些服务器程序只允许浏览器访问的问题
builder.setUserAgent(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0");
builder.setDefaultRequestConfig(reqBuilder.build());
builder.setDefaultConnectionConfig(connBuilder.build());
builder.setConnectionManager(getConnectionManager());
// HostnameVerifier allowAllHostnameVerifier =
// NoopHostnameVerifier.INSTANCE;
// builder.setSSLHostnameVerifier(allowAllHostnameVerifier);
return builder;
}
示例5: getServiceUnavailableRetryStrategy
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
public ServiceUnavailableRetryStrategy getServiceUnavailableRetryStrategy() {
return this.serviceUnavailableRetryStrategy;
}
示例6: setServiceUnavailableRetryStrategy
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
public void setServiceUnavailableRetryStrategy(final ServiceUnavailableRetryStrategy serviceUnavailableRetryStrategy) {
this.serviceUnavailableRetryStrategy = serviceUnavailableRetryStrategy;
}
示例7: setServiceUnavailableRetryStrategy
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
/**
* Assigns {@link ServiceUnavailableRetryStrategy} instance.
*/
public final HttpClientBuilder setServiceUnavailableRetryStrategy(
final ServiceUnavailableRetryStrategy serviceUnavailStrategy) {
this.serviceUnavailStrategy = serviceUnavailStrategy;
return this;
}
示例8: getServiceUnavailableRetryStrategy
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
@Override
protected ServiceUnavailableRetryStrategy getServiceUnavailableRetryStrategy() {
return new OctaneUnauthorizedRetryStrategy();
}
示例9: getServiceUnavailableRetryStrategy
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
@Override
protected ServiceUnavailableRetryStrategy getServiceUnavailableRetryStrategy() {
return new TooManyRequestsRetryStrategy("X-Rate-Limit-Reset");
}
示例10: getServiceUnavailableRetryStrategy
import org.apache.http.client.ServiceUnavailableRetryStrategy; //导入依赖的package包/类
protected ServiceUnavailableRetryStrategy getServiceUnavailableRetryStrategy() {
return null;
}