hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r765025 - in /hadoop/core/trunk: ./ src/hdfs/org/apache/hadoop/hdfs/server/namenode/ src/test/org/apache/hadoop/hdfs/server/namenode/
Date Wed, 15 Apr 2009 00:40:01 GMT
Author: shv
Date: Wed Apr 15 00:40:00 2009
New Revision: 765025

URL: http://svn.apache.org/viewvc?rev=765025&view=rev
Log:
HADOOP-5509. PendingReplicationBlocks does not start monitor in the constructor. Contributed
by Konstantin Shvachko.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/PendingReplicationBlocks.java
    hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/namenode/TestPendingReplication.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=765025&r1=765024&r2=765025&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Apr 15 00:40:00 2009
@@ -226,6 +226,9 @@
     HADOOP-5581. HDFS should throw FileNotFoundException when while opening
     a file that does not exist. (Brian Bockelman via rangadi)
 
+    HADOOP-5509. PendingReplicationBlocks does not start monitor in the
+    constructor. (shv)
+
   OPTIMIZATIONS
 
     HADOOP-5595. NameNode does not need to run a replicator to choose a

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=765025&r1=765024&r2=765025&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 Wed
Apr 15 00:40:00 2009
@@ -320,6 +320,7 @@
    */
   void activate(Configuration conf) throws IOException {
     setBlockTotal();
+    pendingReplications.start();
     this.hbthread = new Daemon(new HeartbeatMonitor());
     this.lmthread = new Daemon(leaseManager.new Monitor());
     this.replthread = new Daemon(new ReplicationMonitor());

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=765025&r1=765024&r2=765025&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java Wed Apr
15 00:40:00 2009
@@ -261,12 +261,12 @@
     // The rpc-server port can be ephemeral... ensure we have the correct info
     this.rpcAddress = this.server.getListenerAddress(); 
     setRpcServerAddress(conf);
-    LOG.info(getRole() + " up at: " + rpcAddress);
 
     myMetrics = new NameNodeMetrics(conf, role);
 
     loadNamesystem(conf);
     activate(conf);
+    LOG.info(getRole() + " up at: " + rpcAddress);
   }
 
   /**

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/PendingReplicationBlocks.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/PendingReplicationBlocks.java?rev=765025&r1=765024&r2=765025&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/PendingReplicationBlocks.java
(original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/PendingReplicationBlocks.java
Wed Apr 15 00:40:00 2009
@@ -51,17 +51,12 @@
     if ( timeoutPeriod > 0 ) {
       this.timeout = timeoutPeriod;
     }
-    init();
-  }
-
-  PendingReplicationBlocks() {
-    init();
-  }
-
-  void init() {
     pendingReplications = new HashMap<Block, PendingBlockInfo>();
     timedOutItems = new ArrayList<Block>();
-    this.timerThread = new Daemon(new PendingReplicationMonitor());
+  }
+
+  void start() {
+    timerThread = new Daemon(new PendingReplicationMonitor());
     timerThread.start();
   }
 
@@ -196,14 +191,15 @@
      */
     void pendingReplicationCheck() {
       synchronized (pendingReplications) {
-        Iterator iter = pendingReplications.entrySet().iterator();
+        Iterator<Map.Entry<Block, PendingBlockInfo>> iter =
+                                    pendingReplications.entrySet().iterator();
         long now = FSNamesystem.now();
         FSNamesystem.LOG.debug("PendingReplicationMonitor checking Q");
         while (iter.hasNext()) {
-          Map.Entry entry = (Map.Entry) iter.next();
-          PendingBlockInfo pendingBlock = (PendingBlockInfo) entry.getValue();
+          Map.Entry<Block, PendingBlockInfo> entry = iter.next();
+          PendingBlockInfo pendingBlock = entry.getValue();
           if (now > pendingBlock.getTimeStamp() + timeout) {
-            Block block = (Block) entry.getKey();
+            Block block = entry.getKey();
             synchronized (timedOutItems) {
               timedOutItems.add(block);
             }
@@ -222,6 +218,7 @@
    */
   void stop() {
     fsRunning = false;
+    if(timerThread == null) return;
     timerThread.interrupt();
     try {
       timerThread.join(3000);
@@ -236,11 +233,12 @@
     synchronized (pendingReplications) {
       out.println("Metasave: Blocks being replicated: " +
                   pendingReplications.size());
-      Iterator iter = pendingReplications.entrySet().iterator();
+      Iterator<Map.Entry<Block, PendingBlockInfo>> iter =
+                                  pendingReplications.entrySet().iterator();
       while (iter.hasNext()) {
-        Map.Entry entry = (Map.Entry) iter.next();
-        PendingBlockInfo pendingBlock = (PendingBlockInfo) entry.getValue();
-        Block block = (Block) entry.getKey();
+        Map.Entry<Block, PendingBlockInfo> entry = iter.next();
+        PendingBlockInfo pendingBlock = entry.getValue();
+        Block block = entry.getKey();
         out.println(block + 
                     " StartTime: " + new Time(pendingBlock.timeStamp) +
                     " NumReplicaInProgress: " + 

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/namenode/TestPendingReplication.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/namenode/TestPendingReplication.java?rev=765025&r1=765024&r2=765025&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/namenode/TestPendingReplication.java
(original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/server/namenode/TestPendingReplication.java
Wed Apr 15 00:40:00 2009
@@ -26,10 +26,12 @@
  * This class tests the internals of PendingReplicationBlocks.java
  */
 public class TestPendingReplication extends TestCase {
+  final static int TIMEOUT = 3;     // 3 seconds
+
   public void testPendingReplication() {
-    int timeout = 10;		// 10 seconds
     PendingReplicationBlocks pendingReplications;
-    pendingReplications = new PendingReplicationBlocks(timeout * 1000);
+    pendingReplications = new PendingReplicationBlocks(TIMEOUT * 1000);
+    pendingReplications.start();
 
     //
     // Add 10 blocks to pendingReplications.
@@ -110,5 +112,6 @@
     for (int i = 0; i < timedOut.length; i++) {
       assertTrue(timedOut[i].getBlockId() < 15);
     }
+    pendingReplications.stop();
   }
 }



Mime
View raw message