hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r755370 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Date Tue, 17 Mar 2009 19:55:07 GMT
Author: hairong
Date: Tue Mar 17 19:55:07 2009
New Revision: 755370

URL: http://svn.apache.org/viewvc?rev=755370&view=rev
Log:
HADOOP-5479. NameNode should not send empty block replication request to DataNode. Contributed
by Hairong Kuang.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=755370&r1=755369&r2=755370&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Tue Mar 17 19:55:07 2009
@@ -1068,6 +1068,9 @@
     HADOOP-5449. Fixes the history cleaner thread. 
     (Amareshwari Sriramadasu via ddas)
 
+    HADOOP-5479. NameNode should not send empty block replication request to
+    DataNode. (hairong)
+
 Release 0.19.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java?rev=755370&r1=755369&r2=755370&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
(original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/DatanodeDescriptor.java
Tue Mar 17 19:55:07 2009
@@ -68,20 +68,16 @@
     }
 
     /** 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;
       }
-      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;
     }
   }
 

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=755370&r1=755369&r2=755370&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Tue
Mar 17 19:55:07 2009
@@ -2517,12 +2517,8 @@
         }
 
         // 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(
-            Math.min(requiredReplication - numEffectiveReplicas, maxTargets),
+            requiredReplication - numEffectiveReplicas,
             srcNode, containingNodes, null, block.getNumBytes());
         if(targets.length == 0)
           continue;
@@ -2537,13 +2533,15 @@
         // Move the block-replication into a "pending" state.
         // The reason we use 'pending' is so we can retry
         // 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) {
           neededReplicationsIterator.remove(); // remove from neededReplications
           replIndex--;
-          pendingReplications.add(block, targets.length);
-          NameNode.stateChangeLog.debug(
-              "BLOCK* block " + block
-              + " is moved from neededReplications to pendingReplications");
         }
         if (NameNode.stateChangeLog.isInfoEnabled()) {
           StringBuffer targetList = new StringBuffer("datanode(s)");



Mime
View raw message