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.PutEvent, AbstractCacheEventQueue.RemoveAllEvent, AbstractCacheEventQueue.RemoveEvent
ICacheEventQueue.QueueType
DEFAULT_WAIT_TO_DIE_MILLIS
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.
|
protected 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.
|
addDisposeEvent, addPutEvent, addRemoveAllEvent, addRemoveEvent, getCacheName, getListenerId, getWaitToDieMillis, initialize, 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
- protected 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 destroy()
protected void put(AbstractCacheEventQueue.AbstractCacheEvent event)
put
in class AbstractCacheEventQueue<K,V>
event
- public IStats getStatistics()
ICacheEventQueue
public boolean isEmpty()
public int size()
Copyright © 2002–2018 The Apache Software Foundation. All rights reserved.