From 76a60a007e056d6dc9a228d8cf1f20832225038c Mon Sep 17 00:00:00 2001 From: Parag Jain Date: Thu, 6 Oct 2016 18:14:00 -0500 Subject: [PATCH] create parent dir on HDFS if it does not exist (#3547) --- .../io/druid/storage/hdfs/HdfsDataSegmentPusher.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions-core/hdfs-storage/src/main/java/io/druid/storage/hdfs/HdfsDataSegmentPusher.java b/extensions-core/hdfs-storage/src/main/java/io/druid/storage/hdfs/HdfsDataSegmentPusher.java index 849135770c7..c89ccad2457 100644 --- a/extensions-core/hdfs-storage/src/main/java/io/druid/storage/hdfs/HdfsDataSegmentPusher.java +++ b/extensions-core/hdfs-storage/src/main/java/io/druid/storage/hdfs/HdfsDataSegmentPusher.java @@ -111,20 +111,24 @@ public class HdfsDataSegmentPusher implements DataSegmentPusher fs ); Path outDir = new Path(String.format("%s/%s", config.getStorageDirectory(), storageDir)); + + // Create parent if it does not exist, recreation is not an error + fs.mkdirs(outDir.getParent()); + if (!fs.rename(tmpFile.getParent(), outDir)) { if (!fs.delete(tmpFile.getParent(), true)) { - log.error("Failed to delete temp directory[%s]", tmpFile); + log.error("Failed to delete temp directory[%s]", tmpFile.getParent()); } if (fs.exists(outDir)) { log.info( "Unable to rename temp directory[%s] to segment directory[%s]. It is already pushed by a replica task.", - tmpFile, + tmpFile.getParent(), outDir ); } else { throw new IOException(String.format( "Failed to rename temp directory[%s] and segment directory[%s] is not present.", - tmpFile, + tmpFile.getParent(), outDir )); }