zhuzhurk commented on code in PR #21796:
URL: https://github.com/apache/flink/pull/21796#discussion_r1091471400
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/sink/FileSink.java:
##########
@@ -130,7 +131,8 @@
implements StatefulSink<IN, FileWriterBucketState>,
TwoPhaseCommittingSink<IN, FileSinkCommittable>,
WithCompatibleState,
- WithPreCommitTopology<IN, FileSinkCommittable> {
+ WithPreCommitTopology<IN, FileSinkCommittable>,
+ SupportsConcurrentExecutionAttempts {
Review Comment:
It's better add some test cases as a guard for future changes to verify that
the results are correct when speculative execution happens on FileSink.
##########
flink-connectors/flink-connector-files/src/test/java/org/apache/flink/connector/file/table/PartitionTempFileManagerTest.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.table;
+
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.util.List;
+import java.util.function.BiPredicate;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link PartitionTempFileManager}. */
+class PartitionTempFileManagerTest {
+
+ @TempDir private java.nio.file.Path tmpPath;
+
+ @Test
+ void testListTaskTemporaryPaths() throws Exception {
+ // only accept task-0-attempt-1
+ final BiPredicate<Integer, Integer> taskAttemptFilter =
+ (subtaskIndex, attemptNumber) -> subtaskIndex == 0 &&
attemptNumber == 1;
+
+ final FileSystem fs = FileSystem.get(tmpPath.toUri());
+ fs.mkdirs(new Path(tmpPath.toUri() + "/task-0-attempt-0")); // invalid
attempt number
+ fs.mkdirs(new Path(tmpPath.toUri() + "/task-0-attempt-1")); // valid
+ fs.mkdirs(new Path(tmpPath.toUri() + "/task-1-attempt-0")); // invalid
subtask index
+ fs.mkdirs(new Path(tmpPath.toUri() + "/.task-0-attempt-1")); //
invisible dir
+ fs.mkdirs(new Path(tmpPath.toUri() + "/_SUCCESS")); // not a task dir
+
+ final List<Path> taskTmpPaths =
+ PartitionTempFileManager.listTaskTemporaryPaths(
+ fs, new Path(tmpPath.toUri()), taskAttemptFilter);
+ final List<String> taskDirs =
+
taskTmpPaths.stream().map(Path::getName).collect(Collectors.toList());
+ assertThat(taskDirs).hasSize(1).contains("task-0-attempt-1");
Review Comment:
contains -> containsExactly
##########
flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemOutputFormat.java:
##########
@@ -37,12 +38,17 @@
import static org.apache.flink.util.Preconditions.checkNotNull;
/**
- * File system {@link OutputFormat} for batch job. It commit in {@link
#finalizeGlobal(int)}.
+ * File system {@link OutputFormat} for batch job. It commits in {@link
+ * #finalizeGlobal(FinalizationContext)}.
*
* @param <T> The type of the consumed records.
*/
@Internal
-public class FileSystemOutputFormat<T> implements OutputFormat<T>,
FinalizeOnMaster, Serializable {
+public class FileSystemOutputFormat<T>
+ implements OutputFormat<T>,
+ FinalizeOnMaster,
+ Serializable,
+ SupportsConcurrentExecutionAttempts {
Review Comment:
I know you have done e2e test. But it's better add some test cases as a
guard for future changes to verify that the results are correct when
speculative execution happens on FileSystemOutputFormat.
--
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]