当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionPoolTimeoutException类代码示例

本文整理汇总了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);
        }

    };

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:PoolingClientConnectionManager.java

示例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);
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:ConnectionPoolMaxConnectionsIntegrationTest.java

示例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);
        }

    };

}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:24,代码来源:PoolingHttpClientConnectionManager.java

示例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");
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:20,代码来源:PoolingHttpClientConnectionManager.java

示例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);
        }

    };

}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:26,代码来源:JMeterPoolingClientConnectionManager.java

示例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);
        }

    };

}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:27,代码来源:PoolingHttpClientConnectionManager.java

示例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");
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:PoolingHttpClientConnectionManager.java

示例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);
    }
  };
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:21,代码来源:ElegantThreadSafeConnManager.java

示例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);
    }
  };
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:26,代码来源:ElegantThreadSafeConnManager.java

示例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);
}
 
开发者ID:lookwhatlook,项目名称:WeiboWeiBaTong,代码行数:17,代码来源:RetryRequestSample.java

示例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);
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:19,代码来源:GooglePlusService.java

示例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);
        }

    };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:ConnPoolByRoute.java

示例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);
        }

    };

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:ThreadSafeClientConnManager.java

示例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);
    }
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:39,代码来源:ConnectionPoolMaxConnectionsIntegrationTest.java

示例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);
        }

    };

}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:28,代码来源:PoolingClientConnectionManager.java


注:本文中的org.apache.http.conn.ConnectionPoolTimeoutException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。