Class AbstractIterativeTask<S extends Function,OT>
- java.lang.Object
-
- org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable
-
- org.apache.flink.runtime.operators.BatchTask<S,OT>
-
- org.apache.flink.runtime.iterative.task.AbstractIterativeTask<S,OT>
-
- All Implemented Interfaces:
Terminable
,CheckpointableTask
,CoordinatedTask
,TaskInvokable
,TaskContext<S,OT>
- Direct Known Subclasses:
IterationHeadTask
,IterationIntermediateTask
,IterationTailTask
public abstract class AbstractIterativeTask<S extends Function,OT> extends BatchTask<S,OT> implements Terminable
The abstract base class for all tasks able to participate in an iteration.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
isSolutionSetUpdate
protected boolean
isWorksetIteration
protected boolean
isWorksetUpdate
protected LongSumAggregator
worksetAggregator
protected BlockingBackChannel
worksetBackChannel
-
Fields inherited from class org.apache.flink.runtime.operators.BatchTask
accumulatorMap, broadcastInputReaders, broadcastInputSerializers, chainedTasks, config, driver, eventualOutputs, inputComparators, inputIterators, inputReaders, inputs, inputSerializers, iterativeBroadcastInputs, iterativeInputs, localStrategies, LOG, output, resettableInputs, running, runtimeUdfContext, stub, tempBarriers
-
-
Constructor Summary
Constructors Constructor Description AbstractIterativeTask(Environment environment)
Create an Invokable task and set its environment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
brokerKey()
void
cancel()
This method is called when a task is canceled either as a result of a user abort or an execution failure.protected void
closeLocalStrategiesAndCaches()
DistributedRuntimeUDFContext
createRuntimeContext(OperatorMetricGroup metrics)
protected Collector<OT>
createSolutionSetUpdateOutputCollector(Collector<OT> delegate)
Creates a new solution set update output collector.protected Collector<OT>
createWorksetUpdateOutputCollector()
protected Collector<OT>
createWorksetUpdateOutputCollector(Collector<OT> delegate)
Creates a newWorksetUpdateOutputCollector
.protected int
currentIteration()
RuntimeAggregatorRegistry
getIterationAggregators()
protected void
incrementIterationCounter()
protected boolean
inFirstIteration()
protected void
initialize()
void
requestTermination()
void
run()
boolean
terminationRequested()
protected void
verifyEndOfSuperstepState()
-
Methods inherited from class org.apache.flink.runtime.operators.BatchTask
cancelChainedTasks, clearReaders, clearWriters, closeChainedTasks, closeUserCode, constructLogString, createInputIterator, excludeFromReset, formatLogString, getContainingTask, getDriverComparator, getInput, getInputSerializer, getIOManager, getLastOutputCollector, getLastTasksConfig, getMemoryManager, getMetricGroup, getNumTaskInputs, getOutputCollector, getOutputCollector, getStub, getTaskConfig, getTaskManagerInfo, initBroadcastInputReaders, initBroadcastInputsSerializers, initInputReaders, initInputsSerializersAndComparators, initLocalStrategies, initOutputs, initOutputs, initStub, instantiateUserCode, invoke, logAndThrowException, openChainedTasks, openUserCode, readAndSetBroadcastInput, releaseBroadcastVariables, resetAllInputs, setLastOutputCollector
-
Methods inherited from class org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable
abortCheckpointOnBarrier, cleanUp, dispatchOperatorEvent, getCurrentNumberOfSubtasks, getEnvironment, getExecutionConfig, getIndexInSubtaskGroup, getJobConfiguration, getTaskConfiguration, getUserCodeClassLoader, isUsingNonBlockingInput, maybeInterruptOnCancel, notifyCheckpointAbortAsync, notifyCheckpointCompleteAsync, notifyCheckpointSubsumedAsync, restore, triggerCheckpointAsync, triggerCheckpointOnBarrier
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.operators.TaskContext
getExecutionConfig, getUserCodeClassLoader
-
-
-
-
Field Detail
-
worksetAggregator
protected LongSumAggregator worksetAggregator
-
worksetBackChannel
protected BlockingBackChannel worksetBackChannel
-
isWorksetIteration
protected boolean isWorksetIteration
-
isWorksetUpdate
protected boolean isWorksetUpdate
-
isSolutionSetUpdate
protected boolean isSolutionSetUpdate
-
-
Constructor Detail
-
AbstractIterativeTask
public AbstractIterativeTask(Environment environment)
Create an Invokable task and set its environment.- Parameters:
environment
- The environment assigned to this invokable.
-
-
Method Detail
-
initialize
protected void initialize() throws Exception
-
run
public void run() throws Exception
-
closeLocalStrategiesAndCaches
protected void closeLocalStrategiesAndCaches()
- Overrides:
closeLocalStrategiesAndCaches
in classBatchTask<S extends Function,OT>
-
createRuntimeContext
public DistributedRuntimeUDFContext createRuntimeContext(OperatorMetricGroup metrics)
- Overrides:
createRuntimeContext
in classBatchTask<S extends Function,OT>
-
inFirstIteration
protected boolean inFirstIteration()
-
currentIteration
protected int currentIteration()
-
incrementIterationCounter
protected void incrementIterationCounter()
-
brokerKey
public String brokerKey()
-
getIterationAggregators
public RuntimeAggregatorRegistry getIterationAggregators()
-
verifyEndOfSuperstepState
protected void verifyEndOfSuperstepState() throws IOException
- Throws:
IOException
-
terminationRequested
public boolean terminationRequested()
- Specified by:
terminationRequested
in interfaceTerminable
-
requestTermination
public void requestTermination()
- Specified by:
requestTermination
in interfaceTerminable
-
cancel
public void cancel() throws Exception
Description copied from interface:TaskInvokable
This method is called when a task is canceled either as a result of a user abort or an execution failure. It can be overwritten to respond to shut down the user code properly.
-
createWorksetUpdateOutputCollector
protected Collector<OT> createWorksetUpdateOutputCollector(Collector<OT> delegate)
Creates a newWorksetUpdateOutputCollector
.This collector is used by
IterationIntermediateTask
orIterationTailTask
to update the workset.If a non-null delegate is given, the new
Collector
will write to the solution set and also call collect(T) of the delegate.- Parameters:
delegate
- null -OR- the delegate on which to call collect() by the newly created collector- Returns:
- a new
WorksetUpdateOutputCollector
-
createSolutionSetUpdateOutputCollector
protected Collector<OT> createSolutionSetUpdateOutputCollector(Collector<OT> delegate)
Creates a new solution set update output collector.This collector is used by
IterationIntermediateTask
orIterationTailTask
to update the solution set of workset iterations. Depending on the task configuration, either a fast (non-probing)SolutionSetFastUpdateOutputCollector
or normal (re-probing)SolutionSetUpdateOutputCollector
is created.If a non-null delegate is given, the new
Collector
will write back to the solution set and also call collect(T) of the delegate.- Parameters:
delegate
- null -OR- a delegate collector to be called by the newly created collector- Returns:
- a new
SolutionSetFastUpdateOutputCollector
orSolutionSetUpdateOutputCollector
-
-