HADOOP-14560. Make HttpServer2 backlog size configurable. Contributed by Alexander Krasheninnikov.
This closes #242.
This commit is contained in:
parent
96b3a6b972
commit
1f04cb45f7
@ -128,6 +128,10 @@ public final class HttpServer2 implements FilterContainer {
|
||||
public static final String HTTP_MAX_RESPONSE_HEADER_SIZE_KEY =
|
||||
"hadoop.http.max.response.header.size";
|
||||
public static final int HTTP_MAX_RESPONSE_HEADER_SIZE_DEFAULT = 65536;
|
||||
|
||||
public static final String HTTP_SOCKET_BACKLOG_SIZE_KEY =
|
||||
"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_TEMP_DIR_KEY = "hadoop.http.temp.dir";
|
||||
|
||||
@ -433,6 +437,9 @@ public HttpServer2 build() throws IOException {
|
||||
httpConfig.setResponseHeaderSize(responseHeaderSize);
|
||||
httpConfig.setSendServerVersion(false);
|
||||
|
||||
int backlogSize = conf.getInt(HTTP_SOCKET_BACKLOG_SIZE_KEY,
|
||||
HTTP_SOCKET_BACKLOG_SIZE_DEFAULT);
|
||||
|
||||
for (URI ep : endpoints) {
|
||||
final ServerConnector connector;
|
||||
String scheme = ep.getScheme();
|
||||
@ -448,6 +455,7 @@ public HttpServer2 build() throws IOException {
|
||||
}
|
||||
connector.setHost(ep.getHost());
|
||||
connector.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
|
||||
connector.setAcceptQueueSize(backlogSize);
|
||||
server.addListener(connector);
|
||||
}
|
||||
server.loadListeners();
|
||||
@ -640,7 +648,6 @@ private static void addNoCacheFilter(ServletContextHandler ctxt) {
|
||||
|
||||
private static void configureChannelConnector(ServerConnector c) {
|
||||
c.setIdleTimeout(10000);
|
||||
c.setAcceptQueueSize(128);
|
||||
if(Shell.WINDOWS) {
|
||||
// result of setting the SO_REUSEADDR flag is different on Windows
|
||||
// http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
|
||||
|
@ -682,4 +682,17 @@ public void testPortRanges() throws Exception {
|
||||
stopHttpServer(myServer2);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBacklogSize() throws Exception
|
||||
{
|
||||
final int backlogSize = 2048;
|
||||
Configuration conf = new Configuration();
|
||||
conf.setInt(HttpServer2.HTTP_SOCKET_BACKLOG_SIZE_KEY, backlogSize);
|
||||
HttpServer2 srv = createServer("test", conf);
|
||||
List<?> listeners = (List<?>) Whitebox.getInternalState(srv,
|
||||
"listeners");
|
||||
ServerConnector listener = (ServerConnector)listeners.get(0);
|
||||
assertEquals(backlogSize, listener.getAcceptQueueSize());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user