gaoyunhaii commented on a change in pull request #18642:
URL: https://github.com/apache/flink/pull/18642#discussion_r800840707



##########
File path: 
flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/sink/utils/TestCommitRequest.java
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.connector.file.sink.utils;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.api.connector.sink2.Committer;
+
+/**
+ * A simple {@link Committer.CommitRequest} used for testing.
+ *
+ * @param <CommT>
+ */
+@PublicEvolving
+public class TestCommitRequest<CommT> implements 
Committer.CommitRequest<CommT> {

Review comment:
       Perhaps move this class to flink-core / test / 
org.apache.flink.api.connector.sink2.mocks and reuse this class for FileSink 
tests and KafkaSink tests? 

##########
File path: 
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/sink/writer/FileWriter.java
##########
@@ -206,7 +219,7 @@ public void write(IN element, Context context) throws 
IOException {
             if (!entry.getValue().isActive()) {
                 activeBucketIt.remove();
             } else {
-                committables.addAll(entry.getValue().prepareCommit(flush));
+                
committables.addAll(entry.getValue().prepareCommit(endOfInput));

Review comment:
       Might also change the parameter name of prepareCommit(boolean) to 
`endOfInput`

##########
File path: 
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/sink/writer/FileWriter.java
##########
@@ -179,7 +186,8 @@ private void updateActiveBucketId(String bucketId, 
FileWriterBucket<IN> restored
     }
 
     @Override
-    public void write(IN element, Context context) throws IOException {
+    public void write(IN element, SinkWriter.Context context)

Review comment:
       `SinkWriter.Context` -> `Context`  ? We have implemented the `SinkWriter`

##########
File path: 
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/sink/committer/FileCommitter.java
##########
@@ -48,9 +47,10 @@ public FileCommitter(BucketWriter<?, ?> bucketWriter) {
     }
 
     @Override
-    public List<FileSinkCommittable> commit(List<FileSinkCommittable> 
committables)
-            throws IOException {
-        for (FileSinkCommittable committable : committables) {
+    public void commit(Collection<CommitRequest<FileSinkCommittable>> requests)
+            throws IOException, InterruptedException {
+        for (CommitRequest<FileSinkCommittable> request : requests) {

Review comment:
       Perhaps we could handle the exceptions with 
`request.signalFailedWithKnownReason(e)` and other methods if it throws 
exception, or we create a follow-up issue to optimize the behavior of 
committing.




-- 
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]


Reply via email to