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

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

public abstract class AbstractCacheEventQueue<K extends Serializable,V extends Serializable>
extends Object
implements ICacheEventQueue<K,V>

An abstract base class to the different implementations


Nested Class Summary
protected  class AbstractCacheEventQueue.AbstractCacheEvent
          Retries before declaring failure.
protected  class AbstractCacheEventQueue.DisposeEvent
          The cache should be disposed when this event is processed.
protected static class AbstractCacheEventQueue.Node
          The queue is composed of nodes.
protected  class AbstractCacheEventQueue.PutEvent
          An element should be put in the cache.
protected  class AbstractCacheEventQueue.RemoveAllEvent
          All elements should be removed from the cache when this event is processed.
protected  class AbstractCacheEventQueue.RemoveEvent
          An element should be removed from the cache.
 
Field Summary
protected  String cacheName
          The cache region name, if applicable.
protected static int DEFAULT_WAIT_TO_DIE_MILLIS
          default
protected  boolean destroyed
          this is true if there is no worker thread.
protected  ICacheListener<K,V> listener
          When the events are pulled off the queue, the tell the listener to handle the specific event type.
protected  long listenerId
          Id of the listener registered with this queue
protected static org.apache.commons.logging.Log log
          The logger.
protected  int maxFailure
          Maximum number of failures before we buy the farm.
protected  int waitBeforeRetry
          in milliseconds
protected  int waitToDieMillis
          time to wait for an event before snuffing the background thread if the queue is empty. make configurable later
protected  boolean working
          This means that the queue is functional.
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheEventQueue
POOLED_QUEUE_TYPE, SINGLE_QUEUE_TYPE
 
Constructor Summary
AbstractCacheEventQueue()
           
 
Method Summary
 void addDisposeEvent()
          Adds a feature to the DisposeEvent attribute of the ICacheEventQueue object
 void addPutEvent(ICacheElement<K,V> ce)
          This adds a put event to the queue.
 void addRemoveAllEvent()
          This adds a remove all event to the queue.
 void addRemoveEvent(K key)
          This adds a remove event to the queue.
 long getListenerId()
          Gets the listenerId attribute of the ICacheEventQueue object
 int getWaitToDieMillis()
          Returns the time to wait for events before killing the background thread.
 boolean isAlive()
          If they queue has an active thread it is considered alive.
 boolean isWorking()
          A Queue is working unless it has reached its max failure count.
protected abstract  void put(AbstractCacheEventQueue.AbstractCacheEvent event)
          Adds an event to the queue.
 void setAlive(boolean aState)
          Sets whether the queue is actively processing -- if there are working threads.
 void setWaitToDieMillis(int wtdm)
          Sets the time to wait for events before killing the background thread.
 void setWorking(boolean b)
          This means that the queue is functional.
 String toString()
          Creates a brief string identifying the listener and the region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jcs.engine.behavior.ICacheEventQueue
destroy, getQueueType, getStatistics, initialize, isEmpty, size
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
The logger.


DEFAULT_WAIT_TO_DIE_MILLIS

protected static final int DEFAULT_WAIT_TO_DIE_MILLIS
default

See Also:
Constant Field Values

waitToDieMillis

protected int waitToDieMillis
time to wait for an event before snuffing the background thread if the queue is empty. make configurable later


listener

protected ICacheListener<K extends Serializable,V extends Serializable> listener
When the events are pulled off the queue, the tell the listener to handle the specific event type. The work is done by the listener.


listenerId

protected long listenerId
Id of the listener registered with this queue


cacheName

protected String cacheName
The cache region name, if applicable.


maxFailure

protected int maxFailure
Maximum number of failures before we buy the farm.


waitBeforeRetry

protected int waitBeforeRetry
in milliseconds


destroyed

protected boolean destroyed
this is true if there is no worker thread.


working

protected boolean working
This means that the queue is functional. If we reached the max number of failures, the queue is marked as non functional and will never work again.

Constructor Detail

AbstractCacheEventQueue

public AbstractCacheEventQueue()
Method Detail

getWaitToDieMillis

public int getWaitToDieMillis()
Returns the time to wait for events before killing the background thread.

Returns:
int

setWaitToDieMillis

public void setWaitToDieMillis(int wtdm)
Sets the time to wait for events before killing the background thread.

Parameters:
wtdm - the ms for the q to sit idle.

toString

public String toString()
Creates a brief string identifying the listener and the region.

Overrides:
toString in class Object
Returns:
String debugging info.

isAlive

public boolean isAlive()
If they queue has an active thread it is considered alive.

Specified by:
isAlive in interface ICacheEventQueue<K extends Serializable,V extends Serializable>
Returns:
The alive value

setAlive

public void setAlive(boolean aState)
Sets whether the queue is actively processing -- if there are working threads.

Parameters:
aState -

getListenerId

public long getListenerId()
Description copied from interface: ICacheEventQueue
Gets the listenerId attribute of the ICacheEventQueue object

Specified by:
getListenerId in interface ICacheEventQueue<K extends Serializable,V extends Serializable>
Returns:
The listenerId value

addPutEvent

public void addPutEvent(ICacheElement<K,V> ce)
                 throws IOException
This adds a put event to the queue. When it is processed, the element will be put to the listener.

Specified by:
addPutEvent in interface ICacheEventQueue<K extends Serializable,V extends Serializable>
Parameters:
ce - The feature to be added to the PutEvent attribute
Throws:
IOException

addRemoveEvent

public void addRemoveEvent(K key)
                    throws IOException
This adds a remove event to the queue. When processed the listener's remove method will be called for the key.

Specified by:
addRemoveEvent in interface ICacheEventQueue<K extends Serializable,V extends Serializable>
Parameters:
key - The feature to be added to the RemoveEvent attribute
Throws:
IOException

addRemoveAllEvent

public void addRemoveAllEvent()
                       throws IOException
This adds a remove all event to the queue. When it is processed, all elements will be removed from the cache.

Specified by:
addRemoveAllEvent in interface ICacheEventQueue<K extends Serializable,V extends Serializable>
Throws:
IOException

addDisposeEvent

public void addDisposeEvent()
                     throws IOException
Description copied from interface: ICacheEventQueue
Adds a feature to the DisposeEvent attribute of the ICacheEventQueue object

Specified by:
addDisposeEvent in interface ICacheEventQueue<K extends Serializable,V extends Serializable>
Throws:
IOException

put

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

Parameters:
event -

isWorking

public boolean isWorking()
Description copied from interface: ICacheEventQueue
A Queue is working unless it has reached its max failure count.

Specified by:
isWorking in interface ICacheEventQueue<K extends Serializable,V extends Serializable>
Returns:
whether the queue is functional.

setWorking

public void setWorking(boolean b)
This means that the queue is functional. If we reached the max number of failures, the queue is marked as non functional and will never work again.

Parameters:
b -


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