Browse Source

HDFS-3398. Client will not retry when primaryDN is down once it's just got pipeline. Contributed by Amith D K.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1343944 13f79535-47bb-0310-9956-ffa450edef68
Uma Maheswara Rao G 13 years ago
parent
commit
47a29c6329

+ 9 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java

@@ -507,8 +507,15 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
           }
           }
 
 
           // write out data to remote datanode
           // write out data to remote datanode
-          blockStream.write(buf.array(), buf.position(), buf.remaining());
-          blockStream.flush();
+          try {            
+            blockStream.write(buf.array(), buf.position(), buf.remaining());
+            blockStream.flush();   
+          } catch (IOException e) {
+            // HDFS-3398 treat primary DN is down since client is unable to 
+            // write to primary DN 
+            errorIndex = 0;
+            throw e;
+          }
           lastPacket = System.currentTimeMillis();
           lastPacket = System.currentTimeMillis();
           
           
           if (one.isHeartbeatPacket()) {  //heartbeat packet
           if (one.isHeartbeatPacket()) {  //heartbeat packet