hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r736426 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
Date Wed, 21 Jan 2009 21:51:46 GMT
Author: hairong
Date: Wed Jan 21 13:51:45 2009
New Revision: 736426

URL: http://svn.apache.org/viewvc?rev=736426&view=rev
Log:
HADOOP-5009. DataNode#shutdown sometimes leaves data block scanner verification log unclosed.
Contributed by Hairong Kuang.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=736426&r1=736425&r2=736426&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Jan 21 13:51:45 2009
@@ -685,6 +685,9 @@
     HADOOP-4967. Fixes a race condition in the JvmManager to do with killing
     tasks. (ddas)
 
+    HADOOP-5009. DataNode#shutdown sometimes leaves data block scanner
+    verification log unclosed. (hairong)
+
 Release 0.19.0 - 2008-11-18
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java?rev=736426&r1=736425&r2=736426&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
(original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
Wed Jan 21 13:51:45 2009
@@ -517,6 +517,7 @@
       verificationLog.updateCurNumLines();
     }
     
+    try {
     // update verification times from the verificationLog.
     while (logReader != null && logReader.hasNext()) {
       if (!datanode.shouldRun || Thread.interrupted()) {
@@ -527,6 +528,9 @@
         updateBlockInfo(entry);
       }
     }
+    } finally {
+      IOUtils.closeStream(logReader);
+    }
     
     /* Initially spread the block reads over half of 
      * MIN_SCAN_PERIOD so that we don't keep scanning the 
@@ -590,12 +594,12 @@
           } catch (InterruptedException ignored) {}
         }
       }
-      shutdown();
     } catch (RuntimeException e) {
       LOG.warn("RuntimeException during DataBlockScanner.run() : " +
                StringUtils.stringifyException(e));
       throw e;
     } finally {
+      shutdown();
       LOG.info("Exiting DataBlockScanner thread.");
     }
   }
@@ -783,8 +787,9 @@
     //This reads the current file and updates the count.
     void updateCurNumLines() {
       int count = 0;
+      Reader it = null;
       try {
-        for(Reader it = new Reader(true); it.hasNext(); count++) {
+        for(it = new Reader(true); it.hasNext(); count++) {
           it.next();
         }
       } catch (IOException e) {
@@ -793,6 +798,7 @@
         synchronized (this) {
           curNumLines = count;
         }
+        IOUtils.closeStream(it);
       }
     }
     

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java?rev=736426&r1=736425&r2=736426&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java Wed Jan
21 13:51:45 2009
@@ -599,10 +599,13 @@
     
     if(upgradeManager != null)
       upgradeManager.shutdownUpgrade();
-    if (blockScanner != null)
-      blockScanner.shutdown();
-    if (blockScannerThread != null) 
+    if (blockScannerThread != null) { 
       blockScannerThread.interrupt();
+      try {
+        blockScannerThread.join(3600000L); // wait for at most 1 hour
+      } catch (InterruptedException ie) {
+      }
+    }
     if (storage != null) {
       try {
         this.storage.unlockAll();



Mime
View raw message