CoherenceTM v3.4
Copyright© 2000-2008 by Oracle Corporation

com.tangosol.net.cache
Class ReadWriteBackingMap.ReadQueue

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

public class ReadWriteBackingMap.ReadQueue
extends CoherenceApplicationEdition

A queue of keys that should be read from the underlying CacheStore.

Author:
jh 2005.02.08

Constructor Summary
protected ReadWriteBackingMap.ReadQueue()
          Construct a ReadQueue.
 
Method Summary
 boolean add(java.lang.Object oKey)
          Add a key to the queue.
 void clear()
          Remove all keys from the queue.
protected  java.util.List getKeyList()
          Return a list of keys in the queue.
protected  java.util.Map getKeyMap()
          Return a map of keys in the queue.
 java.lang.Object peek()
          Wait for a key to be added to the queue and return it without removing it from the queue.
 boolean remove(java.lang.Object oKey)
          Remove a key from the queue if the key is in the queue.
protected  ReadWriteBackingMap.ReadLatch select(long cWaitMillis)
          Select the next key from the refresh-ahead queue that is a candidate for an asynchronous load.
 java.lang.String toString()
          For debugging purposes, present the queue in human-readable format.
 

Constructor Detail

ReadWriteBackingMap.ReadQueue

protected ReadWriteBackingMap.ReadQueue()
Construct a ReadQueue.

Method Detail

add

public boolean add(java.lang.Object oKey)
Add a key to the queue. This method has no effect if the key is already queued.

Parameters:
oKey - the key object
Returns:
true if the key was added to the queue; false otherwise

peek

public java.lang.Object peek()
Wait for a key to be added to the queue and return it without removing it from the queue.

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

remove

public boolean remove(java.lang.Object oKey)
Remove a key from the queue if the key is in the queue.

Parameters:
oKey - the key object
Returns:
true if the key was removed from the queue; false otherwise

select

protected ReadWriteBackingMap.ReadLatch select(long cWaitMillis)
Select the next key from the refresh-ahead queue that is a candidate for an asynchronous load. A key is a candidate if it can be locked "quickly".

This method performs the selection process by iterating through the refresh-ahead queue starting with the first key in the queue. If the queue is empty, this method will block until a key is added to the queue. A key is skipped if it cannot be locked within the specified wait time.

If a candidate key is found, a new ReadLatch for the key is placed in the control map and returned; otherwise, null is returned.

Parameters:
cWaitMillis - the maximum amount of time (in milliseconds) to wait for a lock on the key to be acquired
Returns:
a ReadLatch for the selected key or null if a candidate key was not found

clear

public void clear()
Remove all keys from the queue.


toString

public java.lang.String toString()
For debugging purposes, present the queue in human-readable format.

Returns:
a String representation of this object

getKeyList

protected java.util.List getKeyList()
Return a list of keys in the queue.

Returns:
a list of keys in the queue

getKeyMap

protected java.util.Map getKeyMap()
Return a map of keys in the queue.

Note: The map returned from this method is not thread-safe; therefore, a lock on this ReadQueue must be obtained before accessing the map

Returns:
a map of keys in the queue

CoherenceTM v3.4
Copyright© 2000-2008 by Oracle Corporation