public class PooledCacheEventQueue extends java.lang.Object implements ICacheEventQueue
This is a modified version of the experimental version. It uses a PooledExecutor and a BoundedBuffer to queue up events and execute them as threads become available.
The PooledExecutor is static, because presumably these processes will be IO bound, so throwing more than a few threads at them will serve no purpose other than to saturate the IO interface. In light of this, having one thread per region seems unnecessary. This may prove to be false.
POOLED_QUEUE_TYPE, SINGLE_QUEUE_TYPE| Constructor and Description |
|---|
PooledCacheEventQueue(ICacheListener listener,
long listenerId,
java.lang.String cacheName,
int maxFailure,
int waitBeforeRetry,
java.lang.String threadPoolName)
Constructor for the CacheEventQueue object
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDisposeEvent()
Adds a feature to the DisposeEvent attribute of the ICacheEventQueue
object
|
void |
addPutEvent(ICacheElement ce)
Constructs a PutEvent for the object and passes it to the event queue.
|
void |
addRemoveAllEvent()
Adds a feature to the RemoveAllEvent attribute of the ICacheEventQueue
object
|
void |
addRemoveEvent(java.io.Serializable key)
Adds a feature to the RemoveEvent attribute of the ICacheEventQueue
object
|
void |
destroy()
Destroy the queue.
|
long |
getListenerId()
Gets the listenerId attribute of the ICacheEventQueue object
|
java.lang.String |
getQueueType()
Return the type of event queue we are using, either single or pooled.
|
IStats |
getStatistics()
Returns the historical and statistical data for an event queue cache.
|
java.lang.String |
getStats() |
int |
getWaitToDieMillis()
Returns the time to wait for events before killing the background thread.
|
void |
initialize(ICacheListener listener,
long listenerId,
java.lang.String cacheName,
int maxFailure,
int waitBeforeRetry,
java.lang.String threadPoolName)
Initializes the queue.
|
boolean |
isAlive()
Gets the alive attribute of the ICacheEventQueue object.
|
boolean |
isEmpty()
If the Queue is using a bounded channel we can determine the size.
|
boolean |
isWorking()
A Queue is working unless it has reached its max failure count.
|
void |
setAlive(boolean aState) |
void |
setWaitToDieMillis(int wtdm)
Sets the time to wait for events before killing the background thread.
|
void |
setWorking(boolean isWorkingArg) |
int |
size()
Returns the number of elements in the queue.
|
void |
stopProcessing()
Event Q is empty.
|
java.lang.String |
toString() |
public PooledCacheEventQueue(ICacheListener listener, long listenerId, java.lang.String cacheName, int maxFailure, int waitBeforeRetry, java.lang.String threadPoolName)
listener - listenerId - cacheName - maxFailure - waitBeforeRetry - threadPoolName - public void initialize(ICacheListener listener, long listenerId, java.lang.String cacheName, int maxFailure, int waitBeforeRetry, java.lang.String threadPoolName)
initialize in interface ICacheEventQueuelistener - listenerId - cacheName - maxFailure - waitBeforeRetry - threadPoolName - public java.lang.String getQueueType()
ICacheEventQueuegetQueueType in interface ICacheEventQueuepublic void stopProcessing()
public int getWaitToDieMillis()
public void setWaitToDieMillis(int wtdm)
wtdm - public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isAlive()
ICacheEventQueueisAlive in interface ICacheEventQueuepublic void setAlive(boolean aState)
aState - public long getListenerId()
ICacheEventQueuegetListenerId in interface ICacheEventQueuepublic void destroy()
destroy in interface ICacheEventQueuepublic void addPutEvent(ICacheElement ce) throws java.io.IOException
addPutEvent in interface ICacheEventQueuece - The feature to be added to the PutEvent attributejava.io.IOExceptionpublic void addRemoveEvent(java.io.Serializable key)
throws java.io.IOException
ICacheEventQueueaddRemoveEvent in interface ICacheEventQueuekey - The feature to be added to the RemoveEvent attributejava.io.IOExceptionpublic void addRemoveAllEvent()
throws java.io.IOException
ICacheEventQueueaddRemoveAllEvent in interface ICacheEventQueuejava.io.IOExceptionpublic void addDisposeEvent()
throws java.io.IOException
ICacheEventQueueaddDisposeEvent in interface ICacheEventQueuejava.io.IOExceptionpublic java.lang.String getStats()
public IStats getStatistics()
ICacheEventQueuegetStatistics in interface ICacheEventQueuepublic boolean isWorking()
ICacheEventQueueisWorking in interface ICacheEventQueuepublic void setWorking(boolean isWorkingArg)
isWorkingArg - whether the queue is functionalpublic boolean isEmpty()
isEmpty in interface ICacheEventQueuepublic int size()
size in interface ICacheEventQueueCopyright © 2002-2013 Apache Software Foundation. All Rights Reserved.