Jelajahi Sumber

HDFS-661. DataNode upgrade fails on non-existant current directory. Contributed by Hairong Kuang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/branches/HDFS-265@820149 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang 15 tahun lalu
induk
melakukan
0c49b65844

+ 3 - 0
CHANGES.txt

@@ -95,6 +95,9 @@ Append branch (unreleased changes)
     HDFS-649. Check null pointers for DataTransferTest.  (Konstantin Boudnik
     HDFS-649. Check null pointers for DataTransferTest.  (Konstantin Boudnik
     via szetszwo)
     via szetszwo)
 
 
+    HDFS-661. DataNode upgrade fails on non-existant current directory.
+    (hairong)
+
 Trunk (unreleased changes)
 Trunk (unreleased changes)
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 3 - 0
src/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java

@@ -284,6 +284,9 @@ public class DataStorage extends Storage {
     rename(curDir, tmpDir);
     rename(curDir, tmpDir);
     // hard link finalized & rbw blocks
     // hard link finalized & rbw blocks
     linkAllBlocks(tmpDir, curDir);
     linkAllBlocks(tmpDir, curDir);
+    // create current directory if not exists
+    if (!curDir.exists() && !curDir.mkdirs())
+      throw new IOException("Cannot create directory " + curDir);
     // write version file
     // write version file
     this.layoutVersion = FSConstants.LAYOUT_VERSION;
     this.layoutVersion = FSConstants.LAYOUT_VERSION;
     assert this.namespaceID == nsInfo.getNamespaceID() :
     assert this.namespaceID == nsInfo.getNamespaceID() :