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:55 UTC
[1/2] ambari git commit: AMBARI-15371. Increase the default http
header size of the Ambari server to 64k. (mpapirkovskyy)
Repository: ambari
Updated Branches:
refs/heads/trunk 977cb4bc9 -> 962a97304
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/39eded40
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/39eded40
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/39eded40
Branch: refs/heads/trunk
Commit: 39eded40b1dcf063c351f4bb6832117d14fd0583
Parents: 977cb4b
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:37:35 2016 +0200
----------------------------------------------------------------------
.../server/configuration/Configuration.java | 21 ++++++++++++++++++++
.../ambari/server/controller/AmbariServer.java | 12 +++++++++++
2 files changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/39eded40/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 92d4f47..23571c6 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
@@ -196,6 +196,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_SKIP_PACKAGES_PREFIXES_KEY = "rolling.upgrade.skip.packages.prefixes";
public static final String ROLLING_UPGRADE_SKIP_PACKAGES_PREFIXES_DEFAULT = "";
@@ -1783,6 +1788,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/39eded40/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 4695990..076f850 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
@@ -377,6 +377,7 @@ public class AmbariServer {
httpConfigurationTwoWay.setSecureScheme("https");
httpConfigurationTwoWay.setSecurePort(configs.getTwoWayAuthPort());
httpConfigurationTwoWay.addCustomizer(new SecureRequestCustomizer());
+ setHeaderSize(httpConfigurationTwoWay);
String keystore = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) + File.separator
+ configsMap.get(Configuration.KSTR_NAME_KEY);
@@ -412,6 +413,7 @@ public class AmbariServer {
httpConfigurationOneWay.setSecureScheme("https");
httpConfigurationOneWay.setSecurePort(configs.getOneWayAuthPort());
httpConfigurationOneWay.addCustomizer(new SecureRequestCustomizer());
+ setHeaderSize(httpConfigurationOneWay);
Map <String, Integer> agentSelectorAcceptorMap = getDesiredAgentAcceptorSelector(serverForAgent);
// SSL for 1-way auth
@@ -529,6 +531,7 @@ public class AmbariServer {
HttpConfiguration httpConfigurationSSL = new HttpConfiguration();
httpConfigurationSSL.setSecurePort(configs.getClientSSLApiPort());
+ setHeaderSize(httpConfigurationSSL);
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(contextFactoryApi, "http/1.1"),
new HttpConnectionFactory(httpConfigurationSSL));
@@ -538,6 +541,7 @@ public class AmbariServer {
} else {
HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setSecurePort(configs.getClientApiPort());
+ setHeaderSize(httpConfiguration);
apiConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
apiConnector.setPort(configs.getClientApiPort());
@@ -717,6 +721,14 @@ public class AmbariServer {
}
/**
+ * Propagate header size to Jetty HTTP configuration
+ */
+ private void setHeaderSize(HttpConfiguration httpConfiguration) {
+ httpConfiguration.setResponseHeaderSize(configs.getHttpResponseHeaderSize());
+ httpConfiguration.setRequestHeaderSize(configs.getHttpRequestHeaderSize());
+ }
+
+ /**
* Performs basic configuration of root handler with static values and values
* from configuration file.
*
[2/2] ambari git commit: AMBARI-15375. NPE while gathering JMX ports
from configs. (mpapirkovskyy)
Posted by mp...@apache.org.
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/962a9730
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/962a9730
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/962a9730
Branch: refs/heads/trunk
Commit: 962a9730454f1b771d08ff3280f773a8a1251b7e
Parents: 39eded4
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:37:36 2016 +0200
----------------------------------------------------------------------
.../internal/AbstractProviderModule.java | 27 +++++++++++++-------
.../internal/StackDefinedPropertyProvider.java | 4 +--
.../internal/JMXHostProviderTest.java | 3 +++
3 files changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/962a9730/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 b96addb..30e5b9c 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/962a9730/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 edd11c1..6c40d14 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
@@ -209,8 +209,8 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
} catch (AuthorizationException e) {
// Need to rethrow the catched 'AuthorizationException'.
throw e;
- }
- catch (Exception e) {
+ } catch (Exception e) {
+ 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/962a9730/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 187e0a6..70e21d3 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
@@ -543,6 +543,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 {