Class LateralTCPListener<K,V>
java.lang.Object
org.apache.commons.jcs3.auxiliary.lateral.socket.tcp.LateralTCPListener<K,V>
- All Implemented Interfaces:
ILateralCacheListener<K,,V> ICacheListener<K,,V> IShutdownObserver
public class LateralTCPListener<K,V>
extends Object
implements ILateralCacheListener<K,V>, IShutdownObserver
Listens for connections from other TCP lateral caches and handles them. The initialization method
starts a listening thread, which creates a socket server. When messages are received they are
passed to a pooled executor which then calls the appropriate handle method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassDeprecated.No longer usedclassDeprecated.No longer used -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDeprecated.Specify serializerprotectedLateralTCPListener(ITCPLateralCacheAttributes ilca, IElementSerializer serializer) Only need one since it does work for all regions, just reference by multiple region names. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Dispose this listenerprotected CompositeCache<K,V> Gets the cacheManager attribute of the LateralCacheTCPListener object.intstatic <K,V> LateralTCPListener<K, V> getInstance(ITCPLateralCacheAttributes ilca, ICompositeCacheManager cacheMgr) Deprecated.Specify serializerstatic <K,V> LateralTCPListener<K, V> getInstance(ITCPLateralCacheAttributes ilca, ICompositeCacheManager cacheMgr, IElementSerializer serializer) Gets the instance attribute of the LateralCacheTCPListener class.longGets the listenerId attribute of the LateralCacheTCPListener objectintThis is roughly the number of updates the lateral has received.intvoidhandleDispose(String cacheName) This marks this instance as terminated.Gets the cache that was injected by the lateral factory.handleGetKeySet(String cacheName) Gets the cache that was injected by the lateral factory.Map<K,ICacheElement<K, V>> handleGetMatching(String cacheName, String pattern) Gets the cache that was injected by the lateral factory.voidhandlePut(ICacheElement<K, V> element) Increments the put count.voidhandleRemove(String cacheName, K key) Increments the remove count.voidhandleRemoveAll(String cacheName) Gets the cache that was injected by the lateral factory.voidinit()This starts the ListenerThread on the specified port.voidsetCacheManager(ICompositeCacheManager cacheMgr) voidsetListenerId(long id) Let the lateral cache set a listener_id.voidsetTcpLateralCacheAttributes(ITCPLateralCacheAttributes tcpLateralCacheAttributes) voidshutdown()Shuts down the receiver.
-
Constructor Details
-
LateralTCPListener
Deprecated.Specify serializerOnly need one since it does work for all regions, just reference by multiple region names.- Parameters:
ilca- ITCPLateralCacheAttributes
-
LateralTCPListener
Only need one since it does work for all regions, just reference by multiple region names.- Parameters:
ilca- ITCPLateralCacheAttributesserializer- the serializer to use when receiving
-
-
Method Details
-
getInstance
@Deprecated public static <K,V> LateralTCPListener<K,V> getInstance(ITCPLateralCacheAttributes ilca, ICompositeCacheManager cacheMgr) Deprecated.Specify serializerGets the instance attribute of the LateralCacheTCPListener class.- Parameters:
ilca- ITCPLateralCacheAttributescacheMgr-- Returns:
- The instance value
-
getInstance
public static <K,V> LateralTCPListener<K,V> getInstance(ITCPLateralCacheAttributes ilca, ICompositeCacheManager cacheMgr, IElementSerializer serializer) Gets the instance attribute of the LateralCacheTCPListener class.- Parameters:
ilca- ITCPLateralCacheAttributescacheMgr-serializer- the serializer to use when receiving- Returns:
- The instance value
-
init
This starts the ListenerThread on the specified port.- Specified by:
initin interfaceILateralCacheListener<K,V>
-
setListenerId
Let the lateral cache set a listener_id. Since there is only one listener for all the regions and every region gets registered? the id shouldn't be set if it isn't zero. If it is we assume that it is a reconnect.By default, the listener id is the vmid.
The service should set this value. This value will never be changed by a server we connect to. It needs to be non static, for unit tests.
The service will use the value it sets in all send requests to the sender.
- Specified by:
setListenerIdin interfaceICacheListener<K,V> - Parameters:
id- The new listenerId value- Throws:
IOException
-
getListenerId
Gets the listenerId attribute of the LateralCacheTCPListener object- Specified by:
getListenerIdin interfaceICacheListener<K,V> - Returns:
- The listenerId value
- Throws:
IOException
-
handlePut
Increments the put count. Gets the cache that was injected by the lateral factory. Calls put on the cache.- Specified by:
handlePutin interfaceICacheListener<K,V> - Throws:
IOException- See Also:
-
handleRemove
Increments the remove count. Gets the cache that was injected by the lateral factory. Calls remove on the cache.- Specified by:
handleRemovein interfaceICacheListener<K,V> - Throws:
IOException- See Also:
-
handleRemoveAll
Gets the cache that was injected by the lateral factory. Calls removeAll on the cache.- Specified by:
handleRemoveAllin interfaceICacheListener<K,V> - Throws:
IOException- See Also:
-
handleGet
Gets the cache that was injected by the lateral factory. Calls get on the cache.- Parameters:
cacheName-key-- Returns:
- a ICacheElement
- Throws:
IOException
-
handleGetMatching
public Map<K,ICacheElement<K, handleGetMatchingV>> (String cacheName, String pattern) throws IOException Gets the cache that was injected by the lateral factory. Calls get on the cache.- Parameters:
cacheName- the name of the cachepattern- the matching pattern- Returns:
- Map
- Throws:
IOException
-
handleGetKeySet
Gets the cache that was injected by the lateral factory. Calls getKeySet on the cache.- Parameters:
cacheName- the name of the cache- Returns:
- a set of keys
- Throws:
IOException
-
handleDispose
This marks this instance as terminated.- Specified by:
handleDisposein interfaceICacheListener<K,V> - Throws:
IOException- See Also:
-
dispose
Description copied from interface:ILateralCacheListenerDispose this listener- Specified by:
disposein interfaceILateralCacheListener<K,V>
-
getCache
Gets the cacheManager attribute of the LateralCacheTCPListener object.Normally this is set by the factory. If it wasn't set the listener defaults to the expected singleton behavior of the cache manager.
- Parameters:
name-- Returns:
- CompositeCache
-
getPutCnt
This is roughly the number of updates the lateral has received.- Returns:
- Returns the putCnt.
-
getGetCnt
- Returns:
- Returns the getCnt.
-
getRemoveCnt
- Returns:
- Returns the removeCnt.
-
setCacheManager
- Specified by:
setCacheManagerin interfaceILateralCacheListener<K,V> - Parameters:
cacheMgr- The cacheMgr to set.
-
getCacheManager
- Specified by:
getCacheManagerin interfaceILateralCacheListener<K,V> - Returns:
- Returns the cacheMgr.
-
setTcpLateralCacheAttributes
- Parameters:
tcpLateralCacheAttributes- The tcpLateralCacheAttributes to set.
-
getTcpLateralCacheAttributes
- Returns:
- Returns the tcpLateralCacheAttributes.
-
shutdown
Shuts down the receiver.- Specified by:
shutdownin interfaceIShutdownObserver
-