Class OutboundConnectionCacheBlockingImpl<C extends Connection>
- java.lang.Object
-
- com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.ConnectionCacheBase<C>
-
- com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.OutboundConnectionCacheBlockingImpl<C>
-
- All Implemented Interfaces:
ConnectionCache<C>,OutboundConnectionCache<C>
public final class OutboundConnectionCacheBlockingImpl<C extends Connection> extends ConnectionCacheBase<C> implements OutboundConnectionCache<C>
-
-
Field Summary
Fields Modifier and Type Field Description protected inttotalBusyprotected inttotalIdle-
Fields inherited from class com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.ConnectionCacheBase
logger, reclaimableConnections
-
-
Constructor Summary
Constructors Constructor Description OutboundConnectionCacheBlockingImpl(String cacheType, int highWaterMark, int numberToReclaim, int maxParallelConnections, Logger logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanCreateNewConnection(ContactInfo<C> cinfo)Determine whether a new connection could be created by the ConnectionCache or not.voidclose(C conn)Close a connection, regardless of whether the connection is busy or not.Cget(ContactInfo<C> cinfo)Behaves the same asget( ContactInfo<C>, ConnectionFinder<C> )except that no connection finder is provided, so that step is ignored.Cget(ContactInfo<C> cinfo, ConnectionFinder<C> finder)Return a Connection corresponding to the given ContactInfo.com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.OutboundConnectionCacheBlockingImpl.ConnectionState<C>getConnectionState(ContactInfo<C> cinfo, com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.OutboundConnectionCacheBlockingImpl.CacheEntry<C> entry, C conn)intmaxParallelConnections()Configured maximum number of connections supported per ContactInfo.longnumberOfBusyConnections()Number of non-idle connections.longnumberOfConnections()Total number of connections currently managed by the cache.longnumberOfIdleConnections()Number of idle connections; that is, connections for which the number of get/release or responseReceived/responseProcessed calls are equal.longnumberOfReclaimableConnections()Number of idle connections that are reclaimable.voidrelease(C conn, int numResponsesExpected)Release a Connection previously obtained from get.voidresponseReceived(C conn)Decrement the number of expected responses.protected StringthisClassName()-
Methods inherited from class com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.ConnectionCacheBase
debug, dprint, dprintStatistics, getCacheType, highWaterMark, numberToReclaim, reclaim, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.sun.xml.ws.transport.tcp.connectioncache.spi.transport.ConnectionCache
getCacheType, highWaterMark, numberOfBusyConnections, numberOfConnections, numberOfIdleConnections, numberOfReclaimableConnections, numberToReclaim
-
-
-
-
Method Detail
-
maxParallelConnections
public int maxParallelConnections()
Description copied from interface:OutboundConnectionCacheConfigured maximum number of connections supported per ContactInfo.- Specified by:
maxParallelConnectionsin interfaceOutboundConnectionCache<C extends Connection>
-
thisClassName
protected String thisClassName()
- Specified by:
thisClassNamein classConnectionCacheBase<C extends Connection>
-
canCreateNewConnection
public boolean canCreateNewConnection(ContactInfo<C> cinfo)
Description copied from interface:OutboundConnectionCacheDetermine whether a new connection could be created by the ConnectionCache or not.- Specified by:
canCreateNewConnectionin interfaceOutboundConnectionCache<C extends Connection>
-
get
public C get(ContactInfo<C> cinfo) throws IOException
Description copied from interface:OutboundConnectionCacheBehaves the same asget( ContactInfo<C>, ConnectionFinder<C> )except that no connection finder is provided, so that step is ignored.- Specified by:
getin interfaceOutboundConnectionCache<C extends Connection>- Throws:
IOException
-
getConnectionState
public com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.OutboundConnectionCacheBlockingImpl.ConnectionState<C> getConnectionState(ContactInfo<C> cinfo, com.sun.xml.ws.transport.tcp.connectioncache.impl.transport.OutboundConnectionCacheBlockingImpl.CacheEntry<C> entry, C conn)
-
get
public C get(ContactInfo<C> cinfo, ConnectionFinder<C> finder) throws IOException
Description copied from interface:OutboundConnectionCacheReturn a Connection corresponding to the given ContactInfo. This works as follows:- Call the finder. If it returns non-null, use that connection; (Note that this may be a new connection, created in the finder)
- otherwise, Use an idle connection, if one is available;
- otherwise, create a new connection, if not too many connections are open;
- otherwise, use a busy connection.
- there is no existing connection for the ContactInfo
- OR the total number of connections in the cache is less than the HighWaterMark and the number of connections for this ContactInfo is less than MaxParallelConnections.
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.
- Specified by:
getin interfaceOutboundConnectionCache<C extends Connection>- Throws:
IOException
-
release
public void release(C conn, int numResponsesExpected)
Description copied from interface:OutboundConnectionCacheRelease a Connection previously obtained from get. Connections that have been released as many times as they have been returned by get are idle; otherwise a Connection is busy. Some number of responses (usually 0 or 1) may be expected ON THE SAME CONNECTION even for an idle connection. We maintain a count of the number of outstanding responses we expect for protocols that return the response on the same connection on which the request was received. This is necessary to prevent reclamation of a Connection that is idle, but still needed to send responses to old requests.- Specified by:
releasein interfaceOutboundConnectionCache<C extends Connection>
-
responseReceived
public void responseReceived(C conn)
Decrement the number of expected responses. When a connection is idle and has no expected responses, it can be reclaimed.- Specified by:
responseReceivedin interfaceOutboundConnectionCache<C extends Connection>
-
close
public void close(C conn)
Close a connection, regardless of whether the connection is busy or not.- Specified by:
closein interfaceConnectionCache<C extends Connection>
-
numberOfConnections
public long numberOfConnections()
Description copied from interface:ConnectionCacheTotal number of connections currently managed by the cache.
-
numberOfIdleConnections
public long numberOfIdleConnections()
Description copied from interface:ConnectionCacheNumber of idle connections; that is, connections for which the number of get/release or responseReceived/responseProcessed calls are equal.
-
numberOfBusyConnections
public long numberOfBusyConnections()
Description copied from interface:ConnectionCacheNumber of non-idle connections. Normally, busy+idle==total, but this may not be strictly true due to concurrent updates to the connection cache.
-
numberOfReclaimableConnections
public long numberOfReclaimableConnections()
Description copied from interface:ConnectionCacheNumber of idle connections that are reclaimable. Such connections are not in use, and are not waiting to handle any responses.
-
-