/** * Shuts down this pool and all associated resources. * Overriding methods MUST call the implementation here! */ public void shutdown() { poolLock.lock(); try { if (isShutDown) return; // no point in monitoring GC anymore if (refWorker != null) refWorker.shutdown(); // close all connections that are issued to an application Iterator<BasicPoolEntryRef> iter = issuedConnections.iterator(); while (iter.hasNext()) { BasicPoolEntryRef per = iter.next(); iter.remove(); BasicPoolEntry entry = per.get(); if (entry != null) { closeConnection(entry.getConnection()); } } // remove all references to connections //@@@ use this for shutting them down instead? idleConnHandler.removeAll(); isShutDown = true; } finally { poolLock.unlock(); } }
final Object state) { final PoolEntryRequest poolRequest = connectionPool.requestPoolEntry( route, state);
public void closeExpiredConnections() { connectionPool.closeExpiredConnections(); connectionPool.deleteClosedConnections(); }
public void closeIdleConnections(long idleTimeout, TimeUnit tunit) { // combine these two in a single call? connectionPool.closeIdleConnections(idleTimeout, tunit); connectionPool.deleteClosedConnections(); }
public void shutdown() { connectionPool.shutdown(); }
/** * Hook for creating the connection pool. * * @return the connection pool to use */ protected AbstractConnPool createConnectionPool(final HttpParams params) { AbstractConnPool acp = new ConnPoolByRoute(connOperator, params); boolean conngc = true; //@@@ check parameters to decide if (conngc) { acp.enableConnectionGC(); } return acp; }
public void handleReference(Reference ref) { // END android-changed poolLock.lock(); try { if (ref instanceof BasicPoolEntryRef) { // check if the GCed pool entry was still in use //@@@ find a way to detect this without lookup //@@@ flag in the BasicPoolEntryRef, to be reset when freed? final boolean lost = issuedConnections.remove(ref); if (lost) { final HttpRoute route = ((BasicPoolEntryRef)ref).getRoute(); if (log.isDebugEnabled()) { log.debug("Connection garbage collected. " + route); } handleLostEntry(route); } } } finally { poolLock.unlock(); } }
hca.detach(); if (entry != null) { connectionPool.freeEntry(entry, reusable, validDuration, timeUnit);
public void closeIdleConnections(long idleTimeout, TimeUnit tunit) { // combine these two in a single call? connectionPool.closeIdleConnections(idleTimeout, tunit); connectionPool.deleteClosedConnections(); }
@Override public void shutdown() { poolLock.lock(); try { super.shutdown(); // close all free connections //@@@ move this to base class? Iterator<BasicPoolEntry> ibpe = freeConnections.iterator(); while (ibpe.hasNext()) { BasicPoolEntry entry = ibpe.next(); ibpe.remove(); closeConnection(entry.getConnection()); } // wake up all waiting threads Iterator<WaitingThread> iwth = waitingThreads.iterator(); while (iwth.hasNext()) { WaitingThread waiter = iwth.next(); iwth.remove(); waiter.wakeup(); } routeToPool.clear(); } finally { poolLock.unlock(); } }
/** * Hook for creating the connection pool. * * @return the connection pool to use */ protected AbstractConnPool createConnectionPool(final HttpParams params) { AbstractConnPool acp = new ConnPoolByRoute(connOperator, params); boolean conngc = true; //@@@ check parameters to decide if (conngc) { acp.enableConnectionGC(); } return acp; }
public void handleReference(Reference ref) { // END android-changed poolLock.lock(); try { if (ref instanceof BasicPoolEntryRef) { // check if the GCed pool entry was still in use //@@@ find a way to detect this without lookup //@@@ flag in the BasicPoolEntryRef, to be reset when freed? final boolean lost = issuedConnections.remove(ref); if (lost) { final HttpRoute route = ((BasicPoolEntryRef)ref).getRoute(); if (log.isDebugEnabled()) { log.debug("Connection garbage collected. " + route); } handleLostEntry(route); } } } finally { poolLock.unlock(); } }
hca.detach(); if (entry != null) { connectionPool.freeEntry(entry, reusable, validDuration, timeUnit);
/** * Obtains a pool entry with a connection within the given timeout. * * @param route the route for which to get the connection * @param timeout the timeout, 0 or negative for no timeout * @param tunit the unit for the <code>timeout</code>, * may be <code>null</code> only if there is no timeout * * @return pool entry holding a connection for the route * * @throws ConnectionPoolTimeoutException * if the timeout expired * @throws InterruptedException * if the calling thread was interrupted */ public final BasicPoolEntry getEntry( HttpRoute route, Object state, long timeout, TimeUnit tunit) throws ConnectionPoolTimeoutException, InterruptedException { return requestPoolEntry(route, state).getPoolEntry(timeout, tunit); }
/** * Shuts down this pool and all associated resources. * Overriding methods MUST call the implementation here! */ public void shutdown() { poolLock.lock(); try { if (isShutDown) { return; } // close all connections that are issued to an application final Iterator<BasicPoolEntry> iter = leasedConnections.iterator(); while (iter.hasNext()) { final BasicPoolEntry entry = iter.next(); iter.remove(); closeConnection(entry.getConnection()); } idleConnHandler.removeAll(); isShutDown = true; } finally { poolLock.unlock(); } }
public void closeIdleConnections(long idleTimeout, TimeUnit tunit) { // combine these two in a single call? connectionPool.closeIdleConnections(idleTimeout, tunit); connectionPool.deleteClosedConnections(); }
public void closeExpiredConnections() { connectionPool.closeExpiredConnections(); connectionPool.deleteClosedConnections(); }
public void shutdown() { connectionPool.shutdown(); }
/** * Hook for creating the connection pool. * * @return the connection pool to use */ protected AbstractConnPool createConnectionPool(final HttpParams params) { AbstractConnPool acp = new ConnPoolByRoute(connOperator, params); boolean conngc = true; //@@@ check parameters to decide if (conngc) { acp.enableConnectionGC(); } return acp; }
public void handleReference(Reference ref) { // END android-changed poolLock.lock(); try { if (ref instanceof BasicPoolEntryRef) { // check if the GCed pool entry was still in use //@@@ find a way to detect this without lookup //@@@ flag in the BasicPoolEntryRef, to be reset when freed? final boolean lost = issuedConnections.remove(ref); if (lost) { final HttpRoute route = ((BasicPoolEntryRef)ref).getRoute(); if (log.isDebugEnabled()) { log.debug("Connection garbage collected. " + route); } handleLostEntry(route); } } } finally { poolLock.unlock(); } }