Flink对Offset的管理,有两种方式:
1.Checkpointing disabled 完全依赖于kafka自身的API
2.Checkpointing enabled 当checkpoint做完的时候,会将offset提交给kafka or zk
本文只针对于第二种,Checkpointing enabled
FlinkKafkaConsumerBase中的 notifyCheckpointComplete
@Override
//当checkpoint完成的时候,此方法会被调用
public final void notifyCheckpointComplete(long checkpointId) throws Exception {
if (!running) {
LOG.debug("notifyCheckpointComplete() called on closed source");
return;
}
final AbstractFetcher<?, ?> fetcher = this.kafkaFetcher;
if (fetcher == null) {
LOG.debug("notifyCheckpointComplete() called on uninitialized source");
return;
}
if (offsetCommitMode == OffsetCommitMode.ON_CHECKPOINTS) {
// only one commit operation must be in progress
if (LOG.isDebugEnabled()) {
LOG.debug("Committing offsets to Kafka/ZooKeeper for checkpoint " + checkpointId);
}
try {
final int posInMap = pendingOffsetsToCommit.indexOf(checkpointId);
if (posInMap == -1) {
LOG.warn("Received confirmation for unk

本文详细介绍了在启用了Checkpointing的Flink中,如何在检查点完成后将offset提交给Kafka或ZooKeeper。主要涉及FlinkKafkaConsumerBase的notifyCheckpointComplete方法及其调用链,包括offset的提交流程,以及在offset提交过程中可能出现的情况和处理方式。
最低0.47元/天 解锁文章
1989

被折叠的 条评论
为什么被折叠?



