You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by tzulitai <gi...@git.apache.org> on 2017/01/26 06:21:23 UTC

[GitHub] flink pull request #3031: [FLINK-4616] Added functionality through which wat...

Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3031#discussion_r97758477
  
    --- Diff: flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumerBase.java ---
    @@ -345,39 +345,39 @@ public void snapshotState(FunctionSnapshotContext context) throws Exception {
     			LOG.debug("snapshotState() called on closed source");
     		} else {
     
    -			offsetsStateForCheckpoint.clear();
    +			offsetsAndWatermarksStateForCheckpoint.clear();
     
     			final AbstractFetcher<?, ?> fetcher = this.kafkaFetcher;
     			if (fetcher == null) {
     				// the fetcher has not yet been initialized, which means we need to return the
    -				// originally restored offsets or the assigned partitions
    +				// originally restored offsets and watermarks or the assigned partitions
     
    -				if (restoreToOffset != null) {
    +				if (restoreToOffsetAndWatermark != null) {
     
    -					for (Map.Entry<KafkaTopicPartition, Long> kafkaTopicPartitionLongEntry : restoreToOffset.entrySet()) {
    -						offsetsStateForCheckpoint.add(
    -								Tuple2.of(kafkaTopicPartitionLongEntry.getKey(), kafkaTopicPartitionLongEntry.getValue()));
    +					for (Map.Entry<KafkaTopicPartition, Tuple2<Long, Long>> kafkaTopicPartitionOffsetAndWatermark : restoreToOffsetAndWatermark.entrySet()) {
    +						offsetsAndWatermarksStateForCheckpoint.add(
    +								Tuple2.of(kafkaTopicPartitionOffsetAndWatermark.getKey(), kafkaTopicPartitionOffsetAndWatermark.getValue()));
    --- End diff --
    
    Having a specific checkpoint state object will also be helpful for code readability in situations like this one (it's quite tricky to understand quickly what the key / value refers to, as well as some of the `f0`, `f1` calls in other parts of the PR. I know the previous code used `f0` and `f1` also, but I think it's a good opportunity to improve that).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---