public class ValidatingConnectionPool extends ConnectionPool
A connection pool that validates connections before making them available for use.
Connections that have just been opened are not validated.
Connections that are released
will
be validated.
Validation by reading from the EndPoint is not reliable, since the TCP FIN may arrive just after the validation read.
This class validates connections by putting them in a "quarantine" for a configurable timeout, where they cannot be used to send requests. When the timeout expires, the quarantined connection is made idle and therefore available to send requests.
The existing HttpClient mechanism to detect server closes will trigger and close quarantined connections, before they are made idle (and reusable) again.
There still is a small chance that the timeout expires, the connection is made idle and available again, it is used to send a request exactly when the server decides to close. This case is however unavoidable and may be mitigated by tuning the idle timeout of the servers to be larger than that of the client.
Constructor and Description |
---|
ValidatingConnectionPool(Destination destination,
int maxConnections,
Callback requester,
Scheduler scheduler,
long timeout) |
Modifier and Type | Method and Description |
---|---|
void |
dump(Appendable out,
String indent) |
int |
getValidatingConnectionCount() |
boolean |
release(Connection connection) |
boolean |
remove(Connection connection) |
String |
toString() |
acquire, acquired, close, dump, getActiveConnectionCount, getActiveConnections, getConnectionCount, getIdleConnectionCount, getIdleConnections, idle, idleCreated, isActive, isEmpty, isIdle, lock, offerIdle, proceed, released, remove, sweep, unlock
public ValidatingConnectionPool(Destination destination, int maxConnections, Callback requester, Scheduler scheduler, long timeout)
@ManagedAttribute(value="The number of validating connections", readonly=true) public int getValidatingConnectionCount()
public boolean release(Connection connection)
release
in class DuplexConnectionPool
public boolean remove(Connection connection)
remove
in class DuplexConnectionPool
public void dump(Appendable out, String indent) throws IOException
dump
in interface Dumpable
dump
in class DuplexConnectionPool
IOException
public String toString()
toString
in class DuplexConnectionPool
Copyright © 1995-2016 Webtide. All Rights Reserved.