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 asJoinExecutorBase
andUnionExecutorBase
.- Author:
- Andreas Schwarte
- See Also:
JoinExecutorBase
,UnionExecutorBase
-
-
Field Summary
Fields Modifier and Type Field Description protected Thread
evaluationThread
protected long
executorId
protected boolean
finished
protected static org.slf4j.Logger
log
protected static AtomicLong
NEXT_EXECUTOR_ID
protected QueryInfo
queryInfo
protected CloseableIteration<T,QueryEvaluationException>
rightIter
protected FedXQueueCursor<T>
rightQueue
protected FederationEvalStrategy
strategy
-
Constructor Summary
Constructors Constructor Description ParallelExecutorBase(QueryInfo queryInfo)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addResult(CloseableIteration<T,QueryEvaluationException> res)
Handle the result appropriately, e.g.protected void
checkTimeout()
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.String
getDisplayId()
protected String
getExecutorType()
protected String
getId()
T
getNextElement()
Gets the next element.QueryInfo
getQueryInfo()
Return the query info of the associated queryvoid
handleClose()
Called byAbstractCloseableIteration.close()
when it is called for the first time.boolean
isFinished()
Return true if this executor is finished or abortedprotected abstract void
performExecution()
Perform the parallel execution.void
run()
void
toss(Exception e)
Toss some exception to the controlling instanceString
toString()
-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
stream
-
-
-
-
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 Exception
Perform 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: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
public void toss(Exception e)
Description copied from interface:ParallelExecutor
Toss some exception to the controlling instance- Specified by:
toss
in interfaceParallelExecutor<T>
-
getNextElement
public T getNextElement() throws QueryEvaluationException
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
protected void checkTimeout() throws QueryInterruptedException
Checks whether the query execution has run into a timeout. If so, aQueryInterruptedException
is thrown.- Throws:
QueryInterruptedException
-
handleClose
public void handleClose() throws QueryEvaluationException
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
public QueryInfo 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
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"
-
-