hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1156424 - in /hadoop/common/trunk/hdfs: ./ src/java/org/apache/hadoop/hdfs/server/blockmanagement/ src/java/org/apache/hadoop/hdfs/server/namenode/
Date Thu, 11 Aug 2011 01:05:45 GMT
Author: szetszwo
Date: Thu Aug 11 01:05:45 2011
New Revision: 1156424

URL: http://svn.apache.org/viewvc?rev=1156424&view=rev
Log:
HDFS-2237. Change UnderReplicatedBlocks from public to package private.

Modified:
    hadoop/common/trunk/hdfs/CHANGES.txt
    hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
    hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/UnderReplicatedBlocks.java
    hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Modified: hadoop/common/trunk/hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/CHANGES.txt?rev=1156424&r1=1156423&r2=1156424&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hdfs/CHANGES.txt Thu Aug 11 01:05:45 2011
@@ -660,6 +660,9 @@ Trunk (unreleased changes)
     HDFS-2241. Remove implementing FSConstants interface to just get the
     constants from the interface. (suresh)
 
+    HDFS-2237. Change UnderReplicatedBlocks from public to package private.
+    (szetszwo)
+
   OPTIMIZATIONS
 
     HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

Modified: hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java?rev=1156424&r1=1156423&r2=1156424&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
(original)
+++ hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java
Thu Aug 11 01:05:45 2011
@@ -51,7 +51,6 @@ import org.apache.hadoop.hdfs.protocol.U
 import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager;
 import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager.AccessMode;
 import org.apache.hadoop.hdfs.security.token.block.ExportedBlockKeys;
-import org.apache.hadoop.hdfs.server.blockmanagement.UnderReplicatedBlocks.BlockIterator;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.BlockUCState;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.ReplicaState;
 import org.apache.hadoop.hdfs.server.common.Util;
@@ -2588,9 +2587,14 @@ public class BlockManager {
   /**
    * Return an iterator over the set of blocks for which there are no replicas.
    */
-  public BlockIterator getCorruptReplicaBlockIterator() {
-    return neededReplications
-        .iterator(UnderReplicatedBlocks.QUEUE_WITH_CORRUPT_BLOCKS);
+  public Iterator<Block> getCorruptReplicaBlockIterator() {
+    return neededReplications.iterator(
+        UnderReplicatedBlocks.QUEUE_WITH_CORRUPT_BLOCKS);
+  }
+
+  /** @return the size of UnderReplicatedBlocks */
+  public int numOfUnderReplicatedBlocks() {
+    return neededReplications.size();
   }
 
   /**

Modified: hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/UnderReplicatedBlocks.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/UnderReplicatedBlocks.java?rev=1156424&r1=1156423&r2=1156424&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/UnderReplicatedBlocks.java
(original)
+++ hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/blockmanagement/UnderReplicatedBlocks.java
Thu Aug 11 01:05:45 2011
@@ -17,21 +17,26 @@
  */
 package org.apache.hadoop.hdfs.server.blockmanagement;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NavigableSet;
+import java.util.TreeSet;
 
 import org.apache.hadoop.hdfs.protocol.Block;
 import org.apache.hadoop.hdfs.server.namenode.NameNode;
 
-/* Class for keeping track of under replication blocks
+/** Keep track of under replication blocks.
  * Blocks have replication priority, with priority 0 indicating the highest
  * Blocks have only one replicas has the highest
  */
-public class UnderReplicatedBlocks implements Iterable<Block> {
+class UnderReplicatedBlocks implements Iterable<Block> {
   static final int LEVEL = 5;
-  static public final int QUEUE_WITH_CORRUPT_BLOCKS = 4;
-  private List<TreeSet<Block>> priorityQueues = new ArrayList<TreeSet<Block>>();
+  static final int QUEUE_WITH_CORRUPT_BLOCKS = 4;
+  private final List<NavigableSet<Block>> priorityQueues
+      = new ArrayList<NavigableSet<Block>>();
       
-  /* constructor */
+  /** Create an object. */
   UnderReplicatedBlocks() {
     for(int i=0; i<LEVEL; i++) {
       priorityQueues.add(new TreeSet<Block>());
@@ -47,8 +52,8 @@ public class UnderReplicatedBlocks imple
     }
   }
 
-  /* Return the total number of under replication blocks */
-  public synchronized int size() {
+  /** Return the total number of under replication blocks */
+  synchronized int size() {
     int size = 0;
     for (int i=0; i<LEVEL; i++) {
       size += priorityQueues.get(i).size();
@@ -56,7 +61,7 @@ public class UnderReplicatedBlocks imple
     return size;
   }
 
-  /* Return the number of under replication blocks excluding corrupt blocks */
+  /** Return the number of under replication blocks excluding corrupt blocks */
   synchronized int getUnderReplicatedBlockCount() {
     int size = 0;
     for (int i=0; i<QUEUE_WITH_CORRUPT_BLOCKS; i++) {
@@ -70,15 +75,15 @@ public class UnderReplicatedBlocks imple
     return priorityQueues.get(QUEUE_WITH_CORRUPT_BLOCKS).size();
   }
   
-  /* Check if a block is in the neededReplication queue */
-  public synchronized boolean contains(Block block) {
-    for(TreeSet<Block> set:priorityQueues) {
+  /** Check if a block is in the neededReplication queue */
+  synchronized boolean contains(Block block) {
+    for(NavigableSet<Block> set : priorityQueues) {
       if(set.contains(block)) { return true; }
     }
     return false;
   }
       
-  /* Return the priority of a block
+  /** Return the priority of a block
    * @param block a under replication block
    * @param curReplicas current number of replicas of the block
    * @param expectedReplicas expected number of replicas of the block
@@ -106,7 +111,7 @@ public class UnderReplicatedBlocks imple
     }
   }
       
-  /* add a block to a under replication queue according to its priority
+  /** add a block to a under replication queue according to its priority
    * @param block a under replication block
    * @param curReplicas current number of replicas of the block
    * @param expectedReplicas expected number of replicas of the block
@@ -134,7 +139,7 @@ public class UnderReplicatedBlocks imple
     return false;
   }
 
-  /* remove a block from a under replication queue */
+  /** remove a block from a under replication queue */
   synchronized boolean remove(Block block, 
                               int oldReplicas, 
                               int decommissionedReplicas,
@@ -145,7 +150,7 @@ public class UnderReplicatedBlocks imple
     return remove(block, priLevel);
   }
       
-  /* remove a block from a under replication queue given a priority*/
+  /** remove a block from a under replication queue given a priority*/
   boolean remove(Block block, int priLevel) {
     if(priLevel >= 0 && priLevel < LEVEL 
         && priorityQueues.get(priLevel).remove(block)) {
@@ -174,7 +179,7 @@ public class UnderReplicatedBlocks imple
     return false;
   }
       
-  /* update the priority level of a block */
+  /** update the priority level of a block */
   synchronized void update(Block block, int curReplicas, 
                            int decommissionedReplicas,
                            int curExpectedReplicas,
@@ -209,30 +214,29 @@ public class UnderReplicatedBlocks imple
     }
   }
 
-  /* returns an iterator of all blocks in a given priority queue */
+  /** returns an iterator of all blocks in a given priority queue */
   synchronized BlockIterator iterator(int level) {
     return new BlockIterator(level);
   }
     
-  /* return an iterator of all the under replication blocks */
+  /** return an iterator of all the under replication blocks */
   public synchronized BlockIterator iterator() {
     return new BlockIterator();
   }
   
-  public class BlockIterator implements Iterator<Block> {
+  class BlockIterator implements Iterator<Block> {
     private int level;
     private boolean isIteratorForLevel = false;
     private List<Iterator<Block>> iterators = new ArrayList<Iterator<Block>>();
 
-    BlockIterator()  
-    {
+    private BlockIterator() {
       level=0;
       for(int i=0; i<LEVEL; i++) {
         iterators.add(priorityQueues.get(i).iterator());
       }
     }
 
-    BlockIterator(int l) {
+    private BlockIterator(int l) {
       level = l;
       isIteratorForLevel = true;
       iterators.add(priorityQueues.get(level).iterator());
@@ -246,6 +250,7 @@ public class UnderReplicatedBlocks imple
       }
     }
 
+    @Override
     public Block next() {
       if (isIteratorForLevel)
         return iterators.get(0).next();
@@ -253,6 +258,7 @@ public class UnderReplicatedBlocks imple
       return iterators.get(level).next();
     }
 
+    @Override
     public boolean hasNext() {
       if (isIteratorForLevel)
         return iterators.get(0).hasNext();
@@ -260,6 +266,7 @@ public class UnderReplicatedBlocks imple
       return iterators.get(level).hasNext();
     }
 
+    @Override
     public void remove() {
       if (isIteratorForLevel) 
         iterators.get(0).remove();
@@ -267,8 +274,8 @@ public class UnderReplicatedBlocks imple
         iterators.get(level).remove();
     }
 
-    public int getPriority() {
+    int getPriority() {
       return level;
-    };
+    }
   }  
 }

Modified: hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1156424&r1=1156423&r2=1156424&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
(original)
+++ hadoop/common/trunk/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Thu Aug 11 01:05:45 2011
@@ -39,6 +39,7 @@ import java.util.Date;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -97,7 +98,6 @@ import org.apache.hadoop.hdfs.server.blo
 import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
 import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeManager;
 import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStatistics;
-import org.apache.hadoop.hdfs.server.blockmanagement.UnderReplicatedBlocks;
 import org.apache.hadoop.hdfs.server.common.GenerationStamp;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.BlockUCState;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.NamenodeRole;
@@ -2910,7 +2910,7 @@ public class FSNamesystem implements RwL
           + nt.getNumOfRacks() + " racks and "
           + nt.getNumOfLeaves() + " datanodes");
       NameNode.stateChangeLog.info("STATE* UnderReplicatedBlocks has "
-                                   +blockManager.neededReplications.size()+" blocks");
+          + blockManager.numOfUnderReplicatedBlocks() + " blocks");
     }
 
     /**
@@ -3954,7 +3954,8 @@ public class FSNamesystem implements RwL
       if (startBlockAfter != null) {
         startBlockId = Block.filename2id(startBlockAfter);
       }
-      UnderReplicatedBlocks.BlockIterator blkIterator = blockManager.getCorruptReplicaBlockIterator();
+
+      final Iterator<Block> blkIterator = blockManager.getCorruptReplicaBlockIterator();
       while (blkIterator.hasNext()) {
         Block blk = blkIterator.next();
         INode inode = blockManager.getINode(blk);



Mime
View raw message