hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r755035 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/DFSClient.java src/test/org/apache/hadoop/hdfs/TestLeaseRecovery2.java
Date Mon, 16 Mar 2009 23:11:10 GMT
Author: hairong
Date: Mon Mar 16 23:11:09 2009
New Revision: 755035

URL: http://svn.apache.org/viewvc?rev=755035&view=rev
Log:
Fixed IOException while executing hadoop fs -touchz fileName by making sure that the lease
renewal thread exits before dfs client closes. Contributed by Hairong Kuang.


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
    hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestLeaseRecovery2.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=755035&r1=755034&r2=755035&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Mon Mar 16 23:11:09 2009
@@ -1007,6 +1007,10 @@
     HADOOP-5493. The shuffle copier threads return the codecs back to the pool when the
     shuffle completes. (Jothi Padmanabhan via ddas)
 
+    HADOOP-5414. Fixes IO exception while executing hadoop fs -touchz fileName by
+    making sure that lease renewal thread exits before dfs client exits.
+    (hairong)
+ 
 Release 0.19.2 - Unreleased
 
   BUG FIXES

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java?rev=755035&r1=755034&r2=755035&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java Mon Mar 16 23:11:09 2009
@@ -207,6 +207,10 @@
     if(clientRunning) {
       leasechecker.close();
       clientRunning = false;
+      try {
+        leasechecker.interruptAndJoin();
+      } catch (InterruptedException ie) {
+      }
   
       // close connections to the namenode
       RPC.stopProxy(rpcNamenode);
@@ -928,9 +932,18 @@
       pendingCreates.remove(src);
     }
     
-    synchronized void interrupt() {
-      if (daemon != null) {
-        daemon.interrupt();
+    void interruptAndJoin() throws InterruptedException {
+      Daemon daemonCopy = null;
+      synchronized (this) {
+        if (daemon != null) {
+          daemon.interrupt();
+          daemonCopy = daemon;
+        }
+      }
+     
+      if (daemonCopy != null) {
+        LOG.debug("Wait for lease checker to terminate");
+        daemonCopy.join();
       }
     }
 
@@ -946,8 +959,6 @@
           }
         }
       }
-      
-      interrupt();
     }
 
     private void renew() throws IOException {
@@ -965,7 +976,7 @@
      */
     public void run() {
       long lastRenewed = 0;
-      while (clientRunning) {
+      while (clientRunning && !Thread.interrupted()) {
         if (System.currentTimeMillis() - lastRenewed > (LEASE_SOFTLIMIT_PERIOD / 2)) {
           try {
             renew();

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestLeaseRecovery2.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestLeaseRecovery2.java?rev=755035&r1=755034&r2=755035&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestLeaseRecovery2.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestLeaseRecovery2.java Mon Mar 16 23:11:09
2009
@@ -80,8 +80,8 @@
       // sync file
       AppendTestUtil.LOG.info("sync");
       stm.sync();
-      AppendTestUtil.LOG.info("leasechecker.interrupt()");
-      dfs.dfs.leasechecker.interrupt();
+      AppendTestUtil.LOG.info("leasechecker.interruptAndJoin()");
+      dfs.dfs.leasechecker.interruptAndJoin();
 
       // set the soft limit to be 1 second so that the
       // namenode triggers lease recovery on next attempt to write-for-open.



Mime
View raw message