Class AbstractWriteBehindQueue
- java.lang.Object
-
- net.sf.ehcache.writer.writebehind.AbstractWriteBehindQueue
-
- All Implemented Interfaces:
WriteBehind
public abstract class AbstractWriteBehindQueue extends java.lang.Object implements WriteBehind
Abstract implementation of a WriteBehindQueue.- Author:
- tim
-
-
Constructor Summary
Constructors Constructor Description AbstractWriteBehindQueue(CacheConfiguration config)Create a new write behind queue.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaddItem(SingleOperation operation)Add an item to the write behind queuevoiddelete(CacheEntry entry)Add a delete operation for the given cache entryprotected java.lang.ThreadgetProcessingThread()Backdoor to allow killing the processing thread for testing purposes.abstract longgetQueueSize()Gets the best estimate for items in the queue still awaiting processing.protected abstract java.util.List<SingleOperation>quarantineItems()Quarantine items to be processed.protected abstract voidreinsertUnprocessedItems(java.util.List<SingleOperation> operations)Reinsert any unfinished operations into the queue.voidsetOperationsFilter(OperationsFilter filter)Set the operations filter that should be used.voidstart(CacheWriter writer)Start the write behind queue with a cache writervoidstop()Stop the coordinator and all the internal data structures.voidwrite(Element element)Add a write operation for a given element.
-
-
-
Constructor Detail
-
AbstractWriteBehindQueue
public AbstractWriteBehindQueue(CacheConfiguration config)
Create a new write behind queue.- Parameters:
config- the configuration for the queue
-
-
Method Detail
-
quarantineItems
protected abstract java.util.List<SingleOperation> quarantineItems()
Quarantine items to be processed.- Returns:
- list of operations
-
addItem
protected abstract void addItem(SingleOperation operation)
Add an item to the write behind queue- Parameters:
operation- operation to be done
-
reinsertUnprocessedItems
protected abstract void reinsertUnprocessedItems(java.util.List<SingleOperation> operations)
Reinsert any unfinished operations into the queue.- Parameters:
operations- list of unfinished operations
-
start
public void start(CacheWriter writer)
Start the write behind queue with a cache writer- Specified by:
startin interfaceWriteBehind- Parameters:
writer- the cache writer that should be used to process the operations- See Also:
WriteBehind.stop()
-
setOperationsFilter
public void setOperationsFilter(OperationsFilter filter)
Set the operations filter that should be used.- Specified by:
setOperationsFilterin interfaceWriteBehind- Parameters:
filter- the filter that will be used as of now
-
write
public void write(Element element)
Add a write operation for a given element.- Specified by:
writein interfaceWriteBehind- Parameters:
element- the element for which a write operation will be added to the write behind queue
-
delete
public void delete(CacheEntry entry)
Add a delete operation for the given cache entry- Specified by:
deletein interfaceWriteBehind- Parameters:
entry- the cache entry for which a delete operation will be added to the write behind queue
-
stop
public void stop() throws CacheExceptionStop the coordinator and all the internal data structures.This stops as quickly as possible without losing any previously added items. However, no guarantees are made towards the processing of these items. It's highly likely that items are still inside the internal data structures and not processed.
- Specified by:
stopin interfaceWriteBehind- Throws:
CacheException- See Also:
WriteBehind.start(net.sf.ehcache.writer.CacheWriter)
-
getQueueSize
public abstract long getQueueSize()
Gets the best estimate for items in the queue still awaiting processing. Not including elements currently processed- Specified by:
getQueueSizein interfaceWriteBehind- Returns:
- the amount of elements still awaiting processing.
-
getProcessingThread
protected java.lang.Thread getProcessingThread()
Backdoor to allow killing the processing thread for testing purposes.
-
-