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

public class PooledCacheEventQueue<K,V> extends AbstractCacheEventQueue<K,V>
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.

  • Field Details

  • Constructor Details

    • PooledCacheEventQueue

      public 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

    • initialize

      protected 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 -
    • createPool

      protected ExecutorService createPool(String threadPoolName)
      Create the thread pool.

      Parameters:
      threadPoolName -
      Since:
      3.1
    • getQueueType

      Description copied from interface: ICacheEventQueue
      Return the type of event queue we are using, either single or pooled.

      Returns:
      the queue type
    • destroy

      public void destroy()
      Destroy the queue. Interrupt all threads.
    • put

      Adds an event to the queue.

      Specified by:
      put in class AbstractCacheEventQueue<K,V>
      Parameters:
      event -
    • getStatistics

      Description copied from interface: ICacheEventQueue
      Returns the historical and statistical data for an event queue cache.

      Returns:
      IStats
    • isEmpty

      public boolean isEmpty()
      If 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
    • size

      public int size()
      Returns 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.