com.bigdata.resources
Class IndexManager.IndexCache

java.lang.Object
  extended by com.bigdata.cache.ConcurrentWeakValueCache<K,V>
      extended by com.bigdata.cache.ConcurrentWeakValueCacheWithTimeout<NT,ILocalBTreeView>
          extended by com.bigdata.resources.IndexManager.IndexCache
All Implemented Interfaces:
IConcurrentWeakValueCache<NT,ILocalBTreeView>
Enclosing class:
IndexManager

public class IndexManager.IndexCache
extends ConcurrentWeakValueCacheWithTimeout<NT,ILocalBTreeView>

Extends the ConcurrentWeakValueCache to track the earliest timestamp from which any local IIndex view is reading. This timestamp is reported by getRetentionTime(). The StoreManager uses this in StoreManager.purgeOldResources() to provide a "read lock" such that resources for in use views are not released.

Version:
$Id: IndexManager.java 5894 2012-01-27 13:44:53Z thompsonbry $
Author:
Bryan Thompson

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bigdata.cache.ConcurrentWeakValueCache
ConcurrentWeakValueCache.WeakRef<K,V>
 
Field Summary
 
Fields inherited from class com.bigdata.cache.ConcurrentWeakValueCache
DEBUG, INFO, log
 
Constructor Summary
IndexManager.IndexCache(int cacheCapacity, long cacheTimeout)
           
 
Method Summary
 long getRetentionTime()
          The earliest timestamp that MUST be retained for the read-historical indices in the cache and Long.MAX_VALUE if there are NO read-historical indices in the cache.
 ILocalBTreeView put(NT k, ILocalBTreeView v)
          Adds the key-value mapping to the cache.
 ILocalBTreeView putIfAbsent(NT k, ILocalBTreeView v)
          Adds the key-value mapping to the cache iff there is no entry for that key.
protected  WeakReference<ILocalBTreeView> removeMapEntry(NT k)
          Overridden to clear the retentionTime if the map entry corresponding to that timestamp is being removed from the map.
 
Methods inherited from class com.bigdata.cache.ConcurrentWeakValueCache
capacity, clear, containsKey, didUpdate, entryIterator, get, isRemoveClearedReferences, iterator, newWeakRef, remove, removeClearedEntries, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexManager.IndexCache

public IndexManager.IndexCache(int cacheCapacity,
                               long cacheTimeout)
Method Detail

getRetentionTime

public long getRetentionTime()
The earliest timestamp that MUST be retained for the read-historical indices in the cache and Long.MAX_VALUE if there are NO read-historical indices in the cache.

Note: Due to the concurrent operations of the garbage collector, this method MAY return a time that is earlier than necessary. This possibility arises because WeakReference values may be cleared at any time. There is no negative consequence to this behavior - it simply means that fewer resources will be released than might otherwise be possible. This "hole" can not be closed by polling the ReferenceQueue since it is not when the entries are removed from the map which matters, but when their WeakReference values are cleared. However, periodically clearing stale references using #clearStaleRefs() will keep down the size of that "hole".


put

public ILocalBTreeView put(NT k,
                           ILocalBTreeView v)
Description copied from class: ConcurrentWeakValueCache
Adds the key-value mapping to the cache.

Specified by:
put in interface IConcurrentWeakValueCache<NT,ILocalBTreeView>
Overrides:
put in class ConcurrentWeakValueCache<NT,ILocalBTreeView>
Parameters:
k - The key.
v - The value.
Returns:
The old value under the key -or- null if there is no entry under the key or if the entry under the key has has its reference cleared.

putIfAbsent

public ILocalBTreeView putIfAbsent(NT k,
                                   ILocalBTreeView v)
Description copied from class: ConcurrentWeakValueCache
Adds the key-value mapping to the cache iff there is no entry for that key. Note that a cleared reference under a key is treated in exactly the same manner as if there were no entry under the key (the entry under the key is replaced atomically).

Specified by:
putIfAbsent in interface IConcurrentWeakValueCache<NT,ILocalBTreeView>
Overrides:
putIfAbsent in class ConcurrentWeakValueCache<NT,ILocalBTreeView>
Parameters:
k - The key.
v - The value.
Returns:
the previous value associated with the specified key, or null if there was no mapping for the key or if the entry under the key has has its reference cleared.

removeMapEntry

protected WeakReference<ILocalBTreeView> removeMapEntry(NT k)
Overridden to clear the retentionTime if the map entry corresponding to that timestamp is being removed from the map.

Overrides:
removeMapEntry in class ConcurrentWeakValueCache<NT,ILocalBTreeView>
Parameters:
k - The key.


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.