You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2012/10/18 22:48:08 UTC
svn commit: r1399843 - in /hadoop/common/branches/branch-1: CHANGES.txt
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
src/test/org/apache/hadoop/hdfs/server/namenode/TestReplicationPolicy.java
Author: suresh
Date: Thu Oct 18 20:48:08 2012
New Revision: 1399843
URL: http://svn.apache.org/viewvc?rev=1399843&view=rev
Log:
HDFS-4071. Add number of stale datanodes to metrics (port of HDFS-4059). Contributed by Jing Zhao.
Modified:
hadoop/common/branches/branch-1/CHANGES.txt
hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestReplicationPolicy.java
Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1399843&r1=1399842&r2=1399843&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Thu Oct 18 20:48:08 2012
@@ -92,6 +92,9 @@ Release 1.2.0 - unreleased
HADOOP-8931. Add Java version to startup message. (eli)
+ HDFS-4071. Add number of stale datanodes to metrics (port of HDFS-4059).
+ (Jing Zhao via suresh)
+
OPTIMIZATIONS
HDFS-2533. Backport: Remove needless synchronization on some FSDataSet
Modified: hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=1399843&r1=1399842&r2=1399843&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Thu Oct 18 20:48:08 2012
@@ -373,7 +373,7 @@ public class FSNamesystem implements FSC
private volatile boolean avoidStaleDataNodesForWrite;
private boolean initialAvoidWriteStaleNodes;
/** The number of stale DataNodes */
- private volatile int numStaleNodes;
+ private volatile int numStaleNodes = 0;
/**
* When the ratio of stale datanodes reaches this number, stop avoiding
* writing to stale datanodes, i.e., continue using stale nodes for writing.
@@ -6162,7 +6162,10 @@ public class FSNamesystem implements FSC
.addGauge("ScheduledReplicationBlocks", "",
getScheduledReplicationBlocks())
.addGauge("MissingBlocks", "", getMissingBlocksCount())
- .addGauge("BlockCapacity", "", getBlockCapacity());
+ .addGauge("BlockCapacity", "", getBlockCapacity())
+ .addGauge("StaleDataNodes",
+ "Number of datanodes marked stale due to delayed heartbeat",
+ this.getNumStaleNodes());
}
private void registerWith(MetricsSystem ms) {
Modified: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestReplicationPolicy.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestReplicationPolicy.java?rev=1399843&r1=1399842&r2=1399843&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestReplicationPolicy.java (original)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/server/namenode/TestReplicationPolicy.java Thu Oct 18 20:48:08 2012
@@ -18,6 +18,8 @@
package org.apache.hadoop.hdfs.server.namenode;
+import static org.apache.hadoop.test.MetricsAsserts.assertGauge;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -556,6 +558,9 @@ public class TestReplicationPolicy exten
assertEquals(numStaleNodes, 2);
assertTrue(miniCluster.getNameNode().getNamesystem()
.isAvoidingStaleDataNodesForWrite());
+ // Check metrics
+ assertGauge("StaleDataNodes", numStaleNodes, miniCluster.getNameNode()
+ .getNamesystem());
// Call chooseTarget
DatanodeDescriptor staleNodeInfo = miniCluster.getNameNode()
.getNamesystem()
@@ -583,6 +588,9 @@ public class TestReplicationPolicy exten
// to avoid hotspots
assertFalse(miniCluster.getNameNode().getNamesystem()
.isAvoidingStaleDataNodesForWrite());
+ // Check metrics
+ assertGauge("StaleDataNodes", numStaleNodes, miniCluster.getNameNode()
+ .getNamesystem());
// Call chooseTarget
targets = replicator.chooseTarget(filename, 3, staleNodeInfo, BLOCK_SIZE);
assertEquals(targets.length, 3);
@@ -603,6 +611,9 @@ public class TestReplicationPolicy exten
assertEquals(numStaleNodes, 2);
assertTrue(miniCluster.getNameNode().getNamesystem()
.isAvoidingStaleDataNodesForWrite());
+ // Check metrics
+ assertGauge("StaleDataNodes", numStaleNodes, miniCluster.getNameNode()
+ .getNamesystem());
// Call chooseTarget
targets = replicator.chooseTarget(filename, 3, staleNodeInfo, BLOCK_SIZE);
assertEquals(targets.length, 3);