|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface OutboundConnectionCache<C extends Closeable>
A concurrent mostly non-blocking connection cache. Here a Connection is an abstraction of a Socket or SocketChannel: basically some sort of resource that is expensive to acquire, and can be re-used freely. The cache maintains a loose upper bound on the number of cached connections, and reclaims connections as needed.
This cache places minimal requirements on the Connections that it contains:
Some simple methods are provided for monitoring the state of the cache: numbers of busy and idle connections, and the total number of connections in the cache.
Method Summary | |
---|---|
boolean |
canCreateNewConnection(ContactInfo<C> cinfo)
Determine whether a new connection could be created by the ConnectionCache or not. |
C |
get(ContactInfo<C> cinfo)
Behaves the same as get( ContactInfo |
C |
get(ContactInfo<C> cinfo,
ConnectionFinder<C> finder)
Return a Connection corresponding to the given ContactInfo. |
int |
maxParallelConnections()
Configured maximum number of connections supported per ContactInfo. |
void |
release(C conn,
int numResponseExpected)
Release a Connection previously obtained from get. |
void |
responseReceived(C conn)
Inform the cache that a response has been received on a particular connection. |
Methods inherited from interface com.sun.grizzly.connectioncache.spi.transport.ConnectionCache |
---|
close, getCacheType, highWaterMark, numberOfBusyConnections, numberOfConnections, numberOfIdleConnections, numberOfReclaimableConnections, numberToReclaim |
Method Detail |
---|
int maxParallelConnections()
ContactInfo
boolean canCreateNewConnection(ContactInfo<C> cinfo)
cinfo
- a ContactInfo
ConnectionCache
, otherwise false.C get(ContactInfo<C> cinfo, ConnectionFinder<C> finder) throws IOException
It is possible that the cache contains connections that no longer connect to their destination. In this case, it is the responsibility of the client of the cache to close the broken connection as they are detected. Connection reclamation may also handle the cleanup, but note that a broken connection with pending responses will never be reclaimed.
Note that the idle and busy connection collections that are passed to the finder are unmodifiable collections. They have iterators that return connections in LRU order, with the least recently used connection first. This is done to aid a finder that wishes to consider load balancing in its determination of an appropriate connection.
cinfo
- a ContactInfo
finder
- a ConnectionFinder
IOException
C get(ContactInfo<C> cinfo) throws IOException
cinfo
- a ContactInfo
IOException
void release(C conn, int numResponseExpected)
conn
- a connectionnumResponseExpected
- number of connections in which a response is expectedvoid responseReceived(C conn)
When a Connection is idle, and has no pending responses, it is eligible for reclamation.
conn
- a connection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |