Class ParallelExecutorBase<T>
java.lang.Object
org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration<E,X>
org.eclipse.rdf4j.common.iteration.LookAheadIteration<T,QueryEvaluationException>
org.eclipse.rdf4j.federated.evaluation.concurrent.ParallelExecutorBase<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
AutoCloseable
,Runnable
,CloseableIteration<T,
,QueryEvaluationException> Iteration<T,
,QueryEvaluationException> ParallelExecutor<T>
- Direct Known Subclasses:
JoinExecutorBase
,UnionExecutorBase
public abstract class ParallelExecutorBase<T>
extends LookAheadIteration<T,QueryEvaluationException>
implements ParallelExecutor<T>
Base class for common parallel executors such as
JoinExecutorBase
and UnionExecutorBase
.- Author:
- Andreas Schwarte
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected Thread
protected final long
protected boolean
protected static final org.slf4j.Logger
protected static final AtomicLong
protected final QueryInfo
protected CloseableIteration<T,
QueryEvaluationException> protected FedXQueueCursor<T>
protected final FederationEvalStrategy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Handle the result appropriately, e.g.protected void
Checks whether the query execution has run into a timeout.void
done()
Inform the controlling instance that some job is done from a different thread.protected String
protected String
getId()
Gets the next element.Return the query info of the associated queryvoid
Called byAbstractCloseableIteration.close()
when it is called for the first time.boolean
Return true if this executor is finished or abortedprotected abstract void
Perform the parallel execution.final void
run()
void
Toss some exception to the controlling instancetoString()
Methods inherited from class org.eclipse.rdf4j.common.iteration.LookAheadIteration
hasNext, next, remove
Methods inherited from class org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration
close, isClosed
-
Field Details
-
log
protected static final org.slf4j.Logger log -
NEXT_EXECUTOR_ID
-
strategy
-
executorId
protected final long executorId -
queryInfo
-
evaluationThread
-
rightQueue
-
rightIter
-
finished
protected volatile boolean finished
-
-
Constructor Details
-
ParallelExecutorBase
- Throws:
QueryEvaluationException
-
-
Method Details
-
run
public final void run() -
performExecution
Perform the parallel execution. Note that this method must block until the execution is completed.- Throws:
Exception
-
addResult
Description copied from interface:ParallelExecutor
Handle the result appropriately, e.g. add it to the result iteration. Take care for synchronization in a multithreaded environment- Specified by:
addResult
in interfaceParallelExecutor<T>
-
done
public void done()Description copied from interface:ParallelExecutor
Inform the controlling instance that some job is done from a different thread. In most cases this is a no-op.- Specified by:
done
in interfaceParallelExecutor<T>
-
toss
Description copied from interface:ParallelExecutor
Toss some exception to the controlling instance- Specified by:
toss
in interfaceParallelExecutor<T>
-
getNextElement
Description copied from class:LookAheadIteration
Gets the next element. Subclasses should implement this method so that it returns the next element.- Specified by:
getNextElement
in classLookAheadIteration<T,
QueryEvaluationException> - Returns:
- The next element, or null if no more elements are available.
- Throws:
QueryEvaluationException
-
checkTimeout
Checks whether the query execution has run into a timeout. If so, aQueryInterruptedException
is thrown.- Throws:
QueryInterruptedException
-
handleClose
Description copied from class:AbstractCloseableIteration
Called byAbstractCloseableIteration.close()
when it is called for the first time. This method is only called once on each iteration. By default, this method does nothing.- Overrides:
handleClose
in classLookAheadIteration<T,
QueryEvaluationException> - Throws:
QueryEvaluationException
-
isFinished
public boolean isFinished()Return true if this executor is finished or aborted- Specified by:
isFinished
in interfaceParallelExecutor<T>
- Returns:
- whether the executor is finished
-
getQueryInfo
Description copied from interface:ParallelExecutor
Return the query info of the associated query- Specified by:
getQueryInfo
in interfaceParallelExecutor<T>
- Returns:
- the query info
-
getId
- Returns:
- a unique identifier of this execution
-
getDisplayId
-
getExecutorType
- Returns:
- the executor type, e.g. "Join". Default "Executor"
-
toString
-