瀏覽代碼

HADOOP-973. Improve some error messages in namenode, to help debug a NullPointerException. Contributed by Dhruba.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@508581 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 年之前
父節點
當前提交
be0bf37f6e
共有 2 個文件被更改,包括 21 次插入1 次删除
  1. 4 0
      CHANGES.txt
  2. 17 1
      src/java/org/apache/hadoop/dfs/FSDataset.java

+ 4 - 0
CHANGES.txt

@@ -49,6 +49,10 @@ Trunk (unreleased changes)
 14. HADOOP-476.  Rewrite contrib/streaming command-line processing,
     improving parameter validation.  (Sanjay Dahiya via cutting)
 
+15. HADOOP-973.  Improve error messages in Namenode.  This should help
+    to track down a problem that was appearing as a
+    NullPointerException.  (Dhruba Borthakur via cutting) 
+
 
 Branch 0.11 (unreleased)
 

+ 17 - 1
src/java/org/apache/hadoop/dfs/FSDataset.java

@@ -515,8 +515,24 @@ class FSDataset implements FSConstants {
         File f;
         synchronized (this) {
           f = getFile(invalidBlks[i]);
+          if (f == null) {
+            throw new IOException("Unexpected error trying to delete block "
+                                  + invalidBlks[i] + 
+                                  ". Block not found in blockMap.");
+          }
           FSVolume v = volumeMap.get(invalidBlks[i]);
-          v.clearPath(f.getParentFile());
+          if (v == null) {
+            throw new IOException("Unexpected error trying to delete block "
+                                  + invalidBlks[i] + 
+                                  ". No volume for this block.");
+          }
+          File parent = f.getParentFile();
+          if (parent == null) {
+            throw new IOException("Unexpected error trying to delete block "
+                                  + invalidBlks[i] + 
+                                  ". Parent not found for file " + f + ".");
+          }
+          v.clearPath(parent);
           blockMap.remove(invalidBlks[i]);
           volumeMap.remove(invalidBlks[i]);
         }