vamsikarnika commented on code in PR #19904:
URL: https://github.com/apache/hudi/pull/19904#discussion_r3991110400
##########
hudi-hadoop-common/src/test/java/org/apache/hudi/common/util/TestFileIOUtils.java:
##########
@@ -98,6 +101,61 @@ public void testGetConfiguredLocalDirs() {
envMaps.get("LOCAL_DIRS"));
}
+ @Test
+ public void testGetConfiguredLocalDirsPrefersSparkLocalDirs() {
+ Map<String, String> envMaps = mutableEnv();
+ String originalContainerId = envMaps.get("CONTAINER_ID");
+ String originalLocalDirs = envMaps.get("LOCAL_DIRS");
+ String originalSparkLocalDirs = envMaps.get("SPARK_LOCAL_DIRS");
+ try {
+ // Not under YARN: SPARK_LOCAL_DIRS is used in preference to
java.io.tmpdir.
+ envMaps.remove("CONTAINER_ID");
+ envMaps.remove("LOCAL_DIRS");
+ envMaps.put("SPARK_LOCAL_DIRS", "/spark-dir-1");
+ assertEquals("/spark-dir-1", String.join("",
FileIOUtils.getConfiguredLocalDirs()));
+
+ // Comma separated values are split, as they are for YARN.
+ envMaps.put("SPARK_LOCAL_DIRS", "/spark-dir-1,/spark-dir-2");
+ assertEquals(Arrays.asList("/spark-dir-1", "/spark-dir-2"),
+ Arrays.asList(FileIOUtils.getConfiguredLocalDirs()));
+
+ // YARN keeps precedence when both are present.
+ envMaps.put("CONTAINER_ID", "container_xxx");
+ envMaps.put("LOCAL_DIRS", "/yarn-dir");
+ assertEquals("/yarn-dir", String.join("",
FileIOUtils.getConfiguredLocalDirs()));
+
+ // Neither set: unchanged fallback to java.io.tmpdir.
+ envMaps.remove("CONTAINER_ID");
Review Comment:
Good catch — refactored `testGetConfiguredLocalDirs` to reuse `mutableEnv()`
instead of keeping a second copy of the reflection lookup.
--
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]