public abstract class CheckpointCommitter extends Object implements Serializable
The current checkpointing mechanism is ill-suited for sinks relying on backends that do not support roll-backs. When dealing with such a system, while trying to get exactly-once semantics, one may neither commit data while creating the snapshot (since another sink instance may fail, leading to a replay on the same data) nor when receiving a checkpoint-complete notification (since a subsequent failure would leave us with no knowledge as to whether data was committed or not).
A CheckpointCommitter can be used to solve the second problem by saving whether an instance committed all data belonging to a checkpoint. This data must be stored in a backend that is persistent across retries (which rules out Flink's state mechanism) and accessible from all machines, like a database or distributed file.
There is no mandate as to how the resource is shared; there may be one resource for all Flink jobs, or one for each job/operator/-instance separately. This implies that the resource must not be cleaned up by the system itself, and as such should kept as small as possible.
Modifier and Type | Field and Description |
---|---|
protected String |
jobId |
protected static org.slf4j.Logger |
LOG |
protected String |
operatorId |
Constructor and Description |
---|
CheckpointCommitter() |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes the resource/connection to it.
|
abstract void |
commitCheckpoint(int subtaskIdx,
long checkpointID)
Mark the given checkpoint as completed in the resource.
|
abstract void |
createResource()
Creates/opens/connects to the resource that is used to store information.
|
abstract boolean |
isCheckpointCommitted(int subtaskIdx,
long checkpointID)
Checked the resource whether the given checkpoint was committed completely.
|
abstract void |
open()
Opens/connects to the resource, and possibly creates it beforehand.
|
void |
setJobId(String id)
Internally used to set the job ID after instantiation.
|
void |
setOperatorId(String id)
Internally used to set the operator ID after instantiation.
|
protected static final org.slf4j.Logger LOG
protected String jobId
protected String operatorId
public void setJobId(String id) throws Exception
id
- Exception
public void setOperatorId(String id) throws Exception
id
- Exception
public abstract void open() throws Exception
Exception
public abstract void close() throws Exception
Exception
public abstract void createResource() throws Exception
Exception
public abstract void commitCheckpoint(int subtaskIdx, long checkpointID) throws Exception
subtaskIdx
- the index of the subtask responsible for committing the checkpoint.checkpointID
- the id of the checkpoint to be committed.Exception
public abstract boolean isCheckpointCommitted(int subtaskIdx, long checkpointID) throws Exception
subtaskIdx
- the index of the subtask responsible for committing the checkpoint.checkpointID
- the id of the checkpoint we are interested in.Exception
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.