本文整理汇总了Java中org.apache.http.conn.ConnectionPoolTimeoutException类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionPoolTimeoutException类的具体用法?Java ConnectionPoolTimeoutException怎么用?Java ConnectionPoolTimeoutException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionPoolTimeoutException类属于org.apache.http.conn包,在下文中一共展示了ConnectionPoolTimeoutException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
public ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
if (route == null) {
throw new IllegalArgumentException("HTTP route may not be null");
}
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
final Future<HttpPoolEntry> future = this.pool.lease(route, state);
return new ClientConnectionRequest() {
public void abortRequest() {
future.cancel(true);
}
public ManagedClientConnection getConnection(
final long timeout,
final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
return leaseConnection(future, timeout, tunit);
}
};
}
示例2: leasing_a_new_connection_fails_with_connection_pool_timeout
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
@Test(timeout = 60 * 1000)
public void leasing_a_new_connection_fails_with_connection_pool_timeout()
throws Exception {
String localhostEndpoint = "http://localhost:" + server.getPort();
AmazonHttpClient httpClient = new AmazonHttpClient(
new ClientConfiguration()
.withMaxConnections(1)
.withConnectionTimeout(100)
.withMaxErrorRetry(0));
Request<?> request = new EmptyHttpRequest(localhostEndpoint, HttpMethodName.GET);
// Block the first connection in the pool with this request.
httpClient.requestExecutionBuilder().request(request).execute(new EmptyAWSResponseHandler());
try {
// A new connection will be leased here which would fail in
// ConnectionPoolTimeoutException.
httpClient.requestExecutionBuilder().request(request).execute();
Assert.fail("Connection pool timeout exception is expected!");
} catch (AmazonClientException e) {
Assert.assertTrue(e.getCause() instanceof ConnectionPoolTimeoutException);
}
}
示例3: requestConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
public ConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
Args.notNull(route, "HTTP route");
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Connection request: " + format(route, state) + formatStats(route));
}
final Future<CPoolEntry> future = this.pool.lease(route, state, null);
return new ConnectionRequest() {
public boolean cancel() {
return future.cancel(true);
}
public HttpClientConnection get(
final long timeout,
final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
return leaseConnection(future, timeout, tunit);
}
};
}
示例4: leaseConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
protected HttpClientConnection leaseConnection(
final Future<CPoolEntry> future,
final long timeout,
final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
final CPoolEntry entry;
try {
entry = future.get(timeout, tunit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
Asserts.check(entry.getConnection() != null, "Pool entry with no connection");
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Connection leased: " + format(entry) + formatStats(entry.getRoute()));
}
return CPoolProxy.newProxy(entry);
} catch (final TimeoutException ex) {
throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
}
}
示例5: requestConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
@Override
public ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
Args.notNull(route, "HTTP route");
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
final Future<HttpPoolEntry> future = this.pool.lease(route, state);
return new ClientConnectionRequest() {
@Override
public void abortRequest() {
future.cancel(true);
}
@Override
public ManagedClientConnection getConnection(
final long timeout,
final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
return leaseConnection(future, timeout, tunit);
}
};
}
示例6: requestConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
@Override
public ConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
Args.notNull(route, "HTTP route");
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
final Future<CPoolEntry> future = this.pool.lease(route, state, null);
return new ConnectionRequest() {
@Override
public boolean cancel() {
return future.cancel(true);
}
@Override
public HttpClientConnection get(
final long timeout,
final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
return leaseConnection(future, timeout, tunit);
}
};
}
示例7: leaseConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
protected HttpClientConnection leaseConnection(
final Future<CPoolEntry> future,
final long timeout,
final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
final CPoolEntry entry;
try {
entry = future.get(timeout, tunit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
Asserts.check(entry.getConnection() != null, "Pool entry with no connection");
if (this.log.isDebugEnabled()) {
this.log.debug("Connection leased: " + format(entry) + formatStats(entry.getRoute()));
}
return CPoolProxy.newProxy(entry);
} catch (final TimeoutException ex) {
throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool");
}
}
示例8: requestConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
public final ClientConnectionRequest requestConnection(final HttpRoute paramHttpRoute, Object paramObject)
{
new ClientConnectionRequest()
{
public final void abortRequest()
{
this.val$poolRequest.abortRequest();
}
public final ManagedClientConnection getConnection(long paramAnonymousLong, TimeUnit paramAnonymousTimeUnit)
throws InterruptedException, ConnectionPoolTimeoutException
{
if (paramHttpRoute == null) {
throw new IllegalArgumentException("Route may not be null.");
}
BasicPoolEntry localBasicPoolEntry = this.val$poolRequest.getPoolEntry(paramAnonymousLong, paramAnonymousTimeUnit);
return new ElegantThreadSafeConnManager.ElegantBasicPooledConnAdapter(ElegantThreadSafeConnManager.this, localBasicPoolEntry);
}
};
}
示例9: requestPoolEntry
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
public final PoolEntryRequest requestPoolEntry(final HttpRoute paramHttpRoute, final Object paramObject)
{
new PoolEntryRequest()
{
public final void abortRequest()
{
ElegantThreadSafeConnManager.ElegantPool.this.poolLock.lock();
try
{
this.val$aborter.abort();
return;
}
finally
{
ElegantThreadSafeConnManager.ElegantPool.this.poolLock.unlock();
}
}
public final BasicPoolEntry getPoolEntry(long paramAnonymousLong, TimeUnit paramAnonymousTimeUnit)
throws InterruptedException, ConnectionPoolTimeoutException
{
return ElegantThreadSafeConnManager.ElegantPool.this.getEntryBlocking(paramHttpRoute, paramObject, paramAnonymousLong, paramAnonymousTimeUnit, this.val$aborter);
}
};
}
示例10: onCreate
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The following exceptions will be whitelisted, i.e.: When an exception
// of this type is raised, the request will be retried.
AsyncHttpClient.allowRetryExceptionClass(IOException.class);
AsyncHttpClient.allowRetryExceptionClass(SocketTimeoutException.class);
AsyncHttpClient.allowRetryExceptionClass(ConnectTimeoutException.class);
// The following exceptions will be blacklisted, i.e.: When an exception
// of this type is raised, the request will not be retried and it will
// fail immediately.
AsyncHttpClient.blockRetryExceptionClass(UnknownHostException.class);
AsyncHttpClient.blockRetryExceptionClass(ConnectionPoolTimeoutException.class);
}
示例11: handleException
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
private void handleException(String message, Exception e, User user) {
if (e instanceof HttpClientErrorException) {
String responseBody = ((HttpClientErrorException) e).getResponseBodyAsString();
// if unauthorized
if (((HttpClientErrorException) e).getStatusCode() == HttpStatus.UNAUTHORIZED) {
logger.info("Auth problem with user " + user + ". Resetting token. The problem is due to exception: " + e.getMessage() + "; Response body: " + responseBody);
user.getGooglePlusSettings().setDisconnectReason(e.getMessage());
helper.forciblyDisconnect(this, user);
} else {
logger.warn(message + ": " + e.getMessage() + " : " + ExceptionUtils.getRootCauseMessage(e) + "; Response body: " + responseBody);
}
} else if (e.getCause() instanceof ConnectionPoolTimeoutException || e.getCause() instanceof SocketTimeoutException) {
logger.warn("Google+ timeout (for user: " + user + ") " + ExceptionUtils.getRootCauseMessage(e));
} else {
logger.warn(message, e);
}
}
示例12: requestPoolEntry
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
@Override
public PoolEntryRequest requestPoolEntry(
final HttpRoute route,
final Object state) {
final WaitingThreadAborter aborter = new WaitingThreadAborter();
return new PoolEntryRequest() {
public void abortRequest() {
poolLock.lock();
try {
aborter.abort();
} finally {
poolLock.unlock();
}
}
public BasicPoolEntry getPoolEntry(
long timeout,
TimeUnit tunit)
throws InterruptedException, ConnectionPoolTimeoutException {
return getEntryBlocking(route, state, timeout, tunit, aborter);
}
};
}
示例13: requestConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
public ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
final PoolEntryRequest poolRequest = pool.requestPoolEntry(
route, state);
return new ClientConnectionRequest() {
public void abortRequest() {
poolRequest.abortRequest();
}
public ManagedClientConnection getConnection(
long timeout, TimeUnit tunit) throws InterruptedException,
ConnectionPoolTimeoutException {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
if (log.isDebugEnabled()) {
log.debug("Get connection: " + route + ", timeout = " + timeout);
}
BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, tunit);
return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this, entry);
}
};
}
示例14: leasing_a_new_connection_fails_with_connection_pool_timeout
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
@Test(timeout = 60 * 1000)
public void leasing_a_new_connection_fails_with_connection_pool_timeout() throws Exception {
String localhostEndpoint = "http://localhost:" + server.getPort();
AmazonHttpClient httpClient = HttpTestUtils.testClientBuilder()
.clientExecutionTimeout(null)
.retryPolicy(RetryPolicy.NONE)
.httpClient(ApacheSdkHttpClientFactory.builder()
.connectionTimeout(
Duration.ofMillis(100))
.maxConnections(1)
.build()
.createHttpClient())
.build();
Request<?> request = new EmptyHttpRequest(localhostEndpoint, HttpMethodName.GET);
// Block the first connection in the pool with this request.
httpClient.requestExecutionBuilder()
.request(request)
.originalRequest(NoopTestAwsRequest.builder().build())
.executionContext(executionContext(SdkHttpFullRequestAdapter.toHttpFullRequest(request)))
.execute(new EmptyAWSResponseHandler());
try {
// A new connection will be leased here which would fail in
// ConnectionPoolTimeoutException.
httpClient.requestExecutionBuilder()
.request(request)
.originalRequest(NoopTestAwsRequest.builder().build())
.executionContext(executionContext(SdkHttpFullRequestAdapter.toHttpFullRequest(request)))
.execute();
Assert.fail("Connection pool timeout exception is expected!");
} catch (SdkClientException e) {
Assert.assertTrue(e.getCause() instanceof ConnectionPoolTimeoutException);
}
}
示例15: requestConnection
import org.apache.http.conn.ConnectionPoolTimeoutException; //导入依赖的package包/类
@Override
public ClientConnectionRequest requestConnection(
final HttpRoute route,
final Object state) {
Args.notNull(route, "HTTP route");
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
final Future<HttpPoolEntry> future = this.pool.lease(route, state);
return new ClientConnectionRequest() {
@Override
public void abortRequest() {
future.cancel(true);
}
@Override
public ManagedClientConnection getConnection(
final long timeout,
final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
return leaseConnection(future, timeout, tunit);
}
};
}