|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.relation.locator.AbstractCachingResourceLocator<T>
public abstract class AbstractCachingResourceLocator<T extends ILocatableResource>
Abstract base class for IResourceLocators with caching. The cache
uses WeakReferences so that cache entries will be cleared if the
referenced item is cleared.
| Field Summary | |
|---|---|
protected static boolean |
INFO
|
protected static org.apache.log4j.Logger |
log
|
| Constructor Summary | |
|---|---|
protected |
AbstractCachingResourceLocator(int capacity,
long timeout)
|
| Method Summary | |
|---|---|
int |
capacity()
The cache capacity. |
protected boolean |
clear(String namespace,
long timestamp)
Clears any resource having the same namespace and timestamp from the cache. |
protected T |
get(String namespace,
long timestamp)
Looks up the resource in the cache (thread-safe since the underlying cache is thread-safe). |
protected void |
put(T resource)
Places the resource in the cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.bigdata.relation.locator.IResourceLocator |
|---|
locate |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
protected static final boolean INFO
| Constructor Detail |
|---|
protected AbstractCachingResourceLocator(int capacity,
long timeout)
capacity - The cache capacity.timeout - The timeout in milliseconds for stale entries.| Method Detail |
|---|
public final int capacity()
protected T get(String namespace,
long timestamp)
namespace - timestamp -
null iff it is not in the cache.protected void put(T resource)
Note: The underlying cache is thread-safe. However, when adding an entry
to the cache the caller MUST be synchronized on the named resource, use
get(String, long) to determine that there is no such entry in
the cache, and then put(ILocatableResource) the entry.
Note: Read committed views are allowed into the cache.
For a Journal, this depends on Journal#getIndex(name,timestamp) returning a ReadCommittedView for an index so that the view does in fact have read-committed semantics.
For a federation, read-committed semantics are achieved by the IClientIndex implementations since they always make standoff requests to one (or more) data services. Those requests allow the data service to resolve the then most recent view for the index for each request.
resource - The resource.
protected boolean clear(String namespace,
long timestamp)
Note: The caller MUST be synchronized on the named resource.
true iff there was an entry in the cache for the
same resource namespace and timestamp, in which case it was
cleared from the cache.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||