public void enumAvailable(final Callback<PoolEntry<T, C>> callback) { for (final Iterator<PoolEntry<T, C>> it = available.iterator(); it.hasNext(); ) { final PoolEntry<T, C> entry = it.next(); callback.execute(entry); if (!entry.hasConnection()) { it.remove(); } } }
public void enumLeased(final Callback<PoolEntry<T, C>> callback) { for (final Iterator<PoolEntry<T, C>> it = leased.keySet().iterator(); it.hasNext(); ) { final PoolEntry<T, C> entry = it.next(); callback.execute(entry); if (!entry.hasConnection()) { it.remove(); } } }
public void enumAvailable(final Callback<PoolEntry<T, C>> callback) { for (final Iterator<PoolEntry<T, C>> it = available.iterator(); it.hasNext(); ) { final PoolEntry<T, C> entry = it.next(); callback.execute(entry); if (!entry.hasConnection()) { it.remove(); } } }
public void enumLeased(final Callback<PoolEntry<T, C>> callback) { for (final Iterator<PoolEntry<T, C>> it = leased.keySet().iterator(); it.hasNext(); ) { final PoolEntry<T, C> entry = it.next(); callback.execute(entry); if (!entry.hasConnection()) { it.remove(); } } }
/** * Enumerates all available connections. * * @since 4.3 */ public void enumAvailable(final Callback<PoolEntry<T, C>> callback) { this.lock.lock(); try { final Iterator<PoolEntry<T, C>> it = this.available.iterator(); while (it.hasNext()) { final PoolEntry<T, C> entry = it.next(); callback.execute(entry); if (!entry.hasConnection()) { final PerRoutePool<T, C> pool = getPool(entry.getRoute()); pool.remove(entry); it.remove(); } } processPendingRequests(); purgePoolMap(); } finally { this.lock.unlock(); } }
/** * Enumerates all available connections. * * @since 4.3 */ public void enumAvailable(final Callback<PoolEntry<T, C>> callback) { this.lock.lock(); try { final Iterator<PoolEntry<T, C>> it = this.available.iterator(); while (it.hasNext()) { final PoolEntry<T, C> entry = it.next(); callback.execute(entry); if (!entry.hasConnection()) { final PerRoutePool<T, C> pool = getPool(entry.getRoute()); pool.remove(entry); it.remove(); } } processPendingRequests(); purgePoolMap(); } finally { this.lock.unlock(); } }
final boolean keepAlive = entry.hasConnection() && reusable; pool.free(entry, keepAlive); if (keepAlive) {
final boolean keepAlive = entry.hasConnection() && reusable; pool.free(entry, keepAlive); if (keepAlive) {
releasedEntry.discardConnection(CloseMode.GRACEFUL); if (releasedEntry.hasConnection()) { switch (policy) { case LIFO:
releasedEntry.discardConnection(CloseMode.GRACEFUL); if (releasedEntry.hasConnection()) { switch (policy) { case LIFO:
poolEntry.discardConnection(CloseMode.IMMEDIATE); if (poolEntry.hasConnection()) { resultFuture.completed(endpoint); } else {
poolEntry.discardConnection(CloseMode.IMMEDIATE); if (poolEntry.hasConnection()) { resultFuture.completed(endpoint); } else {
@Override public void connect(final ConnectionEndpoint endpoint, final TimeValue connectTimeout, final HttpContext context) throws IOException { Args.notNull(endpoint, "Managed endpoint"); final InternalConnectionEndpoint internalEndpoint = cast(endpoint); if (internalEndpoint.isConnected()) { return; } final PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry = internalEndpoint.getPoolEntry(); if (!poolEntry.hasConnection()) { poolEntry.assignConnection(connFactory.createConnection(null)); } final HttpRoute route = poolEntry.getRoute(); final HttpHost host; if (route.getProxyHost() != null) { host = route.getProxyHost(); } else { host = route.getTargetHost(); } this.connectionOperator.connect( poolEntry.getConnection(), host, route.getLocalSocketAddress(), connectTimeout, defaultSocketConfig != null ? this.defaultSocketConfig : SocketConfig.DEFAULT, context); }
final PoolEntry<String, HttpConnection> entry1 = future1.get(); Assert.assertNotNull(entry1); Assert.assertFalse(entry1.hasConnection()); entry1.assignConnection(conn1); Assert.assertTrue(future2.isDone()); final PoolEntry<String, HttpConnection> entry2 = future2.get(); Assert.assertNotNull(entry2); Assert.assertFalse(entry2.hasConnection()); entry2.assignConnection(conn2); final PoolEntry<String, HttpConnection> entry3 = future3.get(); Assert.assertNotNull(entry3); Assert.assertFalse(entry3.hasConnection()); entry3.assignConnection(conn3); Assert.assertTrue(future4.isDone()); final PoolEntry<String, HttpConnection> entry4 = future4.get(); Assert.assertNotNull(entry4); Assert.assertFalse(entry4.hasConnection()); entry4.assignConnection(conn4); final PoolEntry<String, HttpConnection> entry5 = future5.get(); Assert.assertNotNull(entry5); Assert.assertFalse(entry5.hasConnection()); entry5.assignConnection(conn5); Assert.assertTrue(future6.isDone()); final PoolEntry<String, HttpConnection> entry6 = future6.get(); Assert.assertNotNull(entry6); Assert.assertTrue(entry6.hasConnection()); Assert.assertSame(conn4, entry6.getConnection());