public class CacheEventQueue<K,V> extends AbstractCacheEventQueue<K,V>
This is a modified version of the experimental version. It should lazy initialize the processor thread, and kill the thread if the queue goes empty for a specified period, now set to 1 minute. If something comes in after that a new processor thread should be created.
AbstractCacheEventQueue.AbstractCacheEvent, AbstractCacheEventQueue.DisposeEvent, AbstractCacheEventQueue.Node, AbstractCacheEventQueue.PutEvent, AbstractCacheEventQueue.RemoveAllEvent, AbstractCacheEventQueue.RemoveEvent
ICacheEventQueue.QueueType
cacheName, DEFAULT_WAIT_TO_DIE_MILLIS, destroyed, listener, listenerId, maxFailure, waitBeforeRetry
Constructor and Description |
---|
CacheEventQueue(ICacheListener<K,V> listener,
long listenerId,
String cacheName)
Constructs with the specified listener and the cache name.
|
CacheEventQueue(ICacheListener<K,V> listener,
long listenerId,
String cacheName,
int maxFailure,
int waitBeforeRetry)
Constructor for the CacheEventQueue object
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Event Q is empty.
|
ICacheEventQueue.QueueType |
getQueueType()
What type of queue is this.
|
IStats |
getStatistics()
This method returns semi-structured data on this queue.
|
void |
initialize(ICacheListener<K,V> listener,
long listenerId,
String cacheName,
int maxFailure,
int waitBeforeRetry,
String threadPoolName)
Initializes the queue.
|
boolean |
isEmpty()
Are there elements in the queue.
|
protected void |
put(AbstractCacheEventQueue.AbstractCacheEvent event)
Adds an event to the queue.
|
int |
size()
Returns the number of elements in the queue.
|
void |
stopProcessing()
Kill the processor thread and indicate that the queue is destroyed and no longer alive, but it
can still be working.
|
protected AbstractCacheEventQueue.AbstractCacheEvent |
take()
Returns the next cache event from the queue or null if there are no events in the queue.
|
addDisposeEvent, addPutEvent, addRemoveAllEvent, addRemoveEvent, getListenerId, getWaitToDieMillis, isAlive, isWorking, setAlive, setWaitToDieMillis, setWorking, toString
public CacheEventQueue(ICacheListener<K,V> listener, long listenerId, String cacheName)
listener
- listenerId
- cacheName
- public CacheEventQueue(ICacheListener<K,V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry)
listener
- listenerId
- cacheName
- maxFailure
- waitBeforeRetry
- public void initialize(ICacheListener<K,V> listener, long listenerId, String cacheName, int maxFailure, int waitBeforeRetry, String threadPoolName)
listener
- listenerId
- cacheName
- maxFailure
- waitBeforeRetry
- threadPoolName
- public ICacheEventQueue.QueueType getQueueType()
public void stopProcessing()
public void destroy()
Calling destroy interrupts the processor thread.
protected void put(AbstractCacheEventQueue.AbstractCacheEvent event)
put
in class AbstractCacheEventQueue<K,V>
event
- protected AbstractCacheEventQueue.AbstractCacheEvent take()
We have an empty node at the head and the tail. When we take an item from the queue we move the next node to the head and then clear the value from that node. This value is returned.
When the queue is empty the head node is the same as the tail node.
public IStats getStatistics()
ICacheEventQueue.getStatistics()
public boolean isEmpty()
ICacheEventQueue
public int size()
Copyright © 2002–2015 The Apache Software Foundation. All rights reserved.