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 asJoinExecutorBaseandUnionExecutorBase.- Author:
- Andreas Schwarte
- See Also:
JoinExecutorBase,UnionExecutorBase
-
-
Field Summary
Fields Modifier and Type Field Description protected ThreadevaluationThreadprotected longexecutorIdprotected booleanfinishedprotected static org.slf4j.Loggerlogprotected static AtomicLongNEXT_EXECUTOR_IDprotected QueryInfoqueryInfoprotected CloseableIteration<T,QueryEvaluationException>rightIterprotected FedXQueueCursor<T>rightQueueprotected FederationEvalStrategystrategy
-
Constructor Summary
Constructors Constructor Description ParallelExecutorBase(QueryInfo queryInfo)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddResult(CloseableIteration<T,QueryEvaluationException> res)Handle the result appropriately, e.g.protected voidcheckTimeout()Checks whether the query execution has run into a timeout.voiddone()Inform the controlling instance that some job is done from a different thread.StringgetDisplayId()protected StringgetExecutorType()protected StringgetId()TgetNextElement()Gets the next element.QueryInfogetQueryInfo()Return the query info of the associated queryvoidhandleClose()Called byAbstractCloseableIteration.close()when it is called for the first time.booleanisFinished()Return true if this executor is finished or abortedprotected abstract voidperformExecution()Perform the parallel execution.voidrun()voidtoss(Exception e)Toss some exception to the controlling instanceStringtoString()-
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 Detail
-
log
protected static final org.slf4j.Logger log
-
NEXT_EXECUTOR_ID
protected static final AtomicLong NEXT_EXECUTOR_ID
-
strategy
protected final FederationEvalStrategy strategy
-
executorId
protected final long executorId
-
queryInfo
protected final QueryInfo queryInfo
-
evaluationThread
protected volatile Thread evaluationThread
-
rightQueue
protected FedXQueueCursor<T> rightQueue
-
rightIter
protected volatile CloseableIteration<T,QueryEvaluationException> rightIter
-
finished
protected volatile boolean finished
-
-
Constructor Detail
-
ParallelExecutorBase
public ParallelExecutorBase(QueryInfo queryInfo) throws QueryEvaluationException
- Throws:
QueryEvaluationException
-
-
Method Detail
-
performExecution
protected abstract void performExecution() throws ExceptionPerform the parallel execution. Note that this method must block until the execution is completed.- Throws:
Exception
-
addResult
public void addResult(CloseableIteration<T,QueryEvaluationException> res)
Description copied from interface:ParallelExecutorHandle the result appropriately, e.g. add it to the result iteration. Take care for synchronization in a multithreaded environment- Specified by:
addResultin interfaceParallelExecutor<T>
-
done
public void done()
Description copied from interface:ParallelExecutorInform the controlling instance that some job is done from a different thread. In most cases this is a no-op.- Specified by:
donein interfaceParallelExecutor<T>
-
toss
public void toss(Exception e)
Description copied from interface:ParallelExecutorToss some exception to the controlling instance- Specified by:
tossin interfaceParallelExecutor<T>
-
getNextElement
public T getNextElement() throws QueryEvaluationException
Description copied from class:LookAheadIterationGets the next element. Subclasses should implement this method so that it returns the next element.- Specified by:
getNextElementin classLookAheadIteration<T,QueryEvaluationException>- Returns:
- The next element, or null if no more elements are available.
- Throws:
QueryEvaluationException
-
checkTimeout
protected void checkTimeout() throws QueryInterruptedExceptionChecks whether the query execution has run into a timeout. If so, aQueryInterruptedExceptionis thrown.- Throws:
QueryInterruptedException
-
handleClose
public void handleClose() throws QueryEvaluationExceptionDescription copied from class:AbstractCloseableIterationCalled 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:
handleClosein classLookAheadIteration<T,QueryEvaluationException>- Throws:
QueryEvaluationException
-
isFinished
public boolean isFinished()
Return true if this executor is finished or aborted- Specified by:
isFinishedin interfaceParallelExecutor<T>- Returns:
- whether the executor is finished
-
getQueryInfo
public QueryInfo getQueryInfo()
Description copied from interface:ParallelExecutorReturn the query info of the associated query- Specified by:
getQueryInfoin interfaceParallelExecutor<T>- Returns:
- the query info
-
getId
protected String getId()
- Returns:
- a unique identifier of this execution
-
getDisplayId
public String getDisplayId()
-
getExecutorType
protected String getExecutorType()
- Returns:
- the executor type, e.g. "Join". Default "Executor"
-
-