public class PooledCacheEventQueue<K,V> extends AbstractCacheEventQueue<K,V>
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.
AbstractCacheEventQueue.AbstractCacheEvent, AbstractCacheEventQueue.DisposeEvent, AbstractCacheEventQueue.Node, AbstractCacheEventQueue.PutEvent, AbstractCacheEventQueue.RemoveAllEvent, AbstractCacheEventQueue.RemoveEvent
ICacheEventQueue.QueueType
cacheName, DEFAULT_WAIT_TO_DIE_MILLIS, destroyed, listener, listenerId, maxFailure, waitBeforeRetry
Constructor and Description |
---|
PooledCacheEventQueue(ICacheListener<K,V> listener,
long listenerId,
String cacheName,
int maxFailure,
int waitBeforeRetry,
String threadPoolName)
Constructor for the CacheEventQueue object
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy the queue.
|
ICacheEventQueue.QueueType |
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.
|
String |
getStats() |
void |
initialize(ICacheListener<K,V> listener,
long listenerId,
String cacheName,
int maxFailure,
int waitBeforeRetry,
String threadPoolName)
Initializes the queue.
|
boolean |
isEmpty()
If the Queue is using a bounded channel we can determine the size.
|
protected void |
put(AbstractCacheEventQueue.AbstractCacheEvent event)
Adds an event to the queue.
|
int |
size()
Returns the number of elements in the queue.
|
void |
stopProcessing()
Event Q is empty.
|
addDisposeEvent, addPutEvent, addRemoveAllEvent, addRemoveEvent, getListenerId, getWaitToDieMillis, isAlive, isWorking, setAlive, setWaitToDieMillis, setWorking, toString
public PooledCacheEventQueue(ICacheListener<K,V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName)
listener
- listenerId
- cacheName
- maxFailure
- waitBeforeRetry
- threadPoolName
- public void initialize(ICacheListener<K,V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName)
listener
- listenerId
- cacheName
- maxFailure
- waitBeforeRetry
- threadPoolName
- public ICacheEventQueue.QueueType getQueueType()
ICacheEventQueue
public void stopProcessing()
public void destroy()
protected void put(AbstractCacheEventQueue.AbstractCacheEvent event)
put
in class AbstractCacheEventQueue<K,V>
event
- public String getStats()
public IStats getStatistics()
ICacheEventQueue
public boolean isEmpty()
public int size()
Copyright © 2002–2015 The Apache Software Foundation. All rights reserved.