org.ehcache.loaderwriter.writebehind
Class AbstractWriteBehindQueue<K,V>

java.lang.Object
  extended by org.ehcache.loaderwriter.writebehind.AbstractWriteBehindQueue<K,V>
All Implemented Interfaces:
WriteBehind<K,V>
Direct Known Subclasses:
LocalHeapWriteBehindQueue

public abstract class AbstractWriteBehindQueue<K,V>
extends java.lang.Object
implements WriteBehind<K,V>


Constructor Summary
AbstractWriteBehindQueue(WriteBehindConfiguration config, CacheLoaderWriter<K,V> cacheLoaderWriter)
           
 
Method Summary
protected abstract  void addItem(SingleOperation<K,V> operation)
          Add an item to the write behind queue
 void delete(K key)
          Deletes a single entry from the underlying system of record.
protected abstract  SingleOperation<K,V> getLatestOperation(K key)
          Get the latest operation
abstract  long getQueueSize()
          Gets the best estimate for items in the queue still awaiting processing.
 V load(K key)
          Loads the value to be associated with the given key in the Cache using this CacheLoaderWriter instance.
protected abstract  java.util.List<SingleOperation<K,V>> quarantineItems()
          Quarantine items to be processed.
protected abstract  void reinsertUnprocessedItems(java.util.List<SingleOperation<K,V>> operations)
          Reinsert any unfinished operations into the queue.
protected abstract  void removeOperation(SingleOperation<K,V> operation)
          remove operation from map so that load hits SOR
 void setOperationsFilter(OperationsFilter<SingleOperation<K,V>> filter)
          Set the operations filter that should be used.
 void start()
          Start the write behind queue
 void stop()
          Stop the coordinator and all the internal data structures.
 void write(K key, V value)
          Writes a single entry to the underlying system of record, maybe a brand new value or an update to an existing value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractWriteBehindQueue

public AbstractWriteBehindQueue(WriteBehindConfiguration config,
                                CacheLoaderWriter<K,V> cacheLoaderWriter)
Method Detail

quarantineItems

protected abstract java.util.List<SingleOperation<K,V>> quarantineItems()
Quarantine items to be processed.


addItem

protected abstract void addItem(SingleOperation<K,V> operation)
Add an item to the write behind queue


reinsertUnprocessedItems

protected abstract void reinsertUnprocessedItems(java.util.List<SingleOperation<K,V>> operations)
Reinsert any unfinished operations into the queue.


getLatestOperation

protected abstract SingleOperation<K,V> getLatestOperation(K key)
Get the latest operation


removeOperation

protected abstract void removeOperation(SingleOperation<K,V> operation)
remove operation from map so that load hits SOR


start

public void start()
Description copied from interface: WriteBehind
Start the write behind queue

Specified by:
start in interface WriteBehind<K,V>

load

public V load(K key)
       throws java.lang.Exception
Description copied from interface: WriteBehind
Loads the value to be associated with the given key in the Cache using this CacheLoaderWriter instance.

Specified by:
load in interface WriteBehind<K,V>
Parameters:
key - the key that will map to the value returned
Returns:
the value to be mapped
Throws:
java.lang.Exception

write

public void write(K key,
                  V value)
           throws CacheWritingException
Description copied from interface: WriteBehind
Writes a single entry to the underlying system of record, maybe a brand new value or an update to an existing value

Specified by:
write in interface WriteBehind<K,V>
Throws:
CacheWritingException

delete

public void delete(K key)
            throws CacheWritingException
Description copied from interface: WriteBehind
Deletes a single entry from the underlying system of record.

Specified by:
delete in interface WriteBehind<K,V>
Throws:
CacheWritingException

stop

public void stop()
Description copied from interface: WriteBehind
Stop 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:
stop in interface WriteBehind<K,V>

setOperationsFilter

public void setOperationsFilter(OperationsFilter<SingleOperation<K,V>> filter)
Description copied from interface: WriteBehind
Set the operations filter that should be used.

Specified by:
setOperationsFilter in interface WriteBehind<K,V>
Parameters:
filter - the filter that will be used as of now

getQueueSize

public abstract long getQueueSize()
Gets the best estimate for items in the queue still awaiting processing. Not including elements currently processed

Specified by:
getQueueSize in interface WriteBehind<K,V>
Returns:
the amount of elements still awaiting processing.