Class ValidatingConnectionPool
- All Implemented Interfaces:
Closeable,AutoCloseable,ConnectionPool,Container,Destroyable,Dumpable,Dumpable.DumpableContainer,LifeCycle,Sweeper.Sweepable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface org.eclipse.jetty.client.ConnectionPool
ConnectionPool.Factory, ConnectionPool.MaxUsable, ConnectionPool.MultiplexableNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionValidatingConnectionPool(HttpDestination destination, int maxConnections, Callback requester, Scheduler scheduler, long timeout) -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.intbooleanrelease(Connection connection) Returns the given connection, previously obtained viaConnectionPool.acquire(boolean), back to this ConnectionPool.booleanremove(Connection connection) Removes the given connection from this ConnectionPool.toString()Methods inherited from class org.eclipse.jetty.client.DuplexConnectionPool
getMaxUsageCount, setMaxUsageCountMethods inherited from class org.eclipse.jetty.client.AbstractConnectionPool
accept, acquire, acquired, activate, close, deactivate, doStop, getActiveConnectionCount, getConnectionCount, getIdleConnectionCount, getMaxConnectionCount, getMaxDuration, getMaxMultiplex, getPendingConnectionCount, idle, isActive, isClosed, isEmpty, isMaximizeConnections, onCreated, preCreateConnections, proceed, released, remove, removed, setMaxDuration, setMaximizeConnections, setMaxMultiplex, sweep, tryCreateMethods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListenersMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Constructor Details
-
ValidatingConnectionPool
public ValidatingConnectionPool(HttpDestination destination, int maxConnections, Callback requester, Scheduler scheduler, long timeout)
-
-
Method Details
-
getValidatingConnectionCount
@ManagedAttribute(value="The number of validating connections", readonly=true) public int getValidatingConnectionCount() -
release
Description copied from interface:ConnectionPoolReturns the given connection, previously obtained via
ConnectionPool.acquire(boolean), back to this ConnectionPool.- Specified by:
releasein interfaceConnectionPool- Overrides:
releasein classAbstractConnectionPool- Parameters:
connection- the connection to release- Returns:
- true if the connection has been released, false if the connection should be closed
-
remove
Description copied from interface:ConnectionPoolRemoves the given connection from this ConnectionPool.
- Specified by:
removein interfaceConnectionPool- Overrides:
removein classAbstractConnectionPool- Parameters:
connection- the connection to remove- Returns:
- true if the connection was removed from this ConnectionPool
-
dump
Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dumpin interfaceDumpable- Overrides:
dumpin classAbstractConnectionPool- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-
toString
- Overrides:
toStringin classAbstractConnectionPool
-