|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPListener<K,V>
public class LateralTCPListener<K extends Serializable,V extends Serializable>
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 | |
|---|---|
class |
LateralTCPListener.ConnectionHandler
A Separate thread that runs when a command comes into the LateralTCPReceiver. |
class |
LateralTCPListener.ListenerThread
Processes commands from the server socket. |
protected static class |
LateralTCPListener.MyThreadFactory
Allows us to set the daemon status on the executor threads |
| Field Summary | |
|---|---|
protected static HashMap<String,ILateralCacheListener<?,?>> |
instances
Map of available instances, keyed by port |
protected static org.apache.commons.logging.Log |
log
The logger |
protected ExecutorService |
pooledExecutor
The processor. |
protected int |
port
Listening port |
protected boolean |
shutdown
is this shut down? |
protected boolean |
terminated
is this terminated? |
| Constructor Summary | |
|---|---|
protected |
LateralTCPListener(ITCPLateralCacheAttributes ilca)
Only need one since it does work for all regions, just reference by multiple region names. |
| Method Summary | ||
|---|---|---|
void |
dispose()
Dispose this listener |
|
protected CompositeCache<K,V> |
getCache(String name)
Gets the cacheManager attribute of the LateralCacheTCPListener object. |
|
ICompositeCacheManager |
getCacheManager()
|
|
int |
getGetCnt()
|
|
static
|
getInstance(ITCPLateralCacheAttributes ilca,
ICompositeCacheManager cacheMgr)
Gets the instance attribute of the LateralCacheTCPListener class. |
|
long |
getListenerId()
Gets the listenerId attribute of the LateralCacheTCPListener object |
|
int |
getPutCnt()
This is roughly the number of updates the lateral has received. |
|
int |
getRemoveCnt()
|
|
ITCPLateralCacheAttributes |
getTcpLateralCacheAttributes()
|
|
void |
handleDispose(String cacheName)
This marks this instance as terminated. |
|
ICacheElement<K,V> |
handleGet(String cacheName,
K key)
Gets the cache that was injected by the lateral factory. |
|
Set<K> |
handleGetGroupKeys(String cacheName,
String group)
Gets the cache that was injected by the lateral factory. |
|
Set<String> |
handleGetGroupNames(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. |
|
void |
handlePut(ICacheElement<K,V> element)
Increments the put count. |
|
void |
handleRemove(String cacheName,
K key)
Increments the remove count. |
|
void |
handleRemoveAll(String cacheName)
Gets the cache that was injected by the lateral factory. |
|
void |
init()
This starts the ListenerThread on the specified port. |
|
void |
setCacheManager(ICompositeCacheManager cacheMgr)
|
|
void |
setListenerId(long id)
Let the lateral cache set a listener_id. |
|
void |
setTcpLateralCacheAttributes(ITCPLateralCacheAttributes tcpLateralCacheAttributes)
|
|
void |
shutdown()
Shuts down the receiver. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.commons.logging.Log log
protected static final HashMap<String,ILateralCacheListener<?,?>> instances
protected int port
protected ExecutorService pooledExecutor
protected boolean shutdown
protected boolean terminated
| Constructor Detail |
|---|
protected LateralTCPListener(ITCPLateralCacheAttributes ilca)
ilca - | Method Detail |
|---|
public static <K extends Serializable,V extends Serializable> LateralTCPListener<K,V> getInstance(ITCPLateralCacheAttributes ilca,
ICompositeCacheManager cacheMgr)
ilca - ITCPLateralCacheAttributescacheMgr -
public void init()
init in interface ILateralCacheListener<K extends Serializable,V extends Serializable>
public void setListenerId(long id)
throws IOException
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.
setListenerId in interface ICacheListener<K extends Serializable,V extends Serializable>id - The new listenerId value
IOException
public long getListenerId()
throws IOException
getListenerId in interface ICacheListener<K extends Serializable,V extends Serializable>IOException
public void handlePut(ICacheElement<K,V> element)
throws IOException
handlePut in interface ICacheListener<K extends Serializable,V extends Serializable>IOExceptionICacheListener.handlePut(org.apache.jcs.engine.behavior.ICacheElement)
public void handleRemove(String cacheName,
K key)
throws IOException
handleRemove in interface ICacheListener<K extends Serializable,V extends Serializable>IOExceptionICacheListener.handleRemove(java.lang.String,
java.io.Serializable)
public void handleRemoveAll(String cacheName)
throws IOException
handleRemoveAll in interface ICacheListener<K extends Serializable,V extends Serializable>IOExceptionICacheListener.handleRemoveAll(java.lang.String)
public ICacheElement<K,V> handleGet(String cacheName,
K key)
throws IOException
cacheName - key -
IOException
public Map<K,ICacheElement<K,V>> handleGetMatching(String cacheName,
String pattern)
throws IOException
cacheName - the name of the cachepattern - the matching pattern
IOException
public Set<K> handleGetGroupKeys(String cacheName,
String group)
throws IOException
cacheName - the name of the cachegroup - the group name
IOException
public Set<String> handleGetGroupNames(String cacheName)
throws IOException
cacheName - the name of the cache
IOException
public void handleDispose(String cacheName)
throws IOException
handleDispose in interface ICacheListener<K extends Serializable,V extends Serializable>IOExceptionICacheListener.handleDispose(java.lang.String)public void dispose()
ILateralCacheListener
dispose in interface ILateralCacheListener<K extends Serializable,V extends Serializable>protected CompositeCache<K,V> getCache(String name)
Normally this is set by the factory. If it wasn't set the listener defaults to the expected singleton behavior of the cache manager.
name -
public int getPutCnt()
public int getGetCnt()
public int getRemoveCnt()
public void setCacheManager(ICompositeCacheManager cacheMgr)
setCacheManager in interface ILateralCacheListener<K extends Serializable,V extends Serializable>cacheMgr - The cacheMgr to set.public ICompositeCacheManager getCacheManager()
getCacheManager in interface ILateralCacheListener<K extends Serializable,V extends Serializable>public void setTcpLateralCacheAttributes(ITCPLateralCacheAttributes tcpLateralCacheAttributes)
tcpLateralCacheAttributes - The tcpLateralCacheAttributes to set.public ITCPLateralCacheAttributes getTcpLateralCacheAttributes()
public void shutdown()
shutdown in interface IShutdownObserver
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||