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.RemoveEventICacheEventQueue.QueueType| Modifier and Type | Field and Description |
|---|---|
protected ExecutorService |
pool
The Thread Pool to execute events with.
|
protected BlockingQueue<Runnable> |
queue
The Thread Pool queue
|
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 |
|---|---|
protected ExecutorService |
createPool(String threadPoolName)
Create the thread pool.
|
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, isWorking, setWaitToDieMillis, setWorking, toStringprotected ExecutorService pool
protected BlockingQueue<Runnable> queue
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 - protected ExecutorService createPool(String threadPoolName)
threadPoolName - public ICacheEventQueue.QueueType getQueueType()
ICacheEventQueuepublic void destroy()
protected void put(AbstractCacheEventQueue.AbstractCacheEvent event)
put in class AbstractCacheEventQueue<K,V>event - public IStats getStatistics()
ICacheEventQueuepublic boolean isEmpty()
public int size()
Copyright © 2002–2022 The Apache Software Foundation. All rights reserved.