Explorar o código

Fix HADOOP-5156 in branch 0.19.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.19@740136 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang %!s(int64=16) %!d(string=hai) anos
pai
achega
aa5d7411c8

+ 3 - 0
CHANGES.txt

@@ -82,6 +82,9 @@ Release 0.19.1 - Unreleased
     HADOOP-5034. NameNode should send both replication and deletion requests
     to DataNode in one reply to a heartbeat. (hairong)
 
+    HADOOP-5156. TestHeartbeatHandling uses MiiDFSCluster.getNamesystem()
+    which does not exit in branch 0.19 and 0.20. (hairong)
+
 Release 0.19.0 - 2008-11-18
 
   INCOMPATIBLE CHANGES

+ 17 - 9
src/test/org/apache/hadoop/hdfs/NNThroughputBenchmark.java

@@ -726,10 +726,13 @@ public class NNThroughputBenchmark {
      */
     void sendHeartbeat() throws IOException {
       // register datanode
-      DatanodeCommand cmd = nameNode.sendHeartbeat(
+      DatanodeCommand[] cmds = nameNode.sendHeartbeat(
           dnRegistration, DF_CAPACITY, DF_USED, DF_CAPACITY - DF_USED, 0, 0);
-      if(cmd != null)
-        LOG.debug("sendHeartbeat Name-node reply: " + cmd.getAction());
+      if(cmds != null) {
+        for (DatanodeCommand cmd : cmds ) {
+          LOG.debug("sendHeartbeat Name-node reply: " + cmd.getAction());
+        }
+      }
     }
 
     boolean addBlock(Block blk) {
@@ -757,13 +760,18 @@ public class NNThroughputBenchmark {
      */
     int replicateBlocks() throws IOException {
       // register datanode
-      DatanodeCommand cmd = nameNode.sendHeartbeat(
+      DatanodeCommand[] cmds = nameNode.sendHeartbeat(
           dnRegistration, DF_CAPACITY, DF_USED, DF_CAPACITY - DF_USED, 0, 0);
-      if(cmd == null || cmd.getAction() != DatanodeProtocol.DNA_TRANSFER)
-        return 0;
-      // Send a copy of a block to another datanode
-      BlockCommand bcmd = (BlockCommand)cmd;
-      return transferBlocks(bcmd.getBlocks(), bcmd.getTargets());
+      if (cmds != null) {
+        for (DatanodeCommand cmd : cmds) {
+          if (cmd.getAction() == DatanodeProtocol.DNA_TRANSFER) {
+            // Send a copy of a block to another datanode
+            BlockCommand bcmd = (BlockCommand)cmd;
+            return transferBlocks(bcmd.getBlocks(), bcmd.getTargets());
+          }
+        }
+      }
+      return 0;
     }
 
     /**

+ 1 - 1
src/test/org/apache/hadoop/hdfs/server/namenode/TestHeartbeatHandling.java

@@ -27,7 +27,7 @@ public class TestHeartbeatHandling extends TestCase {
     final MiniDFSCluster cluster = new MiniDFSCluster(conf, 1, true, null);
     try {
       cluster.waitActive();
-      final FSNamesystem namesystem = cluster.getNamesystem();
+      final FSNamesystem namesystem = cluster.getNameNode().namesystem;
       final DatanodeRegistration nodeReg = cluster.getDataNodes().get(0).dnRegistration;
       DatanodeDescriptor dd = namesystem.getDatanode(nodeReg);