@Internal public class SourceCoordinator<SplitT extends org.apache.flink.api.connector.source.SourceSplit,EnumChkT> extends Object implements OperatorCoordinator
OperatorCoordinator for the Source.
The SourceCoordinator provides an event loop style thread model to interact with
the Flink runtime. The coordinator ensures that all the state manipulations are made by its event
loop thread. It also helps keep track of the necessary split assignments history per subtask to
simplify the SplitEnumerator implementation.
The coordinator maintains a SplitEnumeratorContxt and shares it
with the enumerator. When the coordinator receives an action request from the Flink runtime, it
sets up the context, and calls corresponding method of the SplitEnumerator to take actions.
OperatorCoordinator.Context, OperatorCoordinator.Provider, OperatorCoordinator.SubtaskGatewayNO_CHECKPOINT| 构造器和说明 |
|---|
SourceCoordinator(String operatorName,
org.apache.flink.api.connector.source.Source<?,SplitT,EnumChkT> source,
SourceCoordinatorContext<SplitT> context,
CoordinatorStore coordinatorStore) |
SourceCoordinator(String operatorName,
org.apache.flink.api.connector.source.Source<?,SplitT,EnumChkT> source,
SourceCoordinatorContext<SplitT> context,
CoordinatorStore coordinatorStore,
org.apache.flink.api.common.eventtime.WatermarkAlignmentParams watermarkAlignmentParams) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
checkpointCoordinator(long checkpointId,
CompletableFuture<byte[]> result)
Takes a checkpoint of the coordinator.
|
void |
close()
This method is called when the coordinator is disposed.
|
void |
handleEventFromOperator(int subtask,
OperatorEvent event)
Hands an OperatorEvent coming from a parallel Operator instances (one of the parallel
subtasks).
|
void |
notifyCheckpointAborted(long checkpointId)
We override the method here to remove the checked exception.
|
void |
notifyCheckpointComplete(long checkpointId)
We override the method here to remove the checked exception.
|
void |
resetToCheckpoint(long checkpointId,
byte[] checkpointData)
Resets the coordinator to the given checkpoint.
|
void |
start()
Starts the coordinator.
|
void |
subtaskFailed(int subtaskId,
Throwable reason)
Called when one of the subtasks of the task running the coordinated operator goes through a
failover (failure / recovery cycle).
|
void |
subtaskReady(int subtask,
OperatorCoordinator.SubtaskGateway gateway)
This is called when a subtask of the Operator becomes ready to receive events, both after
initial startup and after task failover.
|
void |
subtaskReset(int subtaskId,
long checkpointId)
Called if a task is recovered as part of a partial failover, meaning a failover
handled by the scheduler's failover strategy (by default recovering a pipelined region).
|
public SourceCoordinator(String operatorName, org.apache.flink.api.connector.source.Source<?,SplitT,EnumChkT> source, SourceCoordinatorContext<SplitT> context, CoordinatorStore coordinatorStore)
public SourceCoordinator(String operatorName, org.apache.flink.api.connector.source.Source<?,SplitT,EnumChkT> source, SourceCoordinatorContext<SplitT> context, CoordinatorStore coordinatorStore, org.apache.flink.api.common.eventtime.WatermarkAlignmentParams watermarkAlignmentParams)
public void start()
throws Exception
OperatorCoordinatorstart 在接口中 OperatorCoordinatorException - Any exception thrown from this method causes a full job failure.public void close()
throws Exception
OperatorCoordinatorclose 在接口中 AutoCloseableclose 在接口中 OperatorCoordinatorExceptionpublic void handleEventFromOperator(int subtask,
OperatorEvent event)
OperatorCoordinatorhandleEventFromOperator 在接口中 OperatorCoordinatorpublic void subtaskFailed(int subtaskId,
@Nullable
Throwable reason)
OperatorCoordinatorThis method is called every time there is a failover of a subtasks, regardless of whether there it is a partial failover or a global failover.
subtaskFailed 在接口中 OperatorCoordinatorpublic void subtaskReset(int subtaskId,
long checkpointId)
OperatorCoordinatorIn contrast to this method, the OperatorCoordinator.resetToCheckpoint(long, byte[]) method is called
in the case of a global failover, which is the case when the coordinator (JobManager) is
recovered.
subtaskReset 在接口中 OperatorCoordinatorpublic void subtaskReady(int subtask,
OperatorCoordinator.SubtaskGateway gateway)
OperatorCoordinatorSubtaskGateway can be used to send
events to the executed subtask.
The given SubtaskGateway is bound to that specific execution attempt that became
ready. All events sent through the gateway target that execution attempt; if the attempt is
no longer running by the time the event is sent, then the events are failed.
subtaskReady 在接口中 OperatorCoordinatorpublic void checkpointCoordinator(long checkpointId,
CompletableFuture<byte[]> result)
OperatorCoordinatorTo confirm the checkpoint and store state in it, the given CompletableFuture must
be completed with the state. To abort or dis-confirm the checkpoint, the given CompletableFuture must be completed exceptionally. In any case, the given CompletableFuture must be completed in some way, otherwise the checkpoint will not progress.
The semantics are defined as follows:
checkpointCoordinator 在接口中 OperatorCoordinatorpublic void notifyCheckpointComplete(long checkpointId)
OperatorCoordinatorCheckpointListener.notifyCheckpointComplete(long) for more detail semantic of the
method.notifyCheckpointComplete 在接口中 org.apache.flink.api.common.state.CheckpointListenernotifyCheckpointComplete 在接口中 OperatorCoordinatorpublic void notifyCheckpointAborted(long checkpointId)
OperatorCoordinatorCheckpointListener.notifyCheckpointAborted(long) for more detail semantic of the
method.notifyCheckpointAborted 在接口中 org.apache.flink.api.common.state.CheckpointListenernotifyCheckpointAborted 在接口中 OperatorCoordinatorpublic void resetToCheckpoint(long checkpointId,
@Nullable
byte[] checkpointData)
throws Exception
OperatorCoordinatorThis method is called in the case of a global failover of the system, which means a
failover of the coordinator (JobManager). This method is not invoked on a partial
failover; partial failovers call the OperatorCoordinator.subtaskReset(int, long) method for the
involved subtasks.
This method is expected to behave synchronously with respect to other method calls and
calls to Context methods. For example, Events being sent by the Coordinator after
this method returns are assumed to take place after the checkpoint that was restored.
This method is called with a null state argument in the following situations:
In both cases, the coordinator should reset to an empty (new) state.
Restoring to a checkpoint is a way of confirming that the checkpoint is complete. It is safe to commit side-effects that are predicated on checkpoint completion after this call.
Even if no call to OperatorCoordinator.notifyCheckpointComplete(long) happened, the checkpoint can
still be complete (for example when a system failure happened directly after committing the
checkpoint, before calling the OperatorCoordinator.notifyCheckpointComplete(long) method).
resetToCheckpoint 在接口中 OperatorCoordinatorExceptionCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.