public abstract class AbstractStepTask extends DataServiceCallable<RuleStats> implements IStepTask, Cloneable
Modifier and Type | Field and Description |
---|---|
protected ActionEnum |
action |
protected IIndexManager |
indexManager |
protected IJoinNexusFactory |
joinNexusFactory |
protected static org.apache.log4j.Logger |
log |
protected IStep |
step |
Modifier | Constructor and Description |
---|---|
protected |
AbstractStepTask(ActionEnum action,
IJoinNexusFactory joinNexusFactory,
IStep step,
IIndexManager indexManager,
DataService dataService)
Base class handles submit either to the caller's
ExecutorService
or to the ConcurrencyManager IFF the task was submitted to a
DataService . |
Modifier and Type | Method and Description |
---|---|
AbstractStepTask |
clone()
Strengthens the return type and masquerades the
CloneNotSupportedException . |
protected Set<String> |
getIndexNames(Collection<IRelation> c)
Returns the names of the indices maintained by the relations.
|
protected Map<String,IBuffer<ISolution[]>> |
getMutationBuffers(IJoinNexus joinNexus,
Map<String,IRelation> relations)
Create the appropriate buffers to absorb writes by the rules in the
program that target an
IMutableRelation . |
protected Map<String,IRelation> |
getReadRelations(IIndexManager indexManager,
IStep step,
long timestamp)
Locate the distinct relation identifiers corresponding to the tail(s) of
each rule and resolve them to their relations.
|
protected Set<String> |
getWriteRelationNames(IStep step)
The set of distinct relations identified by the head of each rule in the
program.
|
protected Map<String,IRelation> |
getWriteRelations(IIndexManager indexManager,
IStep step,
long timestamp)
Locate the distinct relation identifiers corresponding to the head of
each rule and resolve them to their relations.
|
protected RuleStats |
runOne(IJoinNexus joinNexus,
IStep program,
Callable<RuleStats> task)
Run a single step (sequence of one).
|
protected RuleStats |
runParallel(IJoinNexus joinNexus,
IStep program,
List<Callable<RuleStats>> tasks)
Run program steps in parallel.
|
protected RuleStats |
runSequential(IJoinNexus joinNexus,
IStep program,
List<Callable<RuleStats>> tasks)
Run program steps in sequence.
|
Future<RuleStats> |
submit()
Run this task.
|
String |
toString() |
getDataService, isDataService, setDataService
getFederation, setFederation
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getFederation, setFederation
protected static final transient org.apache.log4j.Logger log
protected final ActionEnum action
protected final IJoinNexusFactory joinNexusFactory
protected IIndexManager indexManager
protected final IStep step
protected AbstractStepTask(ActionEnum action, IJoinNexusFactory joinNexusFactory, IStep step, IIndexManager indexManager, DataService dataService)
ExecutorService
or to the ConcurrencyManager
IFF the task was submitted to a
DataService
.
Note: The DataService
will notice the
IDataServiceCallable
interface and set a reference to
itself using DataServiceCallable.setDataService(DataService)
. submit()
notices this case and causes this task to be clone()
ed,
the ExecutorService
set on the clone, and the clone is then
submitted to the ConcurrencyManager
for the DataService
.
action
- Indicate whether this is a query or a mutation operation.joinNexusFactory
- Various goodies.step
- The rule or program.indexManager
- dataService
- non-null
iff the caller is already running on
a DataService
.IllegalArgumentException
- if action is null
.IllegalArgumentException
- if joinNexusFactory is null
.IllegalArgumentException
- if step is null
.protected RuleStats runParallel(IJoinNexus joinNexus, IStep program, List<Callable<RuleStats>> tasks) throws InterruptedException, ExecutionException
program
- tasks
- InterruptedException
ExecutionException
protected RuleStats runSequential(IJoinNexus joinNexus, IStep program, List<Callable<RuleStats>> tasks) throws InterruptedException, ExecutionException
program
- tasks
- InterruptedException
ExecutionException
protected RuleStats runOne(IJoinNexus joinNexus, IStep program, Callable<RuleStats> task) throws InterruptedException, ExecutionException
Note: use #runOne(IStep, Callable)
rather than either
#runParallel(IStep, List)
or #runSequential(IStep, List)
when there is only one task to execute in order to avoid an unnecessary
layering of the RuleStats
(this is due to a coupling between the
RuleStats
reporting structure and the control structure for
executing the tasks).
program
- tasks
- InterruptedException
ExecutionException
public Future<RuleStats> submit()
If we are executing on a DataService
then DataServiceCallable.getDataService()
will have been set automatically and the task will be submitted to the
ConcurrencyManager
for that DataService
.
This condition occurs when this Callable
is sent to the
DataService
using DataService.submit(Callable)
. In order
to gain access to the named indices for the relation, we have to wrap up
this Callable
as an AbstractTask
that declares the
appropriate timestamp and resources. The AbstractTask
is then
submitted to the ConcurrencyManager
for execution. Once the
AbstractTask
is actually running, the inner task
overrides the indexManager
to be
AbstractTask.getJournal()
. This provides access to the indices,
relations, etc. appropriate for the isolation level granted to the task
by the ConcurrencyManager
- without this step the
AbstractTask
will wind up using an IClientIndex
view and
lose the benefits of access to unisolated indices.
public AbstractStepTask clone()
CloneNotSupportedException
.protected Set<String> getWriteRelationNames(IStep step)
protected Map<String,IRelation> getWriteRelations(IIndexManager indexManager, IStep step, long timestamp)
timestamp
- The timestamp associated with the relation views on which the
rule(s) will write.RuntimeException
- if any relation can not be resolved.protected Map<String,IRelation> getReadRelations(IIndexManager indexManager, IStep step, long timestamp)
RuntimeException
- if any relation can not be resolved.protected Map<String,IBuffer<ISolution[]>> getMutationBuffers(IJoinNexus joinNexus, Map<String,IRelation> relations)
IMutableRelation
.IllegalStateException
- if the program is being executed as mutation.RuntimeException
- If a rule requires mutation for a relation (it will write on
the relation) and the corresponding entry in the map does not
implement IMutableRelation
.protected Set<String> getIndexNames(Collection<IRelation> c)
c
- A collection of IRelation
s.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.