ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [1/2] ambari git commit: AMBARI-11434. After cluster installation accessing DATANODE host component results in NPE due to bad metrics JSON (dlysnichenko)
Date Wed, 27 May 2015 17:23:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 766b934c0 -> 90bd51a81


AMBARI-11434. After cluster installation accessing DATANODE host component results in NPE
due to bad metrics JSON (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: 1a6dd84d242fcdd0e26c96b5ce3e564049b5095f
Parents: 766b934
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Wed May 27 20:20:43 2015 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Wed May 27 20:20:43 2015 +0300

----------------------------------------------------------------------
 .../internal/StackDefinedPropertyProvider.java          | 12 +++++++-----
 .../metrics/RestMetricsPropertyProviderTest.java        |  2 ++
 2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1a6dd84d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
index 89ba36e..3a6d30b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
@@ -248,11 +248,13 @@ public class StackDefinedPropertyProvider implements PropertyProvider
{
 
     for (Entry<String, Metric> entry : def.getMetrics().entrySet()) {
       Metric metric = entry.getValue();
-      PropertyInfo propertyInfo = new PropertyInfo(metric.getName(),
-        metric.isTemporal(), metric.isPointInTime());
-      propertyInfo.setAmsHostMetric(metric.isAmsHostMetric());
-      propertyInfo.setUnit(metric.getUnit());
-      defs.put(entry.getKey(), propertyInfo);
+      if (metric.getName() != null) {
+        PropertyInfo propertyInfo = new PropertyInfo(metric.getName(),
+                metric.isTemporal(), metric.isPointInTime());
+        propertyInfo.setAmsHostMetric(metric.isAmsHostMetric());
+        propertyInfo.setUnit(metric.getUnit());
+        defs.put(entry.getKey(), propertyInfo);
+      }
     }
 
     return defs;

http://git-wip-us.apache.org/repos/asf/ambari/blob/1a6dd84d/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
index 1534226..500eea4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
@@ -82,6 +82,7 @@ public class RestMetricsPropertyProviderTest {
     componentMetrics.put("metrics/api/cluster/summary/slots.used", new Metric("/api/cluster/summary##slots.used",
false, false, false, "unitless"));
     componentMetrics.put("metrics/api/cluster/summary/topologies", new Metric("/api/cluster/summary##topologies",
false, false, false, "unitless"));
     componentMetrics.put("metrics/api/cluster/summary/nimbus.uptime", new Metric("/api/cluster/summary##nimbus.uptime",
false, false, false, "unitless"));
+    componentMetrics.put("metrics/api/cluster/summary/wrong.metric", new Metric(null, false,
false, false, "unitless"));
   }
 
 
@@ -132,6 +133,7 @@ public class RestMetricsPropertyProviderTest {
     Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet());
 
     Assert.assertEquals(1, restMetricsPropertyProvider.populateResources(Collections.singleton(resource),
request, null).size());
+    Assert.assertNull(resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/api/cluster/summary",
"wrong.metric")));
 
     //STORM_REST_API
     Assert.assertEquals(28.0, resource.getPropertyValue(PropertyHelper.getPropertyId("metrics/api/cluster/summary",
"tasks.total")));


Mime
View raw message