HS - The generic type of the value returned by Callable.call()
for the subtask.M - The generic type of the master task implementation class.E - The generic type of the elements in the chunks stored in the
BlockingBuffer.L - The generic type of the key used to lookup a subtask in the
internal map (must be unique and must implement hashCode() and
equals() per their contracts).public abstract class AbstractSubtask<HS extends AbstractSubtaskStats,M extends AbstractMasterTask<? extends AbstractMasterStats<L,HS>,E,? extends AbstractSubtask,L>,E,L> extends Object implements Callable<HS>
AbstractMasterTask
handles the protocol for startup and termination of the subtask. A concrete
implementation must handle the chunks of elements being drained from the
subtask's buffer via handleChunk(Object[]).| Modifier and Type | Field and Description |
|---|---|
protected BlockingBuffer<E[]> |
buffer
The buffer on which the
master is writing. |
protected long |
lastChunkAvailableNanos
The timestamp at
IAsynchronousIterator.hasNext(long, TimeUnit)
last returned true when queried with a timeout of
AbstractMasterTask.sinkPollTimeoutNanos nanoseconds. |
protected long |
lastChunkNanos
The timestamp at which a chunk was last written on the buffer for this
sink by the master.
|
protected L |
locator
The unique key for the subtask.
|
protected static org.apache.log4j.Logger |
log |
protected M |
master
The master.
|
protected IAsynchronousIterator<E[]> |
src
The iterator draining the
buffer. |
protected HS |
stats
The statistics used by this task.
|
| Constructor and Description |
|---|
AbstractSubtask(M master,
L locator,
BlockingBuffer<E[]> buffer) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
awaitPending()
Wait until any asynchronous processing for the subtask is done.
|
HS |
call() |
protected void |
cancelRemoteTask(boolean mayInterruptIfRunning)
Cancel the remote task.
|
protected abstract boolean |
handleChunk(E[] chunk)
Process a chunk from the buffer.
|
protected void |
handleRedirect(E[] chunk,
Throwable cause)
This method MUST be invoked if a sink receives a
"stale locator exception" within
handleChunk(Object[]). |
protected abstract void |
notifyClientOfRedirect(L locator,
Throwable cause)
Notify the client that the locator is stale.
|
String |
toString() |
protected static final transient org.apache.log4j.Logger log
protected final M extends AbstractMasterTask<? extends AbstractMasterStats<L,HS>,E,? extends AbstractSubtask,L> master
protected final L locator
protected final BlockingBuffer<E[]> buffer
master is writing.protected final IAsynchronousIterator<E[]> src
protected final HS extends AbstractSubtaskStats stats
protected volatile long lastChunkNanos
protected volatile long lastChunkAvailableNanos
IAsynchronousIterator.hasNext(long, TimeUnit)
last returned true when queried with a timeout of
AbstractMasterTask.sinkPollTimeoutNanos nanoseconds. This tests
whether or not a chunk is available and is used to help decide if the
sink has become idle. (A sink with an available chunk is never idle.)public AbstractSubtask(M master, L locator, BlockingBuffer<E[]> buffer)
public HS call() throws Exception
call in interface Callable<HS extends AbstractSubtaskStats>Exceptionprotected void awaitPending()
throws InterruptedException
InterruptedExceptionprotected void cancelRemoteTask(boolean mayInterruptIfRunning)
throws InterruptedException
InterruptedExceptionprotected void handleRedirect(E[] chunk, Throwable cause) throws InterruptedException
handleChunk(Object[]).
This method asynchronously closes the sink, so that no further
data may be written on it by setting the cause on
BlockingBuffer.abort(Throwable). Next, the current chunk is
placed onto the master's redirectQueue and the sink's buffer is
drained, transferring all chunks which can be read from that buffer onto
the master's redirectQueue.
chunk - The chunk which the sink was processing when it discovered
that it need to redirect its outputs to a different sink (that
is, a chunk which it had already read from its buffer and
hence which needs to be redirected now).cause - The stale locator exception.InterruptedExceptionprotected abstract boolean handleChunk(E[] chunk) throws Exception
true iff the task should exit immediately.ExceptionCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.