Add Jetty acceptors and selectors support

Add support for Jetty `acceptors` and `selectors` configuration, either
directly on the `JettyEmbeddedServletContainerFactory` or via
`server.jetty.acceptors`/`server.jetty.selectors` server properties.

Fixes gh-5380
Closes gh-5649
This commit is contained in:
Venil Noronha
2016-04-11 09:29:57 +05:30
committed by Phillip Webb
parent 1bf10f2926
commit 1def64e49e
4 changed files with 106 additions and 3 deletions

View File

@@ -402,7 +402,7 @@ public class ServerProperties
return this.tomcat;
}
private Jetty getJetty() {
public Jetty getJetty() {
return this.jetty;
}
@@ -950,11 +950,43 @@ public class ServerProperties
}
private static class Jetty {
public static class Jetty {
/**
* Number of acceptor threads to use.
*/
private Integer acceptors;
/**
* Number of selector threads to use.
*/
private Integer selectors;
public Integer getAcceptors() {
return this.acceptors;
}
public void setAcceptors(Integer acceptors) {
this.acceptors = acceptors;
}
public Integer getSelectors() {
return this.selectors;
}
public void setSelectors(Integer selectors) {
this.selectors = selectors;
}
void customizeJetty(ServerProperties serverProperties,
JettyEmbeddedServletContainerFactory factory) {
factory.setUseForwardHeaders(serverProperties.getOrDeduceUseForwardHeaders());
if (this.acceptors != null) {
factory.setAcceptors(this.acceptors);
}
if (this.selectors != null) {
factory.setSelectors(this.selectors);
}
if (serverProperties.getMaxHttpHeaderSize() > 0) {
customizeMaxHttpHeaderSize(factory,
serverProperties.getMaxHttpHeaderSize());

View File

@@ -64,6 +64,7 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @author Eddú Meléndez
* @author Quinten De Swaef
* @author Venil Noronha
*/
public class ServerPropertiesTests {
@@ -260,6 +261,30 @@ public class ServerPropertiesTests {
assertThat(this.properties.getMaxHttpHeaderSize()).isEqualTo(9999);
}
@Test
public void testCustomizePostSize() throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("server.maxHttpPostSize", "9999");
bindProperties(map);
assertThat(this.properties.getMaxHttpPostSize()).isEqualTo(9999);
}
@Test
public void testCustomizeJettyAcceptors() throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("server.jetty.acceptors", "10");
bindProperties(map);
assertThat(this.properties.getJetty().getAcceptors()).isEqualTo(10);
}
@Test
public void testCustomizeJettySelectors() throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("server.jetty.selectors", "10");
bindProperties(map);
assertThat(this.properties.getJetty().getSelectors()).isEqualTo(10);
}
@Test
public void testCustomizeTomcatMinSpareThreads() throws Exception {
Map<String, String> map = new HashMap<String, String>();