瀏覽代碼

HDFS-1202. DataBlockScanner throws NPE when updated before
initialized. (Todd Lipcon via dhruba)



git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-append@960816 13f79535-47bb-0310-9956-ffa450edef68

Dhruba Borthakur 15 年之前
父節點
當前提交
9ab389c825
共有 2 個文件被更改,包括 11 次插入5 次删除
  1. 3 0
      CHANGES.txt
  2. 8 5
      src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java

+ 3 - 0
CHANGES.txt

@@ -22,6 +22,9 @@ Release 0.20-append - Unreleased
     HDFS-1057.  Concurrent readers hit ChecksumExceptions if following 
     a writer to very end of file (Sam Rash via dhruba)
 
+    HDFS-1202.  DataBlockScanner throws NPE when updated before 
+    initialized. (Todd Lipcon via dhruba)
+
   IMPROVEMENTS
 
   BUG FIXES

+ 8 - 5
src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java

@@ -145,7 +145,7 @@ class DataBlockScanner implements Runnable {
     // initialized when the scanner thread is started.
   }
   
-  private synchronized boolean isInitiliazed() {
+  private synchronized boolean isInitialized() {
     return throttler != null;
   }
   
@@ -254,7 +254,7 @@ class DataBlockScanner implements Runnable {
 
   /** Adds block to list of blocks */
   synchronized void addBlock(Block block) {
-    if (!isInitiliazed()) {
+    if (!isInitialized()) {
       return;
     }
     
@@ -273,7 +273,7 @@ class DataBlockScanner implements Runnable {
   
   /** Deletes the block from internal structures */
   synchronized void deleteBlock(Block block) {
-    if (!isInitiliazed()) {
+    if (!isInitialized()) {
       return;
     }
     BlockScanInfo info = blockMap.get(block);
@@ -284,7 +284,7 @@ class DataBlockScanner implements Runnable {
 
   /** @return the last scan time */
   synchronized long getLastScanTime(Block block) {
-    if (!isInitiliazed()) {
+    if (!isInitialized()) {
       return 0;
     }
     BlockScanInfo info = blockMap.get(block);
@@ -305,6 +305,9 @@ class DataBlockScanner implements Runnable {
   private synchronized void updateScanStatus(Block block, 
                                              ScanType type,
                                              boolean scanOk) {
+    if (!isInitialized()) {
+      return;
+    }
     BlockScanInfo info = blockMap.get(block);
     
     if ( info != null ) {
@@ -955,7 +958,7 @@ class DataBlockScanner implements Runnable {
       if (blockScanner == null) {
         buffer.append("Periodic block scanner is not running. " +
                       "Please check the datanode log if this is unexpected.");
-      } else if (blockScanner.isInitiliazed()) {
+      } else if (blockScanner.isInitialized()) {
         blockScanner.printBlockReport(buffer, summary);
       } else {
         buffer.append("Periodic block scanner is not yet initialized. " +