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

项目:FMTech    文件:ElegantThreadSafeConnManager.java   
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);
    }
  };
}
项目:FMTech    文件:ElegantThreadSafeConnManager.java   
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);
    }
  };
}
项目: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    文件:NamedConnectionPool.java   
@Override
protected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl, Object state) {
    BasicPoolEntry entry = super.getFreeEntry(rospl, state);
    if (entry != null) {
        freeEntryCounter.increment();
    }
    return entry;
}
项目:ribbon    文件:NamedConnectionPool.java   
@Override
protected BasicPoolEntry createEntry(RouteSpecificPool rospl,
        ClientConnectionOperator op) {
    createEntryCounter.increment();
    Stopwatch stopWatch = creationTimer.start();
    try {
        return super.createEntry(rospl, op);
    } finally {
        stopWatch.stop();
    }
}
项目:ribbon    文件:NamedConnectionPool.java   
@Override
protected BasicPoolEntry getEntryBlocking(HttpRoute route, Object state,
        long timeout, TimeUnit tunit, WaitingThreadAborter aborter)
        throws ConnectionPoolTimeoutException, InterruptedException {
    Stopwatch stopWatch = requestTimer.start();
    try {
        return super.getEntryBlocking(route, state, timeout, tunit, aborter);
    } finally {
        stopWatch.stop();
    }
}
项目:ribbon    文件:NamedConnectionPool.java   
@Override
public void freeEntry(BasicPoolEntry entry, boolean reusable,
        long validDuration, TimeUnit timeUnit) {
    releaseCounter.increment();
    super.freeEntry(entry, reusable, validDuration, timeUnit);
}
项目:ribbon    文件:NamedConnectionPool.java   
@Override
protected void deleteEntry(BasicPoolEntry entry) {
    deleteCounter.increment();
    super.deleteEntry(entry);
}