beryllw commented on code in PR #3617:
URL: https://github.com/apache/fluss/pull/3617#discussion_r3542095853


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/utils/FlinkConnectorOptionsUtils.java:
##########
@@ -201,13 +202,38 @@ public static long parseTimestamp(String timestampStr, 
String optionKey, ZoneId
 
     public static String getClientScannerIoTmpDir(
             Configuration flussConf, 
org.apache.flink.configuration.Configuration flinkConfig) {
-        if (!flussConf.contains(CLIENT_SCANNER_IO_TMP_DIR)) {
-            if (flinkConfig.contains(TMP_DIRS)) {
-                // pass flink io tmp dir to fluss client.
-                return new File(flinkConfig.get(CoreOptions.TMP_DIRS), 
"/fluss").getAbsolutePath();
+        return getClientScannerIoTmpDir(flussConf, flinkConfig, 0);
+    }
+
+    public static String getClientScannerIoTmpDir(
+            Configuration flussConf,
+            org.apache.flink.configuration.Configuration flinkConfig,
+            int taskIndex) {
+        return flussConf
+                .getOptional(CLIENT_SCANNER_IO_TMP_DIR)
+                .orElseGet(
+                        () -> {
+                            String[] flinkTmpDirs = 
getFlinkIoTmpDirs(flinkConfig);
+                            int idx = taskIndex % flinkTmpDirs.length;
+                            return new File(flinkTmpDirs[idx], 
"/fluss").getAbsolutePath();
+                        });
+    }
+
+    private static String[] getFlinkIoTmpDirs(
+            org.apache.flink.configuration.Configuration flinkConfig) {
+        if (flinkConfig.contains(TMP_DIRS)) {
+            String[] paths = splitPaths(flinkConfig.get(CoreOptions.TMP_DIRS));
+            if (paths.length > 0) {
+                return paths;
             }
         }
-        return flussConf.getString(CLIENT_SCANNER_IO_TMP_DIR);
+        return new String[] {System.getProperty("java.io.tmpdir")};
+    }
+
+    private static String[] splitPaths(@Nonnull String separatedPaths) {

Review Comment:
   Flink already provides a built-in helper for splitting multiple directories 
here — ConfigurationUtils.splitPaths (and the wrapper parseTempDirectories). It 
keeps the separator handling consistent with Flink internals, so we could 
probably just reuse it and avoid maintaining a separate splitting logic. What 
do you think?



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