T
- The generic type of the [R]elation.public class DefaultResourceLocator<T extends ILocatableResource<T>> extends Object implements IResourceLocator<T>
public NAME ( IIndexManager indexManager, String namespace, Long timestamp, Properties properties )
A relation is located using the IIndexStore.getGlobalRowStore(long)
and
materialized by supplying an IIndexManager
that will be able to
resolve the indices for the relation's view. Several different contexts are
handled:
IBigdataFederation
IRelation
will be resolved using the
IIndexStore.getGlobalRowStore(long)
and the
IBigdataFederation
as its IIndexManager
. The makes access to
a remote and potentially distributed IIndex
transparent to the
IRelation
. However, it is NOT possible to resolve local resources on
other JVMs - only scale-out indices registered against the
IBigdataFederation
.Journal
IRelation
will be resolved using the
Journal.getGlobalRowStore(long)
and will use the local index objects
directly.AbstractTask
AbstractTask
and override the locator to use
AbstractTask.getJournal()
as its index manager. This will give you
access to the local index object from within the concurrency control
mechanismTemporaryStore
Journal
. However,
TemporaryStore
s are also used to provide local resources for more
efficient data storage for a variety of purposes. When used in this manner,
you must explicitly notify the locator of the existence of the
TemporaryStore
in order to be able to resolve IRelation
s on
the TemporaryStore
. It is prudent to use a prefix for such local
resources that guarentees uniqueness, e.g., an UUID
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_CACHE_CAPACITY
The default #of recently located resources whose hard references will be
retained by the
LRUCache . |
protected static long |
DEFAULT_CACHE_TIMEOUT
The default timeout for stale entries in milliseconds.
|
protected IIndexManager |
indexManager |
protected static boolean |
INFO |
protected static org.apache.log4j.Logger |
log |
Constructor and Description |
---|
DefaultResourceLocator(IIndexManager indexManager,
IResourceLocator<T> delegate)
Ctor uses
DEFAULT_CACHE_CAPACITY and
DEFAULT_CACHE_TIMEOUT . |
DefaultResourceLocator(IIndexManager indexManager,
IResourceLocator<T> delegate,
int cacheCapacity,
long cacheTimeout) |
Modifier and Type | Method and Description |
---|---|
void |
add(IIndexManager indexManager)
Causes the
IIndexManager to be tested when attempting to resolve
a resource identifiers. |
void |
clearUnisolatedCache()
Discard unisolated resource views from the locator cache.
|
void |
discard(ILocatableResource<T> instance,
boolean destroyed)
Resources that hold hard references to local index objects MUST be
discarded during abort processing.
|
T |
locate(String namespace,
long timestamp)
Locate.
|
protected Properties |
locateResource(String namespace,
long timestamp,
AtomicReference<IIndexManager> foundOn)
Note: Caller is synchronized for this namespace.
|
protected Properties |
locateResourceOn(IIndexManager indexManager,
String namespace,
long timestamp)
Return the
Properties that will be used to configure the
IRelation instance. |
protected T |
newInstance(Class<? extends T> cls,
IIndexManager indexManager,
NT nt,
Properties properties)
Create a new view of the relation.
|
T |
putInstance(T instance)
Places the instance into the cache iff there is no existing instance in
the cache for the same resource and timestamp.
|
protected static final transient org.apache.log4j.Logger log
protected static final boolean INFO
protected final transient IIndexManager indexManager
protected static final transient int DEFAULT_CACHE_CAPACITY
LRUCache
.protected static final transient long DEFAULT_CACHE_TIMEOUT
public DefaultResourceLocator(IIndexManager indexManager, IResourceLocator<T> delegate)
DEFAULT_CACHE_CAPACITY
and
DEFAULT_CACHE_TIMEOUT
.indexManager
- delegate
- Optional IResourceLocator
to which unanswered requests
are then delegated.public DefaultResourceLocator(IIndexManager indexManager, IResourceLocator<T> delegate, int cacheCapacity, long cacheTimeout)
indexManager
- delegate
- Optional IResourceLocator
to which unanswered requests
are then delegated.cacheCapacity
- The capacity of the internal weak value cache.cacheTimeout
- The timeout in milliseconds for stale entries in that cache.public T locate(String namespace, long timestamp)
IResourceLocator
locate
in interface IResourceLocator<T extends ILocatableResource<T>>
namespace
- The resource namespace.timestamp
- The timestamp for the view.null
if the resource declaration could not be
resolved.protected Properties locateResource(String namespace, long timestamp, AtomicReference<IIndexManager> foundOn)
namespace
- The namespace for the resource.timestamp
- foundOn
- Used to pass back the IIndexManager
on which the
resource was found as a side-effect.protected Properties locateResourceOn(IIndexManager indexManager, String namespace, long timestamp)
Properties
that will be used to configure the
IRelation
instance. The RelationSchema.CLASS
property
MUST be defined and specified the runtime class that will be
instantiated.
Note: A null
return is an indication that the resource was
NOT FOUND on this IIndexManager
and the caller SHOULD try another
IIndexManager
.
indexManager
- namespace
- The resource identifier - this is the primary key.timestamp
- The timestamp of the resource view.Properties
iff there is a logical row for the given
namespace.protected T newInstance(Class<? extends T> cls, IIndexManager indexManager, NT nt, Properties properties)
indexManager
- The IIndexManager
that will be used to resolve the
named indices for the relation.nt
- The namespace and timestamp for the view of the relation.properties
- Configuration properties for the relation.public T putInstance(T instance)
Note: This is done automatically by AbstractResource
.
instance
- The instance.public void discard(ILocatableResource<T> instance, boolean destroyed)
IResourceLocator
discard
in interface IResourceLocator<T extends ILocatableResource<T>>
instance
- The instance whose cached references should be discarded.destroyed
- true
iff the resource was destroyed, in which
case the read-committed and unisolated views must also be
discarded even if they do not correspond to the
instance.public void clearUnisolatedCache()
IResourceLocator
clearUnisolatedCache
in interface IResourceLocator<T extends ILocatableResource<T>>
BLZG-2023, BLZG-2041.
public void add(IIndexManager indexManager)
IIndexManager
to be tested when attempting to resolve
a resource identifiers. The IIndexManager
will be automatically
cleared from the set of IIndexManager
s to be tested if its
reference is cleared by the JVM. If it becomes closed asynchronously then
a warning will be logged until its reference is cleared.
Note: The default IIndexManager
specified to the ctor normally
ensures that the global namespace is consistent (it is not possible to
have two indices or ILocatableResource
s with the same name).
When you add additional IIndexManager
s, the opportunity for an
inconsistent unified namespace is introduced. You can protect
yourself by ensuring that resources located on TemporaryStore
s
and the like are always created with a unique prefix, e.g., the
UUID
of the TemporaryStore
itself or a UUID
for
each container that is allocated on the TemporaryStore
.
indexManager
- Typically a TemporaryStore
or Journal
containing local resources.#locateResource(String)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.