com.bigdata.service
Class AbstractIndexCache<T extends IRangeQuery>

java.lang.Object
  extended by com.bigdata.service.AbstractIndexCache<T>
Type Parameters:
T -
Direct Known Subclasses:
IndexCache, LocalDataServiceFederation.DataServiceIndexCache, MetadataIndexCache

public abstract class AbstractIndexCache<T extends IRangeQuery>
extends Object

Abstract base class providing caching for IIndex like objects. A canonicalizing cache is used with weak references to the IIndexs back by a hard reference LRU cache. This tends to keep around views that are reused while letting references for unused views be cleared by the garbage collector in a timely manner.

Version:
$Id: AbstractIndexCache.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static boolean INFO
           
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
protected AbstractIndexCache(int capacity, long timeout)
           
 
Method Summary
protected  void dropIndexFromCache(String name)
          Drop the ITx.UNISOLATED and ITx.READ_COMMITTED entries for the named index from the cache.
 T getIndex(String name, long timestamp)
          Request a view of an index.
protected abstract  T newView(String name, long timestamp)
          Method is invoked on a cache miss and returns a view of the described index.
protected  void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

INFO

protected static final boolean INFO
Constructor Detail

AbstractIndexCache

protected AbstractIndexCache(int capacity,
                             long timeout)
Parameters:
capacity - The capacity of the backing LRU hard reference cache.
timeout - The timeout in milliseconds for stale entries in the cache.
See Also:
IBigdataClient.Options.CLIENT_INDEX_CACHE_CAPACITY, IBigdataClient.Options.CLIENT_INDEX_CACHE_TIMEOUT
Method Detail

newView

protected abstract T newView(String name,
                             long timestamp)
Method is invoked on a cache miss and returns a view of the described index.

Parameters:
name -
timestamp -
Returns:
The index view -or- null if the described index does not exist.

getIndex

public T getIndex(String name,
                  long timestamp)
Request a view of an index. If there is a cache miss then a new view will be created.

Note: ITx.READ_COMMITTED views are cached. Read-committed semantics are obtained by the indirection imposed by the IClientIndex, which converts a request by the client into a request against the appropriate IDataServices via task(s) submitted against those services.

Parameters:
name - The index name.
timestamp - The timestamp of the view.
Returns:
The index view -or- null if the described index does not exist.

dropIndexFromCache

protected void dropIndexFromCache(String name)
Drop the ITx.UNISOLATED and ITx.READ_COMMITTED entries for the named index from the cache.

Historical and transactional reads are still allowed, but we remove the read-committed or unisolated views from the cache once the index has been dropped. If a client wants them, it needs to re-request. If they have been re-registered on the metadata service then they will become available again.

Note: Operations against unisolated or read-committed indices will throw exceptions if they execute after the index was dropped.


shutdown

protected void shutdown()


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