Browse Source

Merge -r 755369:755370 to move the change of HADOOP-5479 from main to branch 0.19.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.19@755375 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang 16 years ago
parent
commit
bda2df45aa

+ 3 - 2
CHANGES.txt

@@ -74,9 +74,10 @@ Release 0.19.2 - Unreleased
     HADOOP-5449. Fixes the history cleaner thread. 
     HADOOP-5449. Fixes the history cleaner thread. 
     (Amareshwari Sriramadasu via ddas)
     (Amareshwari Sriramadasu via ddas)
  
  
-Release 0.19.1 - 2009-02-23
+    HADOOP-5479. NameNode should not send empty block replication request to
+    DataNode. (hairong)
 
 
-  INCOMPATIBLE CHANGES
+Release 0.19.1 - 2009-02-23
 
 
     HADOOP-5225. Workaround for tmp file handling in HDFS. sync() is 
     HADOOP-5225. Workaround for tmp file handling in HDFS. sync() is 
     incomplete as a result. committed only to 0.19.x. (Raghu Angadi)
     incomplete as a result. committed only to 0.19.x. (Raghu Angadi)

+ 7 - 11
src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java

@@ -68,20 +68,16 @@ public class DatanodeDescriptor extends DatanodeInfo {
     }
     }
 
 
     /** Dequeue */
     /** Dequeue */
-    synchronized List<BlockTargetPair> poll(int numTargets) {
-      if (numTargets <= 0 || blockq.isEmpty()) {
+    synchronized List<BlockTargetPair> poll(int numBlocks) {
+      if (numBlocks <= 0 || blockq.isEmpty()) {
         return null;
         return null;
       }
       }
-      else {
-        List<BlockTargetPair> results = new ArrayList<BlockTargetPair>();
-        for(; !blockq.isEmpty() && numTargets > 0; ) {
-          numTargets -= blockq.peek().targets.length; 
-          if (numTargets >= 0) {
-            results.add(blockq.poll());
-          }
-        }
-        return results;
+
+      List<BlockTargetPair> results = new ArrayList<BlockTargetPair>();
+      for(; !blockq.isEmpty() && numBlocks > 0; numBlocks--) {
+        results.add(blockq.poll());
       }
       }
+      return results;
     }
     }
   }
   }
 
 

+ 7 - 9
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

@@ -2463,12 +2463,8 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
         }
         }
 
 
         // choose replication targets
         // choose replication targets
-        int maxTargets = 
-          maxReplicationStreams - srcNode.getNumberOfBlocksToBeReplicated();
-        assert maxTargets > 0 : "Datanode " + srcNode.getName() 
-              + " should have not been selected as a source for replication.";
         DatanodeDescriptor targets[] = replicator.chooseTarget(
         DatanodeDescriptor targets[] = replicator.chooseTarget(
-            Math.min(requiredReplication - numEffectiveReplicas, maxTargets),
+            requiredReplication - numEffectiveReplicas,
             srcNode, containingNodes, null, block.getNumBytes());
             srcNode, containingNodes, null, block.getNumBytes());
         if(targets.length == 0)
         if(targets.length == 0)
           continue;
           continue;
@@ -2483,13 +2479,15 @@ public class FSNamesystem implements FSConstants, FSNamesystemMBean {
         // Move the block-replication into a "pending" state.
         // Move the block-replication into a "pending" state.
         // The reason we use 'pending' is so we can retry
         // The reason we use 'pending' is so we can retry
         // replications that fail after an appropriate amount of time.
         // replications that fail after an appropriate amount of time.
+        pendingReplications.add(block, targets.length);
+        NameNode.stateChangeLog.debug(
+            "BLOCK* block " + block
+            + " is moved from neededReplications to pendingReplications");
+        
+        // remove from neededReplications
         if(numEffectiveReplicas + targets.length >= requiredReplication) {
         if(numEffectiveReplicas + targets.length >= requiredReplication) {
           neededReplicationsIterator.remove(); // remove from neededReplications
           neededReplicationsIterator.remove(); // remove from neededReplications
           replIndex--;
           replIndex--;
-          pendingReplications.add(block, targets.length);
-          NameNode.stateChangeLog.debug(
-              "BLOCK* block " + block
-              + " is moved from neededReplications to pendingReplications");
         }
         }
         if (NameNode.stateChangeLog.isInfoEnabled()) {
         if (NameNode.stateChangeLog.isInfoEnabled()) {
           StringBuffer targetList = new StringBuffer("datanode(s)");
           StringBuffer targetList = new StringBuffer("datanode(s)");