HADOOP-15696. KMS performance regression due to too many open file descriptors after Jetty migration. Contributed by Wei-Chiu Chuang.
This commit is contained in:
parent
9315db5f5d
commit
e780556ae9
@ -141,6 +141,10 @@ public final class HttpServer2 implements FilterContainer {
|
|||||||
"hadoop.http.selector.count";
|
"hadoop.http.selector.count";
|
||||||
// -1 to use default behavior of setting count based on CPU core 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 int HTTP_SELECTOR_COUNT_DEFAULT = -1;
|
||||||
|
// idle timeout in milliseconds
|
||||||
|
public static final String HTTP_IDLE_TIMEOUT_MS_KEY =
|
||||||
|
"hadoop.http.idle_timeout.ms";
|
||||||
|
public static final int HTTP_IDLE_TIMEOUT_MS_DEFAULT = 10000;
|
||||||
public static final String HTTP_TEMP_DIR_KEY = "hadoop.http.temp.dir";
|
public static final String HTTP_TEMP_DIR_KEY = "hadoop.http.temp.dir";
|
||||||
|
|
||||||
public static final String FILTER_INITIALIZER_PROPERTY
|
public static final String FILTER_INITIALIZER_PROPERTY
|
||||||
@ -445,6 +449,8 @@ public HttpServer2 build() throws IOException {
|
|||||||
int responseHeaderSize = conf.getInt(
|
int responseHeaderSize = conf.getInt(
|
||||||
HTTP_MAX_RESPONSE_HEADER_SIZE_KEY,
|
HTTP_MAX_RESPONSE_HEADER_SIZE_KEY,
|
||||||
HTTP_MAX_RESPONSE_HEADER_SIZE_DEFAULT);
|
HTTP_MAX_RESPONSE_HEADER_SIZE_DEFAULT);
|
||||||
|
int idleTimeout = conf.getInt(HTTP_IDLE_TIMEOUT_MS_KEY,
|
||||||
|
HTTP_IDLE_TIMEOUT_MS_DEFAULT);
|
||||||
|
|
||||||
HttpConfiguration httpConfig = new HttpConfiguration();
|
HttpConfiguration httpConfig = new HttpConfiguration();
|
||||||
httpConfig.setRequestHeaderSize(requestHeaderSize);
|
httpConfig.setRequestHeaderSize(requestHeaderSize);
|
||||||
@ -470,6 +476,7 @@ public HttpServer2 build() throws IOException {
|
|||||||
connector.setHost(ep.getHost());
|
connector.setHost(ep.getHost());
|
||||||
connector.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
|
connector.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
|
||||||
connector.setAcceptQueueSize(backlogSize);
|
connector.setAcceptQueueSize(backlogSize);
|
||||||
|
connector.setIdleTimeout(idleTimeout);
|
||||||
server.addListener(connector);
|
server.addListener(connector);
|
||||||
}
|
}
|
||||||
server.loadListeners();
|
server.loadListeners();
|
||||||
@ -483,7 +490,13 @@ private ServerConnector createHttpChannelConnector(
|
|||||||
conf.getInt(HTTP_SELECTOR_COUNT_KEY, HTTP_SELECTOR_COUNT_DEFAULT));
|
conf.getInt(HTTP_SELECTOR_COUNT_KEY, HTTP_SELECTOR_COUNT_DEFAULT));
|
||||||
ConnectionFactory connFactory = new HttpConnectionFactory(httpConfig);
|
ConnectionFactory connFactory = new HttpConnectionFactory(httpConfig);
|
||||||
conn.addConnectionFactory(connFactory);
|
conn.addConnectionFactory(connFactory);
|
||||||
configureChannelConnector(conn);
|
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
|
||||||
|
// without this 2 NN's can start on the same machine and listen on
|
||||||
|
// the same port with indeterminate routing of incoming requests to them
|
||||||
|
conn.setReuseAddress(false);
|
||||||
|
}
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,17 +672,6 @@ private static void addNoCacheFilter(ServletContextHandler ctxt) {
|
|||||||
Collections.<String, String> emptyMap(), new String[] { "/*" });
|
Collections.<String, String> emptyMap(), new String[] { "/*" });
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void configureChannelConnector(ServerConnector c) {
|
|
||||||
c.setIdleTimeout(10000);
|
|
||||||
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
|
|
||||||
// without this 2 NN's can start on the same machine and listen on
|
|
||||||
// the same port with indeterminate routing of incoming requests to them
|
|
||||||
c.setReuseAddress(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get an array of FilterConfiguration specified in the conf */
|
/** Get an array of FilterConfiguration specified in the conf */
|
||||||
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
|
private static FilterInitializer[] getFilterInitializers(Configuration conf) {
|
||||||
if (conf == null) {
|
if (conf == null) {
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -702,6 +703,19 @@ public void testBacklogSize() throws Exception
|
|||||||
assertEquals(backlogSize, listener.getAcceptQueueSize());
|
assertEquals(backlogSize, listener.getAcceptQueueSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIdleTimeout() throws Exception {
|
||||||
|
final int idleTimeout = 1000;
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.setInt(HttpServer2.HTTP_IDLE_TIMEOUT_MS_KEY, idleTimeout);
|
||||||
|
HttpServer2 srv = createServer("test", conf);
|
||||||
|
Field f = HttpServer2.class.getDeclaredField("listeners");
|
||||||
|
f.setAccessible(true);
|
||||||
|
List<?> listeners = (List<?>) f.get(srv);
|
||||||
|
ServerConnector listener = (ServerConnector)listeners.get(0);
|
||||||
|
assertEquals(idleTimeout, listener.getIdleTimeout());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHttpResponseDefaultHeaders() throws Exception {
|
public void testHttpResponseDefaultHeaders() throws Exception {
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
|
@ -101,6 +101,13 @@
|
|||||||
</description>
|
</description>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
<property>
|
||||||
|
<name>hadoop.http.idle_timeout.ms</name>
|
||||||
|
<value>1000</value>
|
||||||
|
<description>
|
||||||
|
KMS Server connection timeout in milliseconds.
|
||||||
|
</description>
|
||||||
|
</property>
|
||||||
<!-- KMS Backend KeyProvider -->
|
<!-- KMS Backend KeyProvider -->
|
||||||
|
|
||||||
<property>
|
<property>
|
||||||
|
@ -54,6 +54,13 @@
|
|||||||
</property>
|
</property>
|
||||||
|
|
||||||
<!-- HTTP properties -->
|
<!-- HTTP properties -->
|
||||||
|
<property>
|
||||||
|
<name>hadoop.http.idle_timeout.ms</name>
|
||||||
|
<value>1000</value>
|
||||||
|
<description>
|
||||||
|
Httpfs Server connection timeout in milliseconds.
|
||||||
|
</description>
|
||||||
|
</property>
|
||||||
|
|
||||||
<property>
|
<property>
|
||||||
<name>hadoop.http.max.threads</name>
|
<name>hadoop.http.max.threads</name>
|
||||||
|
Loading…
Reference in New Issue
Block a user