Java 类org.apache.http.impl.conn.tsccm.ConnPoolByRoute 实例源码

项目:jets3t-aws-roles    文件:RestUtils.java   
@Override
protected AbstractConnPool createConnectionPool(final HttpParams params) {
    // Set the maximum connections per host for the HTTP connection manager,
    // *and* also set the maximum number of total connections (new in 0.7.1).
    // The max connections per host setting is made the same value as the max
    // global connections if there is no per-host property.
    Jets3tProperties props = (Jets3tProperties) params.getParameter(
            Jets3tProperties.JETS3T_PROPERTIES_ID);
    int maxConn = 20;
    int maxConnectionsPerHost = 0;
    if (props != null) {
        maxConn = props.getIntProperty("httpclient.max-connections", 20);
        maxConnectionsPerHost = props.getIntProperty(
                "httpclient.max-connections-per-host",
                0);
    }
    if (maxConnectionsPerHost == 0) {
        maxConnectionsPerHost = maxConn;
    }
    connPerRoute.setDefaultMaxPerRoute(maxConnectionsPerHost);
    return new ConnPoolByRoute(connOperator, connPerRoute, maxConn);
}
项目:pentaho-s3-vfs    文件:S3IT.java   
@Test
@SuppressWarnings( "unchecked" )
public void testConnectionsLeak() throws Exception {
  Field fPool = ThreadSafeClientConnManager.class.getDeclaredField( "pool" );
  Object ob = service.getHttpConnectionManager();
  fPool.setAccessible( true );
  ConnPoolByRoute pool = (ConnPoolByRoute) fPool.get( ob );
  fPool.setAccessible( false );

  Field fLeasedConnections = ConnPoolByRoute.class.getDeclaredField( "leasedConnections" );
  fLeasedConnections.setAccessible( true );
  Set<BasicPoolEntry> set = (Set<BasicPoolEntry>) fLeasedConnections.get( pool );
  fLeasedConnections.setAccessible( false );

  int connections = pool.getConnectionsInPool();

  assertTrue(
    "Http connections leak was found. Check either unclosed streams in test methods or incorrect using S3FileObject"
      + ".getS3Object. Pool size is 10. Connections in pool=" + connections + "leasedConnections=" + set.size(),
    set.size() == 0 );
}
项目:ribbon    文件:MonitoredConnectionManager.java   
@Override
protected ConnPoolByRoute createConnectionPool(long connTTL,
        TimeUnit connTTLTimeUnit) {
    return new NamedConnectionPool(connOperator, connPerRoute, 20, connTTL, connTTLTimeUnit);
}
项目:ribbon    文件:MonitoredConnectionManager.java   
@VisibleForTesting
ConnPoolByRoute getConnectionPool() {
    return this.pool;
}
项目:cougar    文件:CougarClientConnManager.java   
@Override
protected ConnPoolByRoute createConnectionPool(long connTTL, TimeUnit connTTLTimeUnit) {
    return new CougarConnPoolByRoute(connOperator, connPerRoute, TOTAL_CONNECTIONS, connTTL, connTTLTimeUnit);
}