public class MultiplexConnectionPool extends AbstractConnectionPool implements Sweeper.Sweepable
| Modifier and Type | Class and Description |
|---|---|
private static class |
MultiplexConnectionPool.Holder |
ConnectionPool.Factory| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<Connection,MultiplexConnectionPool.Holder> |
busyConnections |
private HttpDestination |
destination |
private java.util.Deque<MultiplexConnectionPool.Holder> |
idleConnections |
private java.util.concurrent.locks.ReentrantLock |
lock |
private static Logger |
LOG |
private int |
maxMultiplex |
private java.util.Map<Connection,MultiplexConnectionPool.Holder> |
muxedConnections |
| Constructor and Description |
|---|
MultiplexConnectionPool(HttpDestination destination,
int maxConnections,
Callback requester,
int maxMultiplex) |
| Modifier and Type | Method and Description |
|---|---|
Connection |
acquire()
Returns an idle connection, if available, or schedules the opening
of a new connection and returns
null. |
protected Connection |
activate() |
void |
close()
Closes this ConnectionPool.
|
void |
dump(java.lang.Appendable out,
java.lang.String indent) |
int |
getMaxMultiplex() |
boolean |
isActive(Connection connection) |
protected void |
lock() |
protected void |
onCreated(Connection connection) |
boolean |
release(Connection connection)
Returns the given connection, previously obtained via
ConnectionPool.acquire(),
back to this ConnectionPool. |
boolean |
remove(Connection connection)
Removes the given connection from this ConnectionPool.
|
protected boolean |
remove(Connection connection,
boolean force) |
void |
setMaxMultiplex(int maxMultiplex) |
boolean |
sweep() |
java.lang.String |
toString() |
protected void |
unlock() |
acquired, active, close, dump, getConnectionCount, getMaxConnectionCount, getPendingCount, idle, isClosed, isEmpty, proceed, released, removed, tryCreateprivate static final Logger LOG
private final java.util.concurrent.locks.ReentrantLock lock
private final HttpDestination destination
private final java.util.Deque<MultiplexConnectionPool.Holder> idleConnections
private final java.util.Map<Connection,MultiplexConnectionPool.Holder> muxedConnections
private final java.util.Map<Connection,MultiplexConnectionPool.Holder> busyConnections
private int maxMultiplex
public MultiplexConnectionPool(HttpDestination destination, int maxConnections, Callback requester, int maxMultiplex)
public Connection acquire()
ConnectionPoolReturns an idle connection, if available, or schedules the opening
of a new connection and returns null.
acquire in interface ConnectionPoolacquire in class AbstractConnectionPoolprotected void lock()
protected void unlock()
public int getMaxMultiplex()
public void setMaxMultiplex(int maxMultiplex)
public boolean isActive(Connection connection)
isActive in interface ConnectionPoolconnection - the connection to testprotected void onCreated(Connection connection)
onCreated in class AbstractConnectionPoolprotected Connection activate()
activate in class AbstractConnectionPoolpublic boolean release(Connection connection)
ConnectionPoolReturns the given connection, previously obtained via ConnectionPool.acquire(),
back to this ConnectionPool.
release in interface ConnectionPoolconnection - the connection to releasepublic boolean remove(Connection connection)
ConnectionPoolRemoves the given connection from this ConnectionPool.
remove in interface ConnectionPoolconnection - the connection to removeprotected boolean remove(Connection connection, boolean force)
public void close()
ConnectionPoolclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface ConnectionPoolclose in class AbstractConnectionPoolConnectionPool.isClosed()public void dump(java.lang.Appendable out,
java.lang.String indent)
throws java.io.IOException
public boolean sweep()
sweep in interface Sweeper.Sweepablepublic java.lang.String toString()
toString in class java.lang.Object