You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2014/03/21 21:39:17 UTC
[1/2] git commit: AMBARI-5182. Retrieve registered host from API
throws exception (dlysnichenko)
Repository: ambari
Updated Branches:
refs/heads/branch-1.5.0 075cec562 -> 982c6075d
refs/heads/trunk 8d58c3262 -> a3410253c
AMBARI-5182. Retrieve registered host from API throws exception (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a3410253
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a3410253
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a3410253
Branch: refs/heads/trunk
Commit: a3410253caaec3527792a71f02bdc5e5cecef29a
Parents: 8d58c32
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Fri Mar 21 22:36:29 2014 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Fri Mar 21 22:36:29 2014 +0200
----------------------------------------------------------------------
.../nagios/NagiosPropertyProvider.java | 8 +++++--
.../nagios/NagiosPropertyProviderTest.java | 23 ++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a3410253/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
index f80d4a6..4dc8f16 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
@@ -164,8 +164,12 @@ public class NagiosPropertyProvider extends BaseProvider implements PropertyProv
if (null == matchValue)
continue;
-
- String clusterName = res.getPropertyValue(clusterNameProperty).toString();
+
+ Object clusterPropertyValue = res.getPropertyValue(clusterNameProperty);
+ if (null == clusterPropertyValue)
+ continue;
+
+ String clusterName = clusterPropertyValue.toString();
if (null == clusterName)
continue;
http://git-wip-us.apache.org/repos/asf/ambari/blob/a3410253/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
index 9c6977d..9f3ff85 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
@@ -120,6 +120,29 @@ public class NagiosPropertyProviderTest {
Assert.assertFalse("Expected no alerts", values.containsKey("alerts"));
}
+
+
+ @Test
+ public void testClusterDoesNotExistNPE() throws Exception {
+ TestStreamProvider streamProvider = new TestStreamProvider("nagios_alerts.txt");
+
+ NagiosPropertyProvider npp = new NagiosPropertyProvider(Resource.Type.Service,
+ streamProvider,
+ "ServiceInfo/cluster_name",
+ "ServiceInfo/service_name");
+
+ Resource resource = new ResourceImpl(Resource.Type.Service);
+ resource.setProperty("ServiceInfo/cluster_name", null);
+ resource.setProperty("ServiceInfo/service_name", "HBASE");
+
+ // request with an empty set should get all supported properties
+ Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet(),
+ new HashMap<String, TemporalInfo>());
+
+ Set<Resource> set = npp.populateResources(Collections.singleton(resource), request, null);
+ Assert.assertEquals(1, set.size());
+
+ }
@Test
public void testNoNagiosServerCompoonent() throws Exception {
[2/2] git commit: AMBARI-5182. Retrieve registered host from API
throws exception (dlysnichenko)
Posted by dm...@apache.org.
AMBARI-5182. Retrieve registered host from API throws exception (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/982c6075
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/982c6075
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/982c6075
Branch: refs/heads/branch-1.5.0
Commit: 982c6075d53881de7e40b15c07d17cc20457ca8c
Parents: 075cec5
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Fri Mar 21 22:38:22 2014 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Fri Mar 21 22:38:22 2014 +0200
----------------------------------------------------------------------
.../nagios/NagiosPropertyProvider.java | 8 +++++--
.../nagios/NagiosPropertyProviderTest.java | 23 ++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/982c6075/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
index f80d4a6..4dc8f16 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProvider.java
@@ -164,8 +164,12 @@ public class NagiosPropertyProvider extends BaseProvider implements PropertyProv
if (null == matchValue)
continue;
-
- String clusterName = res.getPropertyValue(clusterNameProperty).toString();
+
+ Object clusterPropertyValue = res.getPropertyValue(clusterNameProperty);
+ if (null == clusterPropertyValue)
+ continue;
+
+ String clusterName = clusterPropertyValue.toString();
if (null == clusterName)
continue;
http://git-wip-us.apache.org/repos/asf/ambari/blob/982c6075/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
index 9c6977d..9f3ff85 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/nagios/NagiosPropertyProviderTest.java
@@ -120,6 +120,29 @@ public class NagiosPropertyProviderTest {
Assert.assertFalse("Expected no alerts", values.containsKey("alerts"));
}
+
+
+ @Test
+ public void testClusterDoesNotExistNPE() throws Exception {
+ TestStreamProvider streamProvider = new TestStreamProvider("nagios_alerts.txt");
+
+ NagiosPropertyProvider npp = new NagiosPropertyProvider(Resource.Type.Service,
+ streamProvider,
+ "ServiceInfo/cluster_name",
+ "ServiceInfo/service_name");
+
+ Resource resource = new ResourceImpl(Resource.Type.Service);
+ resource.setProperty("ServiceInfo/cluster_name", null);
+ resource.setProperty("ServiceInfo/service_name", "HBASE");
+
+ // request with an empty set should get all supported properties
+ Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet(),
+ new HashMap<String, TemporalInfo>());
+
+ Set<Resource> set = npp.populateResources(Collections.singleton(resource), request, null);
+ Assert.assertEquals(1, set.size());
+
+ }
@Test
public void testNoNagiosServerCompoonent() throws Exception {