Преглед изворни кода

HADOOP-3118. Fix Namenode NPE while loading fsimage after a cluster
upgrade from older disk format. (dhruba)



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@644189 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur пре 17 година
родитељ
комит
b232aeb703
2 измењених фајлова са 11 додато и 7 уклоњено
  1. 3 0
      CHANGES.txt
  2. 8 7
      src/java/org/apache/hadoop/dfs/FSEditLog.java

+ 3 - 0
CHANGES.txt

@@ -440,6 +440,9 @@ Trunk (unreleased changes)
 
     HADOOP-3114. Fix TestDFSShell on Windows. (Lohit Vijaya Renu via cdouglas)
 
+    HADOOP-3118.  Fix Namenode NPE while loading fsimage after a cluster 
+    upgrade from older disk format. (dhruba)
+
 Release 0.16.2 - 2008-04-02
 
   BUG FIXES

+ 8 - 7
src/java/org/apache/hadoop/dfs/FSEditLog.java

@@ -486,8 +486,9 @@ class FSEditLog {
             }
 
             // clientname, clientMachine and block locations of last block.
-            clientName = null;
-            clientMachine = null;
+            clientName = "";
+            clientMachine = "";
+            lastLocations = null;
             if (opcode == OP_ADD && logVersion <= -12) {
               UTF8 uu = new UTF8();
               UTF8 cl = new UTF8();
@@ -500,6 +501,8 @@ class FSEditLog {
               writables = aw.get();
               lastLocations = new DatanodeDescriptor[writables.length];
               System.arraycopy(writables, 0, lastLocations, 0, writables.length);
+            } else {
+              lastLocations = new DatanodeDescriptor[0];
             }
   
             // The open lease transaction re-creates a file if necessary.
@@ -507,10 +510,8 @@ class FSEditLog {
             if (FSNamesystem.LOG.isDebugEnabled()) {
               FSNamesystem.LOG.debug(opcode + ": " + name.toString() + 
                                      " numblocks : " + blocks.length +
-                                     " clientHolder " +  
-                                     ((clientName != null) ? clientName : "") +
-                                     " clientMachine " +
-                                     ((clientMachine != null) ? clientMachine : ""));
+                                     " clientHolder " +  clientName +
+                                     " clientMachine " + clientMachine);
             }
 
             old = fsDir.unprotectedDelete(path, mtime, null);
@@ -534,7 +535,7 @@ class FSEditLog {
                                         node.getPermissionStatus(),
                                         clientName, 
                                         clientMachine, 
-                                        null, 
+                                        null,
                                         lastLocations);
               fsDir.replaceNode(path, node, cons);
               fsNamesys.addLease(path, clientName);