CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.net.cache
Class ReadWriteBackingMap.WriteQueue

java.lang.Object
  extended by CoherenceApplicationEdition
      extended by com.tangosol.net.cache.ReadWriteBackingMap.WriteQueue
Enclosing class:
ReadWriteBackingMap

public class ReadWriteBackingMap.WriteQueue
extends CoherenceApplicationEdition

A queue that only releases entries after a configurable period of time.

Author:
cp 2002.10.22

Nested Class Summary
 class ReadWriteBackingMap.WriteQueue.Entry
          A queue entry that is scheduled to come out of the front of the queue no earlier than some specific point in time.
 
Constructor Summary
protected ReadWriteBackingMap.WriteQueue()
          Construct a WriteQueue that holds write-behind entries.
 
Method Summary
 Object add(Object oKey, Object oValue)
          Add an entry to the queue.
 boolean containsKey(Object oKey)
           
protected  long getCutoffMillis()
          Determine the time before which all entries that were added are now eligable for removing from the queue.
 int getDelaySeconds()
           
protected  Map getEntryMap()
           
protected  List getKeyList()
           
protected  ReadWriteBackingMap.WriteQueue.Entry instantiateEntry(Object oKey)
          Factory pattern: instantiate a queue entry.
 boolean isEmpty()
           
 Map.Entry remove()
          Wait for item in the queue to ripen (to be ready to be removed), and when there is one and it is ripe, then remove and return it.
 Map.Entry remove(Object oKey)
          Remove a key from the queue if the key is in the queue.
 Map.Entry removeImmediate()
          Remove the first key from the queue immediately.
 Map.Entry removeNoWait()
          Check for a ripe or soft-ripe item in the queue, and if there is one, return it; otherwise, return null.
 void setDelaySeconds(int cSeconds)
          Specify the number of seconds that an entry added to the queue will sit in the queue before being removable ("ripe").
 int size()
           
 

Constructor Detail

ReadWriteBackingMap.WriteQueue

protected ReadWriteBackingMap.WriteQueue()
Construct a WriteQueue that holds write-behind entries.

Method Detail

getDelaySeconds

public int getDelaySeconds()
Returns:
the number of seconds that an entry added to the queue will sit in the queue before being removable ("ripe")

setDelaySeconds

public void setDelaySeconds(int cSeconds)
Specify the number of seconds that an entry added to the queue will sit in the queue before being removable ("ripe").

Parameters:
cSeconds - the number of seconds to wait before allowing an entry to be removed from the queue

add

public Object add(Object oKey,
                  Object oValue)
Add an entry to the queue.

Parameters:
oKey - the key object
oValue - the value object
Returns:
the old value of the existing entry, if such an entry existed at the time this method was invoked; null otherwise

remove

public Map.Entry remove(Object oKey)
Remove a key from the queue if the key is in the queue. This method is used, for example, if an item has actually been removed from the backing map.

Parameters:
oKey - the key object
Returns:
the corresponding entry in the queue or null if the specified key was not in the queue

removeImmediate

public Map.Entry removeImmediate()
Remove the first key from the queue immediately.

Returns:
the first entry in the queue or null if the queue is empty

remove

public Map.Entry remove()
Wait for item in the queue to ripen (to be ready to be removed), and when there is one and it is ripe, then remove and return it.

Returns:
the next item in the queue (it will only return null when the backing map is no longer active)

removeNoWait

public Map.Entry removeNoWait()
Check for a ripe or soft-ripe item in the queue, and if there is one, return it; otherwise, return null.

Unlike the remove(java.lang.Object) method, this method will also remove soft-ripe items as calculated using the write-batch factor. A soft-ripe item is an item that has been in the write-behind queue for at least the following duration:

 D' = (1.0 - F)*D
where:
 D = write-behind delay
 F = write-batch factor

Returns:
the next item in the queue if one is ripe or soft-ripe and if the backing map is active, otherwise null

size

public int size()
Returns:
the length of the queue

isEmpty

public boolean isEmpty()
Returns:
true if and only if the queue contains no items

containsKey

public boolean containsKey(Object oKey)
Parameters:
oKey - the key to look for
Returns:
true if and only if the queue contains the specified key

getEntryMap

protected Map getEntryMap()
Returns:
the set of items in the queue

getKeyList

protected List getKeyList()
Returns:
the list of items in the queue

getCutoffMillis

protected long getCutoffMillis()
Determine the time before which all entries that were added are now eligable for removing from the queue. Any entry whose "when-added" time falls on or before the cutoff is considered to be "ripe".

Returns:
the millisecond time value related to the system time from System.currentTimeMillis() to compare to entry when-added values to determine which entries are ripe

instantiateEntry

protected ReadWriteBackingMap.WriteQueue.Entry instantiateEntry(Object oKey)
Factory pattern: instantiate a queue entry.

Parameters:
oKey - the key for the new entry
Returns:
a new Entry

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation