An abstract connection pool. More...
It is used by the com.good.gd.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager. The abstract pool includes a poolLock, which is used to synchronize access to the internal pool datastructures. Don't use synchronized
for that purpose!
The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
Public Member Functions | |
void | enableConnectionGC () throws IllegalStateException |
Enables connection garbage collection (GC). More... | |
final BasicPoolEntry | getEntry (HttpRoute route, Object state, long timeout, TimeUnit tunit) throws ConnectionPoolTimeoutException, InterruptedException |
Obtains a pool entry with a connection within the given timeout. More... | |
abstract PoolEntryRequest | requestPoolEntry (HttpRoute route, Object state) |
Returns a new com.good.gd.apache.http.impl.conn.tsccm.PoolEntryRequest, from which a com.good.gd.apache.http.impl.conn.tsccm.BasicPoolEntry can be obtained, or the request can be aborted. More... | |
abstract void | freeEntry (BasicPoolEntry entry, boolean reusable, long validDuration, TimeUnit timeUnit) |
Returns an entry into the pool. More... | |
void | closeIdleConnections (long idletime, TimeUnit tunit) |
Closes idle connections. More... | |
abstract void | deleteClosedConnections () |
Deletes all entries for closed connections. | |
void | shutdown () |
Shuts down this pool and all associated resources. More... | |
Public Member Functions inherited from RefQueueHandler | |
void | handleReference (Reference<?> ref) |
Invoked when a reference is found on the queue. More... | |
Protected Member Functions | |
AbstractConnPool () | |
Creates a new connection pool. | |
abstract void | handleLostEntry (HttpRoute route) |
Handles cleaning up for a lost pool entry with the given route. More... | |
void | closeConnection (final OperatedClientConnection conn) |
Closes a connection from this pool. More... | |
Protected Attributes | |
final Lock | poolLock |
The global lock for this pool. | |
Set< BasicPoolEntryRef > | issuedConnections |
References to issued connections. More... | |
IdleConnectionHandler | idleConnHandler |
The handler for idle connections. More... | |
int | numConnections |
The current total number of connections. More... | |
ReferenceQueue< Object > | refQueue |
A reference queue to track loss of pool entries to GC. More... | |
volatile boolean | isShutDown |
Indicates whether this pool is shut down. More... | |
void enableConnectionGC | ( | ) | throws IllegalStateException |
This method must be called immediately after creating the connection pool. It is not possible to enable connection GC after pool entries have been created. Neither is it possible to disable connection GC.
IllegalStateException | if connection GC is already enabled, or if it cannot be enabled because there already are pool entries |
final BasicPoolEntry getEntry | ( | HttpRoute | route, |
Object | state, | ||
long | timeout, | ||
TimeUnit | tunit | ||
) | throws ConnectionPoolTimeoutException, InterruptedException |
route | the route for which to get the connection |
state | |
timeout | the timeout, 0 or negative for no timeout |
tunit | the unit for the timeout , may be null only if there is no timeout |
ConnectionPoolTimeoutException | if the timeout expired |
InterruptedException | if the calling thread was interrupted |
|
abstract |
route | |
state |
Reimplemented in ConnPoolByRoute.
|
abstract |
The connection of the entry is expected to be in a suitable state, either open and re-usable, or closed. The pool will not make any attempt to determine whether it can be re-used or not.
entry | the entry for the connection to release |
reusable | true if the entry is deemed reusable, false otherwise. |
validDuration | The duration that the entry should remain free and reusable. |
timeUnit | The unit of time the duration is measured in. |
Reimplemented in ConnPoolByRoute.
|
abstractprotected |
A lost pool entry corresponds to a connection that was garbage collected instead of being properly released.
route | the route of the pool entry that was lost |
Reimplemented in ConnPoolByRoute.
void closeIdleConnections | ( | long | idletime, |
TimeUnit | tunit | ||
) |
idletime | the time the connections should have been idle in order to be closed now |
tunit | the unit for the idletime |
void shutdown | ( | ) |
Overriding methods MUST call the implementation here!
Reimplemented in ConnPoolByRoute.
|
protected |
conn | the connection to close, or null |
|
protected |
Objects in this set are of class BasicPoolEntryRef , and point to the pool entry for the issued connection. GCed connections are detected by the missing pool entries.
|
protected |
|
protected |
|
protected |
The same queue is used to track loss of the connection manager, so we cannot specialize the type.
|
protected |