Explorar o código

HDFS-637. DataNode sends a Success ack when block write fails. Contributed by Hairong Kuang.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@818294 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang %!s(int64=16) %!d(string=hai) anos
pai
achega
2c6aa4eb26

+ 1 - 0
CHANGES.txt

@@ -13,6 +13,7 @@ Trunk (unreleased changes)
   BUG FIXES
   HDFS-640. Fixed TestHDFSFileContextMainOperations.java build failure. (suresh)
 
+  HDFS-637. DataNode sends a Success ack when block write fails. (hairong)
 
 Release 0.21.0 - Unreleased
 

+ 8 - 2
src/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java

@@ -870,6 +870,7 @@ class BlockReceiver implements java.io.Closeable, FSConstants {
       final long startTime = ClientTraceLog.isInfoEnabled() ? System.nanoTime() : 0;
       while (running && datanode.shouldRun && !lastPacketInBlock) {
 
+        boolean isInterrupted = false;
         try {
             DataTransferProtocol.Status op = SUCCESS;
             boolean didRead = false;
@@ -897,7 +898,12 @@ class BlockReceiver implements java.io.Closeable, FSConstants {
                                 " for block " + block +
                                 " waiting for local datanode to finish write.");
                     }
-                    wait();
+                    try {
+                      wait();
+                    } catch (InterruptedException e) {
+                      isInterrupted = true;
+                      throw e;
+                    }
                   }
                   pkt = ackQueue.removeFirst();
                   expected = pkt.seqno;
@@ -920,7 +926,7 @@ class BlockReceiver implements java.io.Closeable, FSConstants {
               }
             }
 
-            if (Thread.interrupted()) {
+            if (Thread.interrupted() || isInterrupted) {
               /* The receiver thread cancelled this thread. 
                * We could also check any other status updates from the 
                * receiver thread (e.g. if it is ok to write to replyOut).