hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1089315 [2/2] - in /hadoop/hdfs/branches/yahoo-merge: ./ conf/ ivy/ src/java/org/apache/hadoop/hdfs/ src/java/org/apache/hadoop/hdfs/server/datanode/ src/java/org/apache/hadoop/hdfs/server/datanode/metrics/ src/java/org/apache/hadoop/hdfs/...
Date Wed, 06 Apr 2011 06:22:33 GMT
Modified: hadoop/hdfs/branches/yahoo-merge/src/test/hdfs/org/apache/hadoop/tools/TestJMXGet.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/yahoo-merge/src/test/hdfs/org/apache/hadoop/tools/TestJMXGet.java?rev=1089315&r1=1089314&r2=1089315&view=diff
==============================================================================
--- hadoop/hdfs/branches/yahoo-merge/src/test/hdfs/org/apache/hadoop/tools/TestJMXGet.java
(original)
+++ hadoop/hdfs/branches/yahoo-merge/src/test/hdfs/org/apache/hadoop/tools/TestJMXGet.java
Wed Apr  6 06:22:32 2011
@@ -31,8 +31,9 @@ import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdfs.HdfsConfiguration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.hdfs.server.namenode.NameNode;
 import org.apache.hadoop.hdfs.tools.JMXGet;
+import org.apache.hadoop.metrics2.MetricsRecordBuilder;
+import static org.apache.hadoop.test.MetricsAsserts.*;
 
 
 /**
@@ -91,18 +92,18 @@ public class TestJMXGet extends TestCase
     writeFile(cluster.getFileSystem(), new Path("/test1"), 2);
 
     JMXGet jmx = new JMXGet();
-    jmx.init();
-
-
-    //get some data from different sources
-    int blocks_corrupted = NameNode.getNameNodeMetrics().
-    numBlocksCorrupted.get();
-    assertEquals(Integer.parseInt(
-        jmx.getValue("NumLiveDataNodes")), 2);
-    assertEquals(Integer.parseInt(
-        jmx.getValue("BlocksCorrupted")), blocks_corrupted);
-    assertEquals(Integer.parseInt(
-        jmx.getValue("NumOpenConnections")), 0);
+    //jmx.setService("*"); // list all hadoop services
+    //jmx.init();
+    //jmx = new JMXGet();
+    jmx.init(); // default lists namenode mbeans only
+
+    //get some data from different source
+    assertEquals(numDatanodes, Integer.parseInt(
+        jmx.getValue("NumLiveDataNodes")));
+    assertGauge("CorruptBlocks", Long.parseLong(jmx.getValue("CorruptBlocks")),
+                getMetrics("FSNamesystem"));
+    assertEquals(numDatanodes, Integer.parseInt(
+        jmx.getValue("NumOpenConnections")));
 
     cluster.shutdown();
   }
@@ -119,9 +120,12 @@ public class TestJMXGet extends TestCase
     writeFile(cluster.getFileSystem(), new Path("/test"), 2);
 
     JMXGet jmx = new JMXGet();
+    //jmx.setService("*"); // list all hadoop services
+    //jmx.init();
+    //jmx = new JMXGet();
     jmx.setService("DataNode");
     jmx.init();
-    assertEquals(Integer.parseInt(jmx.getValue("bytes_written")), 0);
+    assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));
 
     cluster.shutdown();
   }



Mime
View raw message