@ManagedObject public class DuplexConnectionPool extends AbstractConnectionPool implements Sweeper.Sweepable
ConnectionPool.Factory
Modifier and Type | Field and Description |
---|---|
private java.util.Set<Connection> |
activeConnections |
private java.util.Deque<Connection> |
idleConnections |
private java.util.concurrent.locks.ReentrantLock |
lock |
private static Logger |
LOG |
Constructor and Description |
---|
DuplexConnectionPool(Destination destination,
int maxConnections,
Callback requester) |
Modifier and Type | Method and Description |
---|---|
protected Connection |
activate() |
void |
close()
Closes this ConnectionPool.
|
protected boolean |
deactivate(Connection connection) |
void |
dump(java.lang.Appendable out,
java.lang.String indent) |
int |
getActiveConnectionCount() |
java.util.Collection<Connection> |
getActiveConnections() |
int |
getIdleConnectionCount() |
java.util.Queue<Connection> |
getIdleConnections() |
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) |
boolean |
sweep() |
java.lang.String |
toString() |
protected void |
unlock() |
acquire, acquired, active, close, dump, getConnectionCount, getMaxConnectionCount, getPendingCount, idle, isClosed, isEmpty, proceed, released, removed, tryCreate
private static final Logger LOG
private final java.util.concurrent.locks.ReentrantLock lock
private final java.util.Deque<Connection> idleConnections
private final java.util.Set<Connection> activeConnections
public DuplexConnectionPool(Destination destination, int maxConnections, Callback requester)
protected void lock()
protected void unlock()
@ManagedAttribute(value="The number of idle connections", readonly=true) public int getIdleConnectionCount()
@ManagedAttribute(value="The number of active connections", readonly=true) public int getActiveConnectionCount()
public java.util.Queue<Connection> getIdleConnections()
public java.util.Collection<Connection> getActiveConnections()
public boolean isActive(Connection connection)
isActive
in interface ConnectionPool
connection
- the connection to testprotected void onCreated(Connection connection)
onCreated
in class AbstractConnectionPool
protected Connection activate()
activate
in class AbstractConnectionPool
public boolean release(Connection connection)
ConnectionPool
Returns the given connection, previously obtained via ConnectionPool.acquire()
,
back to this ConnectionPool.
release
in interface ConnectionPool
connection
- the connection to releaseprotected boolean deactivate(Connection connection)
public boolean remove(Connection connection)
ConnectionPool
Removes the given connection from this ConnectionPool.
remove
in interface ConnectionPool
connection
- the connection to removeprotected boolean remove(Connection connection, boolean force)
public void close()
ConnectionPool
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface ConnectionPool
close
in class AbstractConnectionPool
ConnectionPool.isClosed()
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
public boolean sweep()
sweep
in interface Sweeper.Sweepable
public java.lang.String toString()
toString
in class java.lang.Object