Repository: ambari Updated Branches: refs/heads/trunk 0de2eb028 -> 08101e430
AMBARI-8118. HostComponent requests that include Nagios are not performant (ncole) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/08101e43 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/08101e43 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/08101e43 Branch: refs/heads/trunk Commit: 08101e4300d9d1c7093ca0e32ff3ba38d00f84bf Parents: 0de2eb0 Author: Nate Cole <[email protected]> Authored: Mon Nov 3 12:21:54 2014 -0500 Committer: Nate Cole <[email protected]> Committed: Mon Nov 3 13:50:04 2014 -0500 ---------------------------------------------------------------------- .../internal/HostComponentResourceProvider.java | 2 - .../internal/HttpProxyPropertyProvider.java | 10 +- .../internal/HttpPropertyProviderTest.java | 98 ++------------------ 3 files changed, 7 insertions(+), 103 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/08101e43/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java index 732203a..4600538 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java @@ -122,8 +122,6 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro PropertyHelper.getPropertyId("HostRoles", "host_name"), PropertyHelper.getPropertyId("HostRoles", "component_name")); - HOST_COMPONENT_PROPERTIES_PROVIDER.put("NAGIOS_SERVER", httpPropertyProvider); - HOST_COMPONENT_PROPERTIES_PROVIDER.put("RESOURCEMANAGER", httpPropertyProvider); } http://git-wip-us.apache.org/repos/asf/ambari/blob/08101e43/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java index ca2bd52..302a54b 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java @@ -58,7 +58,6 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP private static final Map<String, String> PROPERTIES_TO_FILTER = new HashMap<String, String>(); private static final String COMPONENT_RESOURCEMANAGER = "RESOURCEMANAGER"; - private static final String COMPONENT_NAGIOS_SERVER = "NAGIOS_SERVER"; private static final String CONFIG_YARN_SITE = "yarn-site"; private static final String CONFIG_CORE_SITE = "core-site"; private static final String PROPERTY_YARN_HTTP_POLICY = "yarn.http.policy"; @@ -67,11 +66,8 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP private static final String PROPERTY_HADOOP_SSL_ENABLED_VALUE_TRUE = "true"; static { - URL_TEMPLATES.put(COMPONENT_NAGIOS_SERVER, "http://%s/ambarinagios/nagios/nagios_alerts.php?q1=alerts&" + - "alert_type=all"); URL_TEMPLATES.put(COMPONENT_RESOURCEMANAGER, "http://%s:8088/ws/v1/cluster/info"); - MAPPINGS.put(COMPONENT_NAGIOS_SERVER, PropertyHelper.getPropertyId("HostRoles", "nagios_alerts")); MAPPINGS.put(COMPONENT_RESOURCEMANAGER, PropertyHelper.getPropertyId("HostRoles", "ha_state")); PROPERTIES_TO_FILTER.put(COMPONENT_RESOURCEMANAGER, "clusterInfo/haState"); @@ -143,11 +139,7 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP private String getTemplate(String componentName, String clusterName) throws SystemException { String template = URL_TEMPLATES.get(componentName); - if (componentName.equals(COMPONENT_NAGIOS_SERVER)) { - if (configuration.isNagiosSSL()) { - template = template.replace("http", "https"); - } - } else if (componentName.equals(COMPONENT_RESOURCEMANAGER)) { + if (componentName.equals(COMPONENT_RESOURCEMANAGER)) { try { Cluster cluster = this.clusters.getCluster(clusterName); Map<String, String> yarnConfigProperties = cluster.getDesiredConfigByType(CONFIG_YARN_SITE).getProperties(); http://git-wip-us.apache.org/repos/asf/ambari/blob/08101e43/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java index bf3550f..2cc788a 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java @@ -18,19 +18,20 @@ package org.apache.ambari.server.controller.internal; +import static org.easymock.EasyMock.createNiceMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; -import java.util.HashMap; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; -import java.util.List; +import java.util.HashMap; import java.util.Map; import java.util.Set; -import com.google.inject.Injector; import org.apache.ambari.server.configuration.ComponentSSLConfiguration; import org.apache.ambari.server.configuration.ComponentSSLConfigurationTest; import org.apache.ambari.server.controller.spi.Request; @@ -45,9 +46,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import static org.easymock.EasyMock.createNiceMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; +import com.google.inject.Injector; @RunWith(Parameterized.class) public class HttpPropertyProviderTest { @@ -127,91 +126,6 @@ public class HttpPropertyProviderTest { } @Test - public void testReadNagiosServer() throws Exception { - - TestStreamProvider streamProvider = new TestStreamProvider(false); - - Resource resource = doPopulate("NAGIOS_SERVER", Collections.<String>emptySet(), streamProvider); - - Assert.assertNotNull("Expected non-null for 'nagios_alerts'", - resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS)); - - Assert.assertEquals(configuration.isNagiosSSL(), streamProvider.getLastSpec().startsWith("https")); - } - - @Test - public void testReadNotRequested() throws Exception { - - Set<String> propertyIds = new HashSet<String>(); - propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "state")); - propertyIds.add(PROPERTY_ID_COMPONENT_NAME); - - Resource resource = doPopulate("NAGIOS_SERVER", propertyIds, new TestStreamProvider(false)); - - Assert.assertNull("Expected null for 'nagios_alerts'", - resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS)); - } - - @Test - public void testReadWithRequested() throws Exception { - - Set<String> propertyIds = new HashSet<String>(); - propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "nagios_alerts")); - propertyIds.add(PROPERTY_ID_COMPONENT_NAME); - - Resource resource = doPopulate("NAGIOS_SERVER", propertyIds, new TestStreamProvider(false)); - - Assert.assertNotNull("Expected non-null for 'nagios_alerts'", - resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS)); - } - - @Test - public void testReadWithRequestedFail() throws Exception { - - Set<String> propertyIds = new HashSet<String>(); - propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "nagios_alerts")); - propertyIds.add(PROPERTY_ID_COMPONENT_NAME); - - Resource resource = doPopulate("NAGIOS_SERVER", propertyIds, new TestStreamProvider(true)); - - Assert.assertNull("Expected null for 'nagios_alerts'", - resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS)); - } - - @SuppressWarnings("rawtypes") - @Test - public void testReadWithRequestedJson() throws Exception { - - Set<String> propertyIds = new HashSet<String>(); - propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "nagios_alerts")); - propertyIds.add(PROPERTY_ID_COMPONENT_NAME); - Resource resource = doPopulate("NAGIOS_SERVER", propertyIds, new TestStreamProvider(false)); - Object propertyValue = resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS); - - Assert.assertNotNull("Expected non-null for 'nagios_alerts'", propertyValue); - Assert.assertTrue("Expected Map for parsed JSON", propertyValue instanceof Map); - - Object alertsEntry = ((Map) propertyValue).get("alerts"); - Object hostcountsEntry = ((Map) propertyValue).get("hostcounts"); - - Assert.assertNotNull("Expected non-null for 'alerts' entry", alertsEntry); - Assert.assertNotNull("Expected non-null for 'hostcounts' entry", hostcountsEntry); - Assert.assertTrue("Expected List type for 'alerts' entry", alertsEntry instanceof List); - Assert.assertTrue("Expected Map type for 'hostcounts' entry", hostcountsEntry instanceof Map); - - List alertsList = (List) alertsEntry; - Map hostcountsMap = (Map) hostcountsEntry; - - Assert.assertEquals("Expected number of entries in 'alerts' is 1", 1, alertsList.size()); - Assert.assertTrue("Expected Map type for 'alerts' element", alertsList.get(0) instanceof Map); - Assert.assertEquals("Body", ((Map) alertsList.get(0)).get("Alert Body")); - - Assert.assertEquals("Expected number of entries in 'hostcounts' is 2", 2, hostcountsMap.size()); - Assert.assertEquals("1", hostcountsMap.get("up_hosts")); - Assert.assertEquals("0", hostcountsMap.get("down_hosts")); - } - - @Test public void testReadGangliaServer() throws Exception { Resource resource = doPopulate("GANGLIA_SERVER", Collections.<String>emptySet(), new TestStreamProvider(false));
