You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cd...@apache.org on 2018/03/13 21:21:32 UTC
[3/3] hadoop git commit: HADOOP-15311. HttpServer2 needs a way to
configure the acceptor/selector count. Contributed by Erik Krogen
HADOOP-15311. HttpServer2 needs a way to configure the acceptor/selector count. Contributed by Erik Krogen
(cherry picked from commit 9d6994da1964c1125a33b3a65e7a7747e2d0bc59)
(cherry picked from commit 80641508c721fe49c8ace4730b647efd3ce84fbd)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9889e55e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9889e55e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9889e55e
Branch: refs/heads/branch-3.0
Commit: 9889e55e5a27506e92defc7910c36b3bee10a39d
Parents: fc6f3e2
Author: Chris Douglas <cd...@apache.org>
Authored: Tue Mar 13 13:53:58 2018 -0700
Committer: Chris Douglas <cd...@apache.org>
Committed: Tue Mar 13 14:20:44 2018 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/http/HttpServer2.java | 12 +++++++++-
.../org/apache/hadoop/http/TestHttpServer.java | 23 +++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9889e55e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
index fb49d2d..d36cdf4 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java
@@ -133,6 +133,14 @@ public final class HttpServer2 implements FilterContainer {
"hadoop.http.socket.backlog.size";
public static final int HTTP_SOCKET_BACKLOG_SIZE_DEFAULT = 128;
public static final String HTTP_MAX_THREADS_KEY = "hadoop.http.max.threads";
+ public static final String HTTP_ACCEPTOR_COUNT_KEY =
+ "hadoop.http.acceptor.count";
+ // -1 to use default behavior of setting count based on CPU core count
+ public static final int HTTP_ACCEPTOR_COUNT_DEFAULT = -1;
+ public static final String HTTP_SELECTOR_COUNT_KEY =
+ "hadoop.http.selector.count";
+ // -1 to use default behavior of setting count based on CPU core count
+ public static final int HTTP_SELECTOR_COUNT_DEFAULT = -1;
public static final String HTTP_TEMP_DIR_KEY = "hadoop.http.temp.dir";
static final String FILTER_INITIALIZER_PROPERTY
@@ -464,7 +472,9 @@ public final class HttpServer2 implements FilterContainer {
private ServerConnector createHttpChannelConnector(
Server server, HttpConfiguration httpConfig) {
- ServerConnector conn = new ServerConnector(server);
+ ServerConnector conn = new ServerConnector(server,
+ conf.getInt(HTTP_ACCEPTOR_COUNT_KEY, HTTP_ACCEPTOR_COUNT_DEFAULT),
+ conf.getInt(HTTP_SELECTOR_COUNT_KEY, HTTP_SELECTOR_COUNT_DEFAULT));
ConnectionFactory connFactory = new HttpConnectionFactory(httpConfig);
conn.addConnectionFactory(connFactory);
configureChannelConnector(conn);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9889e55e/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
index ca7e466..7350d09 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java
@@ -147,7 +147,7 @@ public class TestHttpServer extends HttpServerFunctionalTest {
@BeforeClass public static void setup() throws Exception {
Configuration conf = new Configuration();
- conf.setInt(HttpServer2.HTTP_MAX_THREADS_KEY, 10);
+ conf.setInt(HttpServer2.HTTP_MAX_THREADS_KEY, MAX_THREADS);
server = createTestServer(conf);
server.addServlet("echo", "/echo", EchoServlet.class);
server.addServlet("echomap", "/echomap", EchoMapServlet.class);
@@ -195,6 +195,27 @@ public class TestHttpServer extends HttpServerFunctionalTest {
ready.await();
start.countDown();
}
+
+ /**
+ * Test that the number of acceptors and selectors can be configured by
+ * trying to configure more of them than would be allowed based on the
+ * maximum thread count.
+ */
+ @Test
+ public void testAcceptorSelectorConfigurability() throws Exception {
+ Configuration conf = new Configuration();
+ conf.setInt(HttpServer2.HTTP_MAX_THREADS_KEY, MAX_THREADS);
+ conf.setInt(HttpServer2.HTTP_ACCEPTOR_COUNT_KEY, MAX_THREADS - 2);
+ conf.setInt(HttpServer2.HTTP_SELECTOR_COUNT_KEY, MAX_THREADS - 2);
+ HttpServer2 badserver = createTestServer(conf);
+ try {
+ badserver.start();
+ // Should not succeed
+ fail();
+ } catch (IOException ioe) {
+ assertTrue(ioe.getCause() instanceof IllegalStateException);
+ }
+ }
@Test public void testEcho() throws Exception {
assertEquals("a:b\nc:d\n",
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org