Package org.apache.commons.jcs3.engine
Class PooledCacheEventQueue<K,V> 
java.lang.Object
org.apache.commons.jcs3.engine.AbstractCacheEventQueue<K,V>
 
org.apache.commons.jcs3.engine.PooledCacheEventQueue<K,V> 
- All Implemented Interfaces:
- ICacheEventQueue<K,- V> 
- Direct Known Subclasses:
- CacheEventQueue
An event queue is used to propagate ordered cache events to one and only one target listener.
 
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.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.apache.commons.jcs3.engine.AbstractCacheEventQueueAbstractCacheEventQueue.AbstractCacheEvent, AbstractCacheEventQueue.DisposeEvent, AbstractCacheEventQueue.PutEvent, AbstractCacheEventQueue.RemoveAllEvent, AbstractCacheEventQueue.RemoveEventNested classes/interfaces inherited from interface org.apache.commons.jcs3.engine.behavior.ICacheEventQueueICacheEventQueue.QueueType
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ExecutorServiceThe Thread Pool to execute events with.protected BlockingQueue<Runnable>The Thread Pool queueFields inherited from class org.apache.commons.jcs3.engine.AbstractCacheEventQueueDEFAULT_WAIT_TO_DIE_MILLIS
- 
Constructor SummaryConstructorsConstructorDescriptionPooledCacheEventQueue(ICacheListener<K, V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName) Constructor for the CacheEventQueue object
- 
Method SummaryModifier and TypeMethodDescriptionprotected ExecutorServicecreatePool(String threadPoolName) Create the thread pool.voiddestroy()Destroy the queue.Return the type of event queue we are using, either single or pooled.Returns the historical and statistical data for an event queue cache.protected voidinitialize(ICacheListener<K, V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName) Initializes the queue.booleanisEmpty()If the Queue is using a bounded channel we can determine the size.protected voidput(AbstractCacheEventQueue<K, V>.AbstractCacheEvent event) Adds an event to the queue.intsize()Returns the number of elements in the queue.Methods inherited from class org.apache.commons.jcs3.engine.AbstractCacheEventQueueaddDisposeEvent, addPutEvent, addRemoveAllEvent, addRemoveEvent, getCacheName, getListenerId, getWaitToDieMillis, initialize, isWorking, setWaitToDieMillis, setWorking, toString
- 
Field Details- 
poolThe Thread Pool to execute events with.
- 
queueThe Thread Pool queue
 
- 
- 
Constructor Details- 
PooledCacheEventQueuepublic PooledCacheEventQueue(ICacheListener<K, V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName) Constructor for the CacheEventQueue object- Parameters:
- listener-
- listenerId-
- cacheName-
- maxFailure-
- waitBeforeRetry-
- threadPoolName-
 
 
- 
- 
Method Details- 
initializeprotected void initialize(ICacheListener<K, V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName) Initializes the queue.- Parameters:
- listener-
- listenerId-
- cacheName-
- maxFailure-
- waitBeforeRetry-
- threadPoolName-
 
- 
createPoolCreate the thread pool.- Parameters:
- threadPoolName-
- Since:
- 3.1
 
- 
getQueueTypeDescription copied from interface:ICacheEventQueueReturn the type of event queue we are using, either single or pooled.- Returns:
- the queue type
 
- 
destroyDestroy the queue. Interrupt all threads.
- 
putAdds an event to the queue.- Specified by:
- putin class- AbstractCacheEventQueue<K,- V> 
- Parameters:
- event-
 
- 
getStatisticsDescription copied from interface:ICacheEventQueueReturns the historical and statistical data for an event queue cache.- Returns:
- IStats
 
- 
isEmptyIf the Queue is using a bounded channel we can determine the size. If it is zero or we can't determine the size, we return true.- Returns:
- whether or not there are items in the queue
 
- 
sizeReturns the number of elements in the queue. If the queue cannot determine the size accurately it will return 0.- Returns:
- number of items in the queue.
 
 
-