hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r1034181 - in /hadoop/hdfs/trunk/src/test/system: java/org/apache/hadoop/hdfs/test/system/DNClient.java java/org/apache/hadoop/hdfs/test/system/NNClient.java test/org/apache/hadoop/hdfs/TestHL040.java
Date Thu, 11 Nov 2010 22:24:05 GMT
Author: cos
Date: Thu Nov 11 22:24:05 2010
New Revision: 1034181

URL: http://svn.apache.org/viewvc?rev=1034181&view=rev
Log:
HDFS-1408. Herriot NN and DN clients should vend statistics. Contributed by Konstantin Boudnik.

Modified:
    hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/DNClient.java
    hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/NNClient.java
    hadoop/hdfs/trunk/src/test/system/test/org/apache/hadoop/hdfs/TestHL040.java

Modified: hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/DNClient.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/DNClient.java?rev=1034181&r1=1034180&r2=1034181&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/DNClient.java
(original)
+++ hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/DNClient.java
Thu Nov 11 22:24:05 2010
@@ -36,6 +36,7 @@ import org.apache.hadoop.test.system.pro
 public class DNClient extends HDFSDaemonClient<DNProtocol> {
 
   DNProtocol proxy;
+  private static final String HADOOP_DATANODE_OPTS_ENV = "HADOOP_DATANODE_OPTS";
 
   public DNClient(Configuration conf, RemoteProcess process) throws IOException {
     super(conf, process);
@@ -79,4 +80,20 @@ public class DNClient extends HDFSDaemon
   public Configuration getDatanodeConfig() throws IOException {
     return getProxy().getDaemonConf();
   }
+
+  @Override
+  public String getHadoopOptsEnvName() {
+    return HADOOP_DATANODE_OPTS_ENV;
+  }
+
+  /**
+   * Concrete implementation of abstract super class method
+   * @param attributeName name of the attribute to be retrieved
+   * @return Object value of the given attribute
+   * @throws IOException is thrown in case of communication errors
+   */
+  @Override
+  public Object getDaemonAttribute (String attributeName) throws IOException {
+    return getJmxAttribute("DataNode", "DataNodeInfo", attributeName);
+  }
 }

Modified: hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/NNClient.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/NNClient.java?rev=1034181&r1=1034180&r2=1034181&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/NNClient.java
(original)
+++ hadoop/hdfs/trunk/src/test/system/java/org/apache/hadoop/hdfs/test/system/NNClient.java
Thu Nov 11 22:24:05 2010
@@ -31,6 +31,7 @@ import org.apache.hadoop.test.system.pro
 public class NNClient extends HDFSDaemonClient<NNProtocol> {
   
   NNProtocol proxy;
+  private static final String HADOOP_NAMENODE_OPTS_ENV = "HADOOP_NAMENODE_OPTS";
 
   public NNClient(Configuration conf, RemoteProcess process) throws IOException {
     super(conf, process);
@@ -68,4 +69,20 @@ public class NNClient extends HDFSDaemon
   protected NNProtocol getProxy() {
     return proxy;
   }
+
+  @Override
+  public String getHadoopOptsEnvName() {
+    return HADOOP_NAMENODE_OPTS_ENV;
+  }
+
+  /**
+   * Concrete implementation of abstract super class method
+   * @param attributeName name of the attribute to be retrieved
+   * @return Object value of the given attribute
+   * @throws IOException is thrown in case of communication errors
+   */
+  @Override
+  public Object getDaemonAttribute (String attributeName) throws IOException {
+    return getJmxAttribute("NameNode", "NameNodeInfo", attributeName);
+  }
 }

Modified: hadoop/hdfs/trunk/src/test/system/test/org/apache/hadoop/hdfs/TestHL040.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/system/test/org/apache/hadoop/hdfs/TestHL040.java?rev=1034181&r1=1034180&r2=1034181&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/system/test/org/apache/hadoop/hdfs/TestHL040.java (original)
+++ hadoop/hdfs/trunk/src/test/system/test/org/apache/hadoop/hdfs/TestHL040.java Thu Nov 11
22:24:05 2010
@@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs;
 
 import java.io.IOException;
 import java.util.Collection;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -31,6 +32,7 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mortbay.util.ajax.JSON;
 
 public class TestHL040 {
   private HDFSCluster cluster = null;
@@ -64,6 +66,21 @@ public class TestHL040 {
           dnC.getProcessInfo());
       Assert.assertNotNull("Datanode process info isn't suppose to be null",
           dnC.getProcessInfo());
+      LOG.info("Free space " + getFreeSpace(dnC));
     }
   }
+
+  private long getFreeSpace(DNClient dnC) throws IOException {
+    Object volObj = dnC.getDaemonAttribute("VolumeInfo");
+    Assert.assertNotNull("Attribute value is expected to be not null", volObj);
+    LOG.debug("Got object: " + volObj);
+    Map volInfoMap = (Map) JSON.parse(volObj.toString());
+    long totalFreeSpace = 0L;
+    for (Object key : volInfoMap.keySet()) {
+      Map attrMap = (Map) volInfoMap.get(key);
+      long freeSpace = (Long) attrMap.get("freeSpace");
+      totalFreeSpace += freeSpace;
+    }
+    return totalFreeSpace;
+  }
 }



Mime
View raw message