Skip to content

Commit 180f969

Browse files
squitoMarcelo Vanzin
authored andcommitted
[SPARK-26094][CORE][STREAMING] createNonEcFile creates parent dirs.
## What changes were proposed in this pull request? We explicitly avoid files with hdfs erasure coding for the streaming WAL and for event logs, as hdfs EC does not support all relevant apis. However, the new builder api used has different semantics -- it does not create parent dirs, and it does not resolve relative paths. This updates createNonEcFile to have similar semantics to the old api. ## How was this patch tested? Ran tests with the WAL pointed at a non-existent dir, which failed before this change. Manually tested the new function with a relative path as well. Unit tests via jenkins. Closes #23092 from squito/SPARK-26094. Authored-by: Imran Rashid <irashid@cloudera.com> Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
1 parent 35f9163 commit 180f969

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,13 @@ private[spark] object SparkHadoopUtil {
466466
try {
467467
// Use reflection as this uses apis only avialable in hadoop 3
468468
val builderMethod = fs.getClass().getMethod("createFile", classOf[Path])
469-
val builder = builderMethod.invoke(fs, path)
469+
// the builder api does not resolve relative paths, nor does it create parent dirs, while
470+
// the old api does.
471+
if (!fs.mkdirs(path.getParent())) {
472+
throw new IOException(s"Failed to create parents of $path")
473+
}
474+
val qualifiedPath = fs.makeQualified(path)
475+
val builder = builderMethod.invoke(fs, qualifiedPath)
470476
val builderCls = builder.getClass()
471477
// this may throw a NoSuchMethodException if the path is not on hdfs
472478
val replicateMethod = builderCls.getMethod("replicate")

0 commit comments

Comments
 (0)