org.apache.jcs.engine
Class PooledCacheEventQueue<K extends Serializable,V extends Serializable>

java.lang.Object
  extended by org.apache.jcs.engine.AbstractCacheEventQueue<K,V>
      extended by org.apache.jcs.engine.PooledCacheEventQueue<K,V>
All Implemented Interfaces:
ICacheEventQueue<K,V>

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


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.jcs.engine.AbstractCacheEventQueue
AbstractCacheEventQueue.AbstractCacheEvent, AbstractCacheEventQueue.DisposeEvent, AbstractCacheEventQueue.Node, AbstractCacheEventQueue.PutEvent, AbstractCacheEventQueue.RemoveAllEvent, AbstractCacheEventQueue.RemoveEvent
 
Field Summary
 
Fields inherited from class org.apache.jcs.engine.AbstractCacheEventQueue
cacheName, DEFAULT_WAIT_TO_DIE_MILLIS, destroyed, listener, listenerId, log, maxFailure, waitBeforeRetry, waitToDieMillis, working
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheEventQueue
POOLED_QUEUE_TYPE, SINGLE_QUEUE_TYPE
 
Constructor Summary
PooledCacheEventQueue(ICacheListener<K,V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName)
          Constructor for the CacheEventQueue object
 
Method Summary
 void destroy()
          Destroy the queue.
 String 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.
 
Methods inherited from class org.apache.jcs.engine.AbstractCacheEventQueue
addDisposeEvent, addPutEvent, addRemoveAllEvent, addRemoveEvent, getListenerId, getWaitToDieMillis, isAlive, isWorking, setAlive, setWaitToDieMillis, setWorking, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

initialize

public 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 -

getQueueType

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

Returns:
the queue type

stopProcessing

public void stopProcessing()
Event Q is empty.


destroy

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


put

protected void put(AbstractCacheEventQueue.AbstractCacheEvent event)
Adds an event to the queue.

Specified by:
put in class AbstractCacheEventQueue<K extends Serializable,V extends Serializable>
Parameters:
event -

getStats

public String getStats()
Returns:
Statistics info

getStatistics

public IStats 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 1.

Returns:
number of items in the queue.


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.