You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mp...@apache.org on 2016/03/11 16:18:32 UTC

[1/2] ambari git commit: AMBARI-15375. NPE while gathering JMX ports from configs. (mpapirkovskyy)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 fe2462876 -> 3b5a96d27


AMBARI-15375. NPE while gathering JMX ports from configs. (mpapirkovskyy)


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

Branch: refs/heads/branch-2.2
Commit: 3b5a96d272423740a856411eb57a4f7f29626062
Parents: 161cbd0
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Thu Mar 10 17:00:31 2016 +0200
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
Committed: Fri Mar 11 16:47:04 2016 +0200

----------------------------------------------------------------------
 .../internal/AbstractProviderModule.java        | 27 +++++++++++++-------
 .../internal/StackDefinedPropertyProvider.java  |  2 +-
 .../internal/JMXHostProviderTest.java           |  3 +++
 3 files changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3b5a96d2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
index ff9b4e4..7747753 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
@@ -66,6 +66,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.GANGLIA;
 import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.TIMELINE_METRICS;
@@ -199,8 +200,8 @@ public abstract class AbstractProviderModule implements ProviderModule,
   /**
    * JMX ports read from the configs
    */
-  private final Map<String, Map<String, Map<String, String>> >jmxPortMap =
-      new HashMap<String, Map<String, Map<String, String>>>();
+  private final Map<String, ConcurrentMap<String, ConcurrentMap<String, String>> >jmxPortMap =
+      Collections.synchronizedMap(new HashMap<String, ConcurrentMap<String, ConcurrentMap<String, String>>>());
 
   private volatile boolean initialized = false;
 
@@ -494,12 +495,12 @@ public abstract class AbstractProviderModule implements ProviderModule,
   @Override
   public String getPort(String clusterName, String componentName, String hostName, boolean httpsEnabled) throws SystemException {
     // Parent map need not be synchronized
-    Map<String, Map<String, String>> clusterJmxPorts = jmxPortMap.get(clusterName);
+    ConcurrentMap<String, ConcurrentMap<String, String>> clusterJmxPorts = jmxPortMap.get(clusterName);
     if (clusterJmxPorts == null) {
       synchronized (jmxPortMap) {
         clusterJmxPorts = jmxPortMap.get(clusterName);
         if (clusterJmxPorts == null) {
-          clusterJmxPorts = new ConcurrentHashMap<String, Map<String, String>>();
+          clusterJmxPorts = new ConcurrentHashMap<String, ConcurrentMap<String, String>>();
           jmxPortMap.put(clusterName, clusterJmxPorts);
         }
       }
@@ -547,20 +548,28 @@ public abstract class AbstractProviderModule implements ProviderModule,
             // this will trigger using the default port for the component
             String portString = getPortString(entry.getValue());
             if (null != portString) {
-              if(!clusterJmxPorts.containsKey(hostName)) {
-                clusterJmxPorts.put(hostName, new ConcurrentHashMap<String, String>());
-              }
+              clusterJmxPorts.putIfAbsent(hostName, new ConcurrentHashMap<String, String>());
               clusterJmxPorts.get(hostName).put(entry.getKey(), portString);
             }
           }
         }
       } catch (Exception e) {
-        LOG.error("Exception initializing jmx port maps. " + e);
+        LOG.error("Exception initializing jmx port maps. ", e);
       }
     }
 
     LOG.debug("jmxPortMap -> " + jmxPortMap);
-    return clusterJmxPorts.get(hostName).get(componentName);
+
+    ConcurrentMap<String, String> hostJmxPorts = clusterJmxPorts.get(hostName);
+    if (hostJmxPorts == null) {
+      LOG.debug("Jmx ports not loaded from properties: clusterName={}, componentName={}, hostName={}, " +
+          "clusterJmxPorts={}, jmxPortMap.get(clusterName)={}",
+          clusterName, componentName, hostName, clusterJmxPorts, jmxPortMap.get(clusterName));
+      //returning null is acceptable in cases when property with port not present
+      //or loading from property is not supported for specific component
+      return null;
+    }
+    return hostJmxPorts.get(componentName);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b5a96d2/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 a1b4f3f..228ce01 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
@@ -207,7 +207,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
       }
 
     } catch (Exception e) {
-      e.printStackTrace();
+      LOG.error("Error loading deferred resources", e);
       throw new SystemException("Error loading deferred resources", e);
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3b5a96d2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index 8894ef8..029720e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -537,6 +537,9 @@ public class JMXHostProviderTest {
     //Unrelated ports
     Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE", "localhost"));
     Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER", "localhost"));
+
+    //test another host and component without property
+    Assert.assertNull(providerModule.getPort("c1", "HBASE_REGIONSERVER", "remotehost1"));
   }
 
   private static class JMXHostProviderModule extends AbstractProviderModule {


[2/2] ambari git commit: AMBARI-15371. Increase the default http header size of the Ambari server to 64k. (mpapirkovskyy)

Posted by mp...@apache.org.
AMBARI-15371. Increase the default http header size of the Ambari server to 64k. (mpapirkovskyy)


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

Branch: refs/heads/branch-2.2
Commit: 161cbd07b71611c78d83d513fa8a99fdf090b922
Parents: fe24628
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Thu Mar 10 17:29:04 2016 +0200
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
Committed: Fri Mar 11 16:47:04 2016 +0200

----------------------------------------------------------------------
 .../server/configuration/Configuration.java     | 21 ++++++++++++++++++++
 .../ambari/server/controller/AmbariServer.java  |  7 +++++++
 2 files changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/161cbd07/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 3fbcc6d..02f993e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -188,6 +188,11 @@ public class Configuration {
   public static final String SERVER_JDBC_URL_KEY = "server.jdbc.url";
   public static final String SERVER_JDBC_PROPERTIES_PREFIX = "server.jdbc.properties.";
 
+  public static final String SERVER_HTTP_REQUEST_HEADER_SIZE = "server.http.request.header.size";
+  public static final String SERVER_HTTP_RESPONSE_HEADER_SIZE = "server.http.response.header.size";
+  public static final int SERVER_HTTP_REQUEST_HEADER_SIZE_DEFAULT = 64*1024;
+  public static final int SERVER_HTTP_RESPONSE_HEADER_SIZE_DEFAULT = 64*1024;
+
   // Properties for stack upgrade (Rolling, Express)
   public static final String ROLLING_UPGRADE_MIN_STACK_KEY = "rolling.upgrade.min.stack";
   public static final String ROLLING_UPGRADE_MAX_STACK_KEY = "rolling.upgrade.max.stack";
@@ -1740,6 +1745,22 @@ public class Configuration {
     return customDbProperties;
   }
 
+  /**
+   * @return Custom property for request header size
+   */
+  public int getHttpRequestHeaderSize() {
+    return Integer.parseInt(properties.getProperty(
+        SERVER_HTTP_REQUEST_HEADER_SIZE, String.valueOf(SERVER_HTTP_REQUEST_HEADER_SIZE_DEFAULT)));
+  }
+
+  /**
+   * @return Custom property for response header size
+   */
+  public int getHttpResponseHeaderSize() {
+    return Integer.parseInt(properties.getProperty(
+        SERVER_HTTP_RESPONSE_HEADER_SIZE, String.valueOf(SERVER_HTTP_RESPONSE_HEADER_SIZE_DEFAULT)));
+  }
+
   public Map<String, String> getAmbariProperties() {
 
     Properties properties = readConfigFile();

http://git-wip-us.apache.org/repos/asf/ambari/blob/161cbd07/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 2cd80aa..a4f3c30 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -381,6 +381,8 @@ public class AmbariServer {
       sslConnectorTwoWay.setKeystoreType(configsMap.get(Configuration.KSTR_TYPE_KEY));
       sslConnectorTwoWay.setTruststoreType(configsMap.get(Configuration.TSTR_TYPE_KEY));
       sslConnectorTwoWay.setNeedClientAuth(configs.getTwoWaySsl());
+      sslConnectorTwoWay.setRequestHeaderSize(configs.getHttpRequestHeaderSize());
+      sslConnectorTwoWay.setResponseHeaderSize(configs.getHttpResponseHeaderSize());
 
       //SSL Context Factory
       SslContextFactory contextFactoryOneWay = new SslContextFactory(true);
@@ -397,6 +399,8 @@ public class AmbariServer {
       //Secured connector for 1-way auth
       SslSelectChannelConnector sslConnectorOneWay = new SslSelectChannelConnector(contextFactoryOneWay);
       sslConnectorOneWay.setPort(configs.getOneWayAuthPort());
+      sslConnectorOneWay.setRequestHeaderSize(configs.getHttpRequestHeaderSize());
+      sslConnectorOneWay.setResponseHeaderSize(configs.getHttpResponseHeaderSize());
 
       // because there are two connectors sharing the same pool, cut each's
       // acceptors in half
@@ -498,6 +502,9 @@ public class AmbariServer {
         apiConnector.setMaxIdleTime(configs.getConnectionMaxIdleTime());
       }
 
+      apiConnector.setRequestHeaderSize(configs.getHttpRequestHeaderSize());
+      apiConnector.setResponseHeaderSize(configs.getHttpResponseHeaderSize());
+
       // Client Jetty thread pool
       configureJettyThreadPool(server, apiConnector.getAcceptors(), "qtp-ambari-client", configs.getClientThreadPoolSize());
       server.addConnector(apiConnector);