org.apache.jcs.engine
Class CacheEventQueue

java.lang.Object
  extended byorg.apache.jcs.engine.CacheEventQueue
All Implemented Interfaces:
ICacheEventQueue

public class CacheEventQueue
extends java.lang.Object
implements ICacheEventQueue

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 should lazy initilaize the processor thread, and kill the thread if the queue goes emtpy for a specified period, now set to 1 minute. If something comes in after that a new processor thread should be created. I didn't get all of Hanson's changes in yet, but I did add the syncronization.


Field Summary
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheEventQueue
POOLED_QUEUE_TYPE, SINGLE_QUEUE_TYPE
 
Constructor Summary
CacheEventQueue(ICacheListener listener, long listenerId, java.lang.String cacheName)
          Constructs with the specified listener and the cache name.
CacheEventQueue(ICacheListener listener, long listenerId, java.lang.String cacheName, int maxFailure, int waitBeforeRetry)
          Constructor for the CacheEventQueue object
 
Method Summary
 void addDisposeEvent()
          Adds a feature to the DisposeEvent attribute of the ICacheEventQueue object
 void addPutEvent(ICacheElement ce)
          Adds a feature to the PutEvent attribute of the ICacheEventQueue object
 void addRemoveAllEvent()
          Adds a feature to the RemoveAllEvent attribute of the ICacheEventQueue object
 void addRemoveEvent(java.io.Serializable key)
          Adds a feature to the RemoveEvent attribute of the ICacheEventQueue object
 void destroy()
          Event Q is emtpy.
 long getListenerId()
          Gets the listenerId attribute of the ICacheEventQueue object
 int getQueueType()
          Returnt he type of event queue we are using, either single or pooled.
 IStats getStatistics()
          Returns the historical and statistical data for an event queue cache.
 int getWaitToDieMillis()
          Returns the time to wait for events before killing the background thread.
 boolean isAlive()
          Gets the alive attribute of the ICacheEventQueue object.
 boolean isEmpty()
          Are there elements in the queue.
 boolean isWorking()
          A Queue is working unless it has reached its max failure count.
 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)
           
 void stopProcessing()
          Kill the processor thread and indicate that the queue is detroyed and no longer alive, but it can still be working.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheEventQueue

public CacheEventQueue(ICacheListener listener,
                       long listenerId,
                       java.lang.String cacheName)
Constructs with the specified listener and the cache name.

Parameters:
listener -
listenerId -
cacheName -

CacheEventQueue

public CacheEventQueue(ICacheListener listener,
                       long listenerId,
                       java.lang.String cacheName,
                       int maxFailure,
                       int waitBeforeRetry)
Constructor for the CacheEventQueue object

Parameters:
listener -
listenerId -
cacheName -
maxFailure -
waitBeforeRetry -
Method Detail

getQueueType

public int getQueueType()
Description copied from interface: ICacheEventQueue
Returnt he type of event queue we are using, either single or pooled.

Specified by:
getQueueType in interface ICacheEventQueue
Returns:

stopProcessing

public void stopProcessing()
Kill the processor thread and indicate that the queue is detroyed and no longer alive, but it can still be working.


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 java.lang.String toString()
Returns:
String debugging info.

isAlive

public boolean isAlive()
Description copied from interface: ICacheEventQueue
Gets the alive attribute of the ICacheEventQueue object. Alive just indicates that there are active threads. This is less important that if the queue is working.

Specified by:
isAlive in interface ICacheEventQueue
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
Returns:
The {3} value

destroy

public void destroy()
Event Q is emtpy.

Specified by:
destroy in interface ICacheEventQueue

addPutEvent

public void addPutEvent(ICacheElement ce)
                 throws java.io.IOException
Description copied from interface: ICacheEventQueue
Adds a feature to the PutEvent attribute of the ICacheEventQueue object

Specified by:
addPutEvent in interface ICacheEventQueue
Parameters:
ce - The feature to be added to the PutEvent attribute
Throws:
java.io.IOException

addRemoveEvent

public void addRemoveEvent(java.io.Serializable key)
                    throws java.io.IOException
Description copied from interface: ICacheEventQueue
Adds a feature to the RemoveEvent attribute of the ICacheEventQueue object

Specified by:
addRemoveEvent in interface ICacheEventQueue
Parameters:
key - The feature to be added to the RemoveEvent attribute
Throws:
java.io.IOException

addRemoveAllEvent

public void addRemoveAllEvent()
                       throws java.io.IOException
Description copied from interface: ICacheEventQueue
Adds a feature to the RemoveAllEvent attribute of the ICacheEventQueue object

Specified by:
addRemoveAllEvent in interface ICacheEventQueue
Throws:
java.io.IOException

addDisposeEvent

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

Specified by:
addDisposeEvent in interface ICacheEventQueue
Throws:
java.io.IOException

getStatistics

public IStats getStatistics()
Description copied from interface: ICacheEventQueue
Returns the historical and statistical data for an event queue cache.

Specified by:
getStatistics in interface ICacheEventQueue
Returns:

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
Returns:
whether the queue is functional.

setWorking

public void setWorking(boolean b)
Parameters:
b -

isEmpty

public boolean isEmpty()
Description copied from interface: ICacheEventQueue
Are there elements in the queue.

Specified by:
isEmpty in interface ICacheEventQueue
Returns:
whether there are any items in the queue.


Copyright © 2002-2007 Apache Software Foundation. All Rights Reserved.