Class AcknowledgeOnCheckpoint<ACKID extends Serializable>
- java.lang.Object
-
- org.apache.flink.streaming.connectors.gcp.pubsub.common.AcknowledgeOnCheckpoint<ACKID>
-
- Type Parameters:
ACKID- Type of Ids to acknowledge
- All Implemented Interfaces:
org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.streaming.api.checkpoint.ListCheckpointed<AcknowledgeIdsForCheckpoint<ACKID>>
public class AcknowledgeOnCheckpoint<ACKID extends Serializable> extends Object implements org.apache.flink.api.common.state.CheckpointListener, org.apache.flink.streaming.api.checkpoint.ListCheckpointed<AcknowledgeIdsForCheckpoint<ACKID>>
Helper class for SourceFunctions to acknowledge messages to external systems after a successful checkpoint.The mechanism for this source assumes that messages are identified by a unique ID. When messages are taken from the message queue, the message must not be dropped immediately from the external system, but must be retained until acknowledged. Messages that are not acknowledged within a certain time interval will be served again (to a different connection, established by the recovered source).
Note that this source can give no guarantees about message order in the case of failures, because messages that were retrieved but not yet acknowledged will be returned later again, after a set of messages that was not retrieved before the failure.
Internally, this class gathers the IDs of elements it emits. Per checkpoint, the IDs are stored and acknowledged when the checkpoint is complete. That way, no message is acknowledged unless it is certain that it has been successfully processed throughout the topology and the updates to any state caused by that message are persistent.
-
-
Constructor Summary
Constructors Constructor Description AcknowledgeOnCheckpoint(Acknowledger<ACKID> acknowledger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAcknowledgeId(ACKID id)voidnotifyCheckpointAborted(long checkpointId)voidnotifyCheckpointComplete(long checkpointId)intnumberOfOutstandingAcknowledgements()voidrestoreState(List<AcknowledgeIdsForCheckpoint<ACKID>> state)List<AcknowledgeIdsForCheckpoint<ACKID>>snapshotState(long checkpointId, long timestamp)
-
-
-
Constructor Detail
-
AcknowledgeOnCheckpoint
public AcknowledgeOnCheckpoint(Acknowledger<ACKID> acknowledger)
-
-
Method Detail
-
addAcknowledgeId
public void addAcknowledgeId(ACKID id)
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId)
- Specified by:
notifyCheckpointCompletein interfaceorg.apache.flink.api.common.state.CheckpointListener
-
notifyCheckpointAborted
public void notifyCheckpointAborted(long checkpointId)
- Specified by:
notifyCheckpointAbortedin interfaceorg.apache.flink.api.common.state.CheckpointListener
-
snapshotState
public List<AcknowledgeIdsForCheckpoint<ACKID>> snapshotState(long checkpointId, long timestamp)
- Specified by:
snapshotStatein interfaceorg.apache.flink.streaming.api.checkpoint.ListCheckpointed<ACKID extends Serializable>
-
restoreState
public void restoreState(List<AcknowledgeIdsForCheckpoint<ACKID>> state)
- Specified by:
restoreStatein interfaceorg.apache.flink.streaming.api.checkpoint.ListCheckpointed<ACKID extends Serializable>
-
numberOfOutstandingAcknowledgements
public int numberOfOutstandingAcknowledgements()
-
-