- java.lang.Object
-
- org.eclipse.jetty.client.AbstractConnectionPool
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ConnectionPool,Dumpable
- Direct Known Subclasses:
DuplexConnectionPool,MultiplexConnectionPool,RoundRobinConnectionPool
@ManagedObject public abstract class AbstractConnectionPool extends java.lang.Object implements ConnectionPool, Dumpable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.ConnectionPool
ConnectionPool.Factory, ConnectionPool.Multiplexable
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractConnectionPool(HttpDestination destination, int maxConnections, Callback requester)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaccept(Connection connection)Accepts the given connection to be managed by this ConnectionPool.Connectionacquire(boolean create)Returns an idle connection, if available; if an idle connection is not available, and the givencreateparameter istrue, then schedules the opening of a new connection, if possible within the configuration of this connection pool (for example, if it does not exceed the max connection count); otherwise returnsnull.protected voidacquired(Connection connection)protected abstract Connectionactivate()protected Connectionactive(Connection connection)voidclose()protected voidclose(java.util.Collection<Connection> connections)java.lang.Stringdump()intgetConnectionCount()protected HttpDestinationgetHttpDestination()intgetMaxConnectionCount()intgetPendingConnectionCount()protected booleanidle(Connection connection, boolean close)booleanisClosed()booleanisEmpty()protected abstract voidonCreated(Connection connection)protected voidproceed()protected voidreleased(Connection connection)protected voidremoved(Connection connection)protected voidtryCreate(int maxPending)Schedules the opening of a new connection.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.client.ConnectionPool
isActive, release, remove
-
-
-
-
Constructor Detail
-
AbstractConnectionPool
protected AbstractConnectionPool(HttpDestination destination, int maxConnections, Callback requester)
-
-
Method Detail
-
getHttpDestination
protected HttpDestination getHttpDestination()
-
getMaxConnectionCount
@ManagedAttribute(value="The max number of connections", readonly=true) public int getMaxConnectionCount()
-
getConnectionCount
@ManagedAttribute(value="The number of connections", readonly=true) public int getConnectionCount()
-
getPendingConnectionCount
@ManagedAttribute(value="The number of pending connections", readonly=true) public int getPendingConnectionCount()
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceConnectionPool- Returns:
- whether this ConnectionPool has no open connections
-
isClosed
public boolean isClosed()
- Specified by:
isClosedin interfaceConnectionPool- Returns:
- whether this ConnectionPool has been closed
- See Also:
ConnectionPool.close()
-
acquire
public Connection acquire(boolean create)
Description copied from interface:ConnectionPoolReturns an idle connection, if available; if an idle connection is not available, and the given
createparameter istrue, then schedules the opening of a new connection, if possible within the configuration of this connection pool (for example, if it does not exceed the max connection count); otherwise returnsnull.- Specified by:
acquirein interfaceConnectionPool- Parameters:
create- whether to schedule the opening of a connection if no idle connections are available- Returns:
- an idle connection or
nullif no idle connections are available
-
tryCreate
protected void tryCreate(int maxPending)
Schedules the opening of a new connection.
Whether a new connection is scheduled for opening is determined by the
maxPendingparameter: ifmaxPendingis greater than the current number of connections scheduled for opening, then this method returns without scheduling the opening of a new connection; ifmaxPendingis negative, a new connection is always scheduled for opening.- Parameters:
maxPending- the max desired number of connections scheduled for opening, or a negative number to always trigger the opening of a new connection
-
accept
public boolean accept(Connection connection)
Description copied from interface:ConnectionPoolAccepts the given connection to be managed by this ConnectionPool.
- Specified by:
acceptin interfaceConnectionPool- Parameters:
connection- the connection to accept- Returns:
- whether the connection has been accepted
-
onCreated
protected abstract void onCreated(Connection connection)
-
proceed
protected void proceed()
-
activate
protected abstract Connection activate()
-
active
protected Connection active(Connection connection)
-
acquired
protected void acquired(Connection connection)
-
idle
protected boolean idle(Connection connection, boolean close)
-
released
protected void released(Connection connection)
-
removed
protected void removed(Connection connection)
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceConnectionPool
-
close
protected void close(java.util.Collection<Connection> connections)
-
-