fapaul commented on a change in pull request #18428: URL: https://github.com/apache/flink/pull/18428#discussion_r795704693
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/operators/sink/committables/CommittableCollector.java ########## @@ -0,0 +1,243 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.streaming.runtime.operators.sink.committables; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.functions.RuntimeContext; +import org.apache.flink.api.connector.sink2.Sink.InitContext; +import org.apache.flink.api.java.tuple.Tuple2; +import org.apache.flink.streaming.api.connector.sink2.CommittableMessage; +import org.apache.flink.streaming.api.connector.sink2.CommittableSummary; +import org.apache.flink.streaming.api.connector.sink2.CommittableWithLineage; + +import javax.annotation.Nullable; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.NavigableMap; +import java.util.TreeMap; +import java.util.stream.Collectors; + +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * This class is responsible to book-keep the committing progress across checkpoints and subtasks. + * It handles the emission of committables and the {@link CommittableSummary}. + * + * @param <CommT> type of committable + */ +@Internal +public class CommittableCollector<CommT> { + private static final long EOI = Long.MAX_VALUE; + /** Mapping of checkpoint id to {@link CheckpointCommittableManagerImpl}. */ + private final NavigableMap<Long, CheckpointCommittableManagerImpl<CommT>> + checkpointCommittables; + /** Denotes the subtask id the collector is running. */ + private final int subtaskId; Review comment: I'd prefer the current solution because during the lifetime of a `CommittableCollector` the `subtaskId` and `numberOfSubtassks` should never change. If I add them as parameters to the commit method it introduces room for errors. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
