Переглянути джерело

AMBARI-8118. HostComponent requests that include Nagios are not performant (ncole)

Nate Cole 10 роки тому
батько
коміт
08101e4300

+ 0 - 2
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);
   }
 

+ 1 - 9
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();

+ 6 - 92
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 {
@@ -126,91 +125,6 @@ public class HttpPropertyProviderTest {
             "/ws/v1/cluster/info"));
   }
 
-  @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 {