ACKID- Type of Ids to acknowledge
public class AcknowledgeOnCheckpoint<ACKID extends Serializable> extends Object implements CheckpointListener, ListCheckpointed<AcknowledgeIdsForCheckpoint<ACKID>>
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 and Description|
|Modifier and Type||Method and Description|
This method is called as a notification once a distributed checkpoint has been aborted.
Notifies the listener that the checkpoint with the given
Restores the state of the function or operator to that of a previous checkpoint.
Gets the current state of the function.
public void addAcknowledgeId(ACKID id)
public void notifyCheckpointComplete(long checkpointId)
checkpointIdcompleted and was committed.
These notifications are "best effort", meaning they can sometimes be skipped. To behave
properly, implementers need to follow the "Checkpoint Subsuming Contract". Please see the
class-level JavaDocs for details.
Please note that checkpoints may generally overlap, so you cannot assume that the
notifyCheckpointComplete() call is always for the latest prior checkpoint (or snapshot) that
was taken on the function/operator implementing this interface. It might be for a checkpoint
that was triggered earlier. Implementing the "Checkpoint Subsuming Contract" (see above)
properly handles this situation correctly as well.
Please note that throwing exceptions from this method will not cause the completed checkpoint to be revoked. Throwing exceptions will typically cause task/job failure and trigger recovery.
public void notifyCheckpointAborted(long checkpointId)
Important: The fact that a checkpoint has been aborted does NOT mean that the data
and artifacts produced between the previous checkpoint and the aborted checkpoint are to be
discarded. The expected behavior is as if this checkpoint was never triggered in the first
place, and the next successful checkpoint simply covers a longer time span. See the
"Checkpoint Subsuming Contract" in the
class-level JavaDocs for
These notifications are "best effort", meaning they can sometimes be skipped.
This method is very rarely necessary to implement. The "best effort" guarantee, together with the fact that this method should not result in discarding any data (per the "Checkpoint Subsuming Contract") means it is mainly useful for earlier cleanups of auxiliary resources. One example is to pro-actively clear a local per-checkpoint state cache upon checkpoint failure.
public List<AcknowledgeIdsForCheckpoint<ACKID>> snapshotState(long checkpointId, long timestamp)
The returned list should contain one entry for redistributable unit of state. See the
class docs for an illustration how list-style state redistribution
As special case, the returned list may be null or empty (if the operator has no state) or it may contain a single element (if the operator state is indivisible).
ListCheckpointed<AcknowledgeIdsForCheckpoint<ACKID extends Serializable>>
checkpointId- The ID of the checkpoint - a unique and monotonously increasing value.
timestamp- The wall clock timestamp when the checkpoint was triggered by the master.
public void restoreState(List<AcknowledgeIdsForCheckpoint<ACKID>> state)
The given state list will contain all the sub states that this parallel instance of
the function needs to handle. Refer to the
class docs for an
illustration how list-style state redistribution works.
public int numberOfOutstandingAcknowledgements()
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.