本文整理汇总了Java中org.apache.http.pool.ConnPoolControl类的典型用法代码示例。如果您正苦于以下问题:Java ConnPoolControl类的具体用法?Java ConnPoolControl怎么用?Java ConnPoolControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnPoolControl类属于org.apache.http.pool包,在下文中一共展示了ConnPoolControl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: if
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
/**
* Returns a wrapped instance of {@link HttpClientConnectionManager}
* to capture the necessary performance metrics.
*
* @param orig the target instance to be wrapped
*/
public static HttpClientConnectionManager wrap
(HttpClientConnectionManager orig) {
if (orig instanceof Wrapped)
throw new IllegalArgumentException();
final Class<?>[] interfaces;
if (orig instanceof ConnPoolControl) {
interfaces = new Class<?>[]{
HttpClientConnectionManager.class,
ConnPoolControl.class,
Wrapped.class
};
} else {
interfaces = new Class<?>[]{
HttpClientConnectionManager.class,
Wrapped.class
};
}
return (HttpClientConnectionManager) Proxy.newProxyInstance(
// https://github.com/aws/aws-sdk-java/pull/48#issuecomment-29454423
ClientConnectionManagerFactory.class.getClassLoader(),
interfaces,
new Handler(orig));
}
示例2: clientInterruptedDuringResponseHandlers_DoesNotLeakConnection
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
/**
* Tests that a streaming operation has it's request properly cleaned up if the client is interrupted after the
* response is received.
*
* @see TT0070103230
*/
@Test
public void clientInterruptedDuringResponseHandlers_DoesNotLeakConnection() throws IOException {
ClientConfiguration config = new ClientConfiguration();
ConnectionManagerAwareHttpClient rawHttpClient = new ApacheHttpClientFactory().create(HttpClientSettings.adapt(config));
httpClient = new AmazonHttpClient(config, rawHttpClient, null);
interruptCurrentThreadAfterDelay(1000);
List<RequestHandler2> requestHandlers = RequestHandlerTestUtils
.buildRequestHandlerList(new SlowRequestHandler().withAfterResponseWaitInSeconds(10));
try {
requestBuilder().executionContext(withHandlers(requestHandlers)).execute(new DummyResponseHandler().leaveConnectionOpen());
fail("Expected exception");
} catch (AmazonClientException e) {
assertThat(e.getCause(), instanceOf(InterruptedException.class));
}
@SuppressWarnings("deprecation")
int leasedConnections = ((ConnPoolControl<?>) ((SdkHttpClient)rawHttpClient).getHttpClientConnectionManager()).getTotalStats().getLeased();
assertEquals(0, leasedConnections);
}
示例3: createHttpClient
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
public static AbstractHttpClient createHttpClient()
{
try
{
if (IS_HTTP_CLIENT_GE_4_2)
{
ClientConnectionManager poolingManager = (ClientConnectionManager) Class.forName(
"org.apache.http.impl.conn.PoolingClientConnectionManager").newInstance();
((ConnPoolControl<?>) poolingManager).setMaxTotal(DEFAULT_MAX_TOTAL);
((ConnPoolControl<?>) poolingManager).setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE);
return new DefaultHttpClient(poolingManager, (HttpParams) null);
} else {
return new ThreadSafeHttpClient();
}
}
catch (Exception e)
{
throw new IllegalStateException("Can not create http client.", e);
}
}
示例4: ApacheHttpClient441BackedHttpClient
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
public ApacheHttpClient441BackedHttpClient(String scheme,
String host,
int port,
OAuthSigner signer,
CloseableHttpClient client,
Closeable onClose,
ConnPoolControl<HttpRoute> connPoolControl,
Map<String, String> headersForEveryRequest) {
this.scheme = scheme;
this.host = host;
this.port = port;
this.oauthSigner = signer;
this.client = client;
this.onClose = onClose;
this.connPoolControl = connPoolControl;
this.headersForEveryRequest = headersForEveryRequest;
}
示例5: wrap
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
/**
* Returns a wrapped instance of {@link HttpClientConnectionManager}
* to capture the necessary performance metrics.
*
* @param orig the target instance to be wrapped
*/
public static HttpClientConnectionManager wrap(HttpClientConnectionManager orig) {
if (orig instanceof Wrapped) {
throw new IllegalArgumentException();
}
final Class<?>[] interfaces;
if (orig instanceof ConnPoolControl) {
interfaces = new Class<?>[]{
HttpClientConnectionManager.class,
ConnPoolControl.class,
Wrapped.class};
} else {
interfaces = new Class<?>[]{
HttpClientConnectionManager.class,
Wrapped.class
};
}
return (HttpClientConnectionManager) Proxy.newProxyInstance(
// https://github.com/aws/aws-sdk-java/pull/48#issuecomment-29454423
ClientConnectionManagerFactory.class.getClassLoader(),
interfaces,
new Handler(orig));
}
示例6: captureConnectionPoolMetrics
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
/**
* Captures the connection pool metrics.
*/
private void captureConnectionPoolMetrics() {
if (awsRequestMetrics.isEnabled() &&
httpClient.getHttpClientConnectionManager() instanceof
ConnPoolControl<?>) {
final PoolStats stats = ((ConnPoolControl<?>) httpClient
.getHttpClientConnectionManager()).getTotalStats();
awsRequestMetrics
.withCounter(HttpClientPoolAvailableCount, stats.getAvailable())
.withCounter(HttpClientPoolLeasedCount, stats.getLeased())
.withCounter(HttpClientPoolPendingCount, stats.getPending());
}
}
示例7: AIMDBackoffManager
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
AIMDBackoffManager(ConnPoolControl<HttpRoute> connPerRoute, Clock clock) {
this.clock = clock;
this.connPerRoute = connPerRoute;
this.lastRouteProbes = new HashMap<HttpRoute,Long>();
this.lastRouteBackoffs = new HashMap<HttpRoute,Long>();
}
示例8: HTTPCAsyncClientMonitor
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
public HTTPCAsyncClientMonitor(String poolName, ConnPoolControl<HttpRoute> pool) {
super(poolName, pool);
}
示例9: HTTPCClientMonitor
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
public HTTPCClientMonitor(String poolName, ConnPoolControl<HttpRoute> pool) {
this.poolName = poolName;
this.pool = pool;
this.future = HTTPCClientMonitorExecutor.pool.scheduleAtFixedRate(this, 5, 30, TimeUnit.SECONDS);
}
示例10: HTTPCSyncClientMonitor
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
public HTTPCSyncClientMonitor(String poolName, ConnPoolControl<HttpRoute> pool) {
super(poolName, pool);
}
示例11: AIMDBackoffManager
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
AIMDBackoffManager(final ConnPoolControl<HttpRoute> connPerRoute, final Clock clock) {
this.clock = clock;
this.connPerRoute = connPerRoute;
this.lastRouteProbes = new HashMap<HttpRoute,Long>();
this.lastRouteBackoffs = new HashMap<HttpRoute,Long>();
}
示例12: getConnPoolControl
import org.apache.http.pool.ConnPoolControl; //导入依赖的package包/类
/**
* Gets the {@link ConnPoolControl}.
*
* @return the {@link ConnPoolControl}
*/
public ConnPoolControl getConnPoolControl() {
return connPoolControl;
}