incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject git commit: AMBARI-3140. Expose NN HA status thorugh Ambari API. (swagle)
Date Sat, 07 Sep 2013 03:32:20 GMT
Updated Branches:
  refs/heads/trunk 36ff824e5 -> b19122629


AMBARI-3140. Expose NN HA status thorugh Ambari API. (swagle)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/b1912262
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/b1912262
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/b1912262

Branch: refs/heads/trunk
Commit: b19122629d9c35d81efe5ac16b37eebf19e7c5a1
Parents: 36ff824
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Fri Sep 6 17:57:03 2013 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Fri Sep 6 17:58:53 2013 -0700

----------------------------------------------------------------------
 .../controller/jmx/JMXPropertyProvider.java     |  6 ++--
 .../src/main/resources/jmx_properties_2.json    |  5 +++
 .../controller/jmx/JMXPropertyProviderTest.java | 20 +++++++++--
 .../src/test/resources/hdfs_namenode_jmx.json   | 36 ++++++++++++++++++++
 4 files changed, 63 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b1912262/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
index d27eebd..dca738a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
@@ -58,7 +58,7 @@ public class JMXPropertyProvider extends AbstractPropertyProvider {
 
   private static final String NAME_KEY = "name";
   private static final String PORT_KEY = "tag.port";
-
+  private static final String DOT_REPLACEMENT_CHAR = "#";
   private static final long DEFAULT_POPULATE_TIMEOUT_MILLIS = 10000L;
 
   public static final String TIMED_OUT_MSG = "Timed out waiting for JMX metrics.";
@@ -384,7 +384,9 @@ public class JMXPropertyProvider extends AbstractPropertyProvider {
   private void setResourceValue(Resource resource, Map<String, Map<String, Object>>
categories, String propertyId,
                                 String category, String property, List<String> keyList)
{
     Map<String, Object> properties = categories.get(category);
-    
+    if (property.contains(DOT_REPLACEMENT_CHAR)) {
+      property = property.replaceAll(DOT_REPLACEMENT_CHAR, ".");
+    }
     if (properties != null && properties.containsKey(property)) {
       Object value = properties.get(property);
       if (keyList.size() > 0 && value instanceof Map) {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b1912262/ambari-server/src/main/resources/jmx_properties_2.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/jmx_properties_2.json b/ambari-server/src/main/resources/jmx_properties_2.json
index 81b9231..e05a0ce 100644
--- a/ambari-server/src/main/resources/jmx_properties_2.json
+++ b/ambari-server/src/main/resources/jmx_properties_2.json
@@ -1335,6 +1335,11 @@
         "pointInTime" : true,
         "temporal" : false
       },
+      "metrics/dfs/FSNamesystem/HAState":{
+        "metric" : "Hadoop:service=NameNode,name=FSNamesystem.tag#HAState",
+        "pointInTime" : true,
+        "temporal" : false
+      },
       "metrics/dfs/namenode/AddBlockOps":{
         "metric" : "Hadoop:service=NameNode,name=NameNodeActivity.AddBlockOps",
         "pointInTime" : true,

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b1912262/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
index 813aa42..81ffb49 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
@@ -85,7 +85,6 @@ public class JMXPropertyProviderTest {
     Assert.assertEquals(842207944704L, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/dfs/FSNamesystem",
"CapacityRemaining")));
     Assert.assertEquals(45509562366L, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/dfs/FSNamesystem",
"CapacityNonDFSUsed")));
 
-
     // datanode
     resource = new ResourceImpl(Resource.Type.HostComponent);
 
@@ -355,7 +354,7 @@ public class JMXPropertyProviderTest {
         PropertyHelper.getPropertyId("HostRoles", "state"),
         Collections.singleton("STARTED"));
 
-    // namenode
+    // resourcemanager
     Resource resource = new ResourceImpl(Resource.Type.HostComponent);
 
     resource.setProperty(HOST_COMPONENT_HOST_NAME_PROPERTY_ID, "domu-12-31-39-0e-34-e1.compute-1.internal");
@@ -381,6 +380,23 @@ public class JMXPropertyProviderTest {
     Assert.assertEquals(0,  resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/yarn/ClusterMetrics",
"NumLostNMs")));
     Assert.assertEquals(0,  resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/yarn/ClusterMetrics",
"NumUnhealthyNMs")));
     Assert.assertEquals(0,  resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/yarn/ClusterMetrics",
"NumRebootedNMs")));
+
+    //namenode
+    resource = new ResourceImpl(Resource.Type.HostComponent);
+
+    resource.setProperty(HOST_COMPONENT_HOST_NAME_PROPERTY_ID, "domu-12-31-39-0e-34-e1.compute-1.internal");
+    resource.setProperty(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "NAMENODE");
+    resource.setProperty(HOST_COMPONENT_STATE_PROPERTY_ID, "STARTED");
+
+    // request with an empty set should get all supported properties
+    request = PropertyHelper.getReadRequest(Collections.<String>emptySet());
+
+    Assert.assertEquals(1, propertyProvider.populateResources(Collections.singleton(resource),
request, null).size());
+
+    Assert.assertEquals(propertyProvider.getSpec("domu-12-31-39-0e-34-e1" +
+      ".compute-1.internal", "50070"), streamProvider.getLastSpec());
+    Assert.assertEquals("active", resource.getPropertyValue(PropertyHelper
+      .getPropertyId("metrics/dfs/FSNamesystem", "HAState")));
   }
   
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b1912262/ambari-server/src/test/resources/hdfs_namenode_jmx.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/hdfs_namenode_jmx.json b/ambari-server/src/test/resources/hdfs_namenode_jmx.json
index 0204554..7cb95a1 100644
--- a/ambari-server/src/test/resources/hdfs_namenode_jmx.json
+++ b/ambari-server/src/test/resources/hdfs_namenode_jmx.json
@@ -17,6 +17,42 @@
     },
     "ObjectPendingFinalizationCount" : 0
   }, {
+      "name" : "Hadoop:service=NameNode,name=FSNamesystem",
+      "modelerType" : "FSNamesystem",
+      "tag.Context" : "dfs",
+      "tag.HAState" : "active",
+      "tag.Hostname" : "ambari-nn-ha-2.iad1",
+      "MissingBlocks" : 0,
+      "ExpiredHeartbeats" : 0,
+      "TransactionsSinceLastCheckpoint" : -11936,
+      "TransactionsSinceLastLogRoll" : 0,
+      "LastWrittenTransactionId" : 180,
+      "LastCheckpointTime" : 1378512092338,
+      "CapacityTotal" : 42275766271,
+      "CapacityTotalGB" : 39.0,
+      "CapacityUsed" : 65536,
+      "CapacityUsedGB" : 0.0,
+      "CapacityRemaining" : 39943532544,
+      "CapacityRemainingGB" : 37.0,
+      "CapacityUsedNonDFS" : 2332168191,
+      "TotalLoad" : 2,
+      "SnapshottableDirectories" : 0,
+      "Snapshots" : 0,
+      "BlocksTotal" : 4,
+      "FilesTotal" : 24,
+      "PendingReplicationBlocks" : 0,
+      "UnderReplicatedBlocks" : 0,
+      "CorruptBlocks" : 0,
+      "ScheduledReplicationBlocks" : 0,
+      "PendingDeletionBlocks" : 0,
+      "ExcessBlocks" : 0,
+      "PostponedMisreplicatedBlocks" : 0,
+      "PendingDataNodeMessageCount" : 0,
+      "MillisSinceLastLoadedEdits" : 24777,
+      "BlockCapacity" : 2097152,
+      "StaleDataNodes" : 0,
+      "TotalFiles" : 24
+  }, {
     "name" : "Hadoop:service=NameNode,name=FSNamesystemMetrics",
     "modelerType" : "FSNamesystemMetrics",
     "tag.context" : "dfs",


Mime
View raw message