guoweiM commented on a change in pull request #13576: URL: https://github.com/apache/flink/pull/13576#discussion_r502990728
########## File path: flink-core/src/main/java/org/apache/flink/api/connector/sink/Sink.java ########## @@ -0,0 +1,94 @@ +/* + * 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.api.connector.sink; + +import org.apache.flink.annotation.Experimental; +import org.apache.flink.core.io.SimpleVersionedSerializer; +import org.apache.flink.metrics.MetricGroup; + +import java.util.List; +import java.util.Optional; + +/** + * This interface lets the sink developer build a simple sink topology, which could guarantee the exactly once + * semantics in both batch and stream execution mode if there is a {@link Committer} or {@link GlobalCommitter}. + * 1. The {@link Writer} is responsible for producing the committable. + * 2. The {@link Committer} is responsible for committing a single committable. + * 3. The {@link GlobalCommitter} is responsible for committing an aggregated committable, which we called the global + * committable. There is only one instance of the {@link GlobalCommitter}. + * Note: Developers need to ensure the idempotence of {@link Committer} and {@link GlobalCommitter}. + * + * @param <InputT> The type of the sink's input + * @param <CommT> The type of the committable data + * @param <GlobalCommT> The type of the aggregated committable + * @param <WriterStateT> The type of the writer's state + */ +@Experimental +public interface Sink<InputT, CommT, GlobalCommT, WriterStateT> { Review comment: Yes steven. At first I have same feeling as you. But I found that there may be four combinations: 1. `Writer` 2. `Writer` + `Committer` 3. `Writer` + `GlobalCommitter` 4. `Writer` + `Committer` + `GlobalCommitter` So we have to provide the four "different" `XXXSink` classes if we want provide all these pattern to the developer. For me I think it might too many on term of the number of a sink api. Actually I would like to say that this sink api is more like a "building topology" pattern. (Of course it is not so flexible currently). ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
