|
|
|
@ -86,6 +86,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
|
* @author Quinten De Swaef
|
|
|
|
|
* @author Venil Noronha
|
|
|
|
|
* @author Aurélien Leboulanger
|
|
|
|
|
*/
|
|
|
|
|
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
|
|
|
|
|
public class ServerProperties
|
|
|
|
@ -656,6 +657,19 @@ public class ServerProperties
|
|
|
|
|
*/
|
|
|
|
|
private Charset uriEncoding;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maximum amount of connections accept and process.
|
|
|
|
|
* <p>Once the limit has been reached,
|
|
|
|
|
* the operating system may still accept connections based on the @link{acceptCount} setting.</p>
|
|
|
|
|
*/
|
|
|
|
|
private int maxConnections = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maximum queue length for incoming connection requests when all possible request processing threads are in use.
|
|
|
|
|
* Any requests received when the queue is full will be refused.
|
|
|
|
|
*/
|
|
|
|
|
private int acceptCount = 0;
|
|
|
|
|
|
|
|
|
|
public int getMaxThreads() {
|
|
|
|
|
return this.maxThreads;
|
|
|
|
|
}
|
|
|
|
@ -748,6 +762,22 @@ public class ServerProperties
|
|
|
|
|
this.uriEncoding = uriEncoding;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getMaxConnections() {
|
|
|
|
|
return this.maxConnections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMaxConnections(int maxConnections) {
|
|
|
|
|
this.maxConnections = maxConnections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getAcceptCount() {
|
|
|
|
|
return this.acceptCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAcceptCount(int acceptCount) {
|
|
|
|
|
this.acceptCount = acceptCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void customizeTomcat(ServerProperties serverProperties,
|
|
|
|
|
TomcatEmbeddedServletContainerFactory factory) {
|
|
|
|
|
if (getBasedir() != null) {
|
|
|
|
@ -782,6 +812,40 @@ public class ServerProperties
|
|
|
|
|
if (this.redirectContextRoot != null) {
|
|
|
|
|
customizeRedirectContextRoot(factory, this.redirectContextRoot);
|
|
|
|
|
}
|
|
|
|
|
if (this.maxConnections > 0) {
|
|
|
|
|
customizeMaxConnections(factory);
|
|
|
|
|
}
|
|
|
|
|
if (this.acceptCount > 0) {
|
|
|
|
|
customizeAcceptCount(factory);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void customizeAcceptCount(TomcatEmbeddedServletContainerFactory factory) {
|
|
|
|
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void customize(Connector connector) {
|
|
|
|
|
ProtocolHandler handler = connector.getProtocolHandler();
|
|
|
|
|
if (handler instanceof AbstractProtocol) {
|
|
|
|
|
AbstractProtocol protocol = (AbstractProtocol) handler;
|
|
|
|
|
protocol.setBacklog(Tomcat.this.acceptCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void customizeMaxConnections(TomcatEmbeddedServletContainerFactory factory) {
|
|
|
|
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void customize(Connector connector) {
|
|
|
|
|
ProtocolHandler handler = connector.getProtocolHandler();
|
|
|
|
|
if (handler instanceof AbstractProtocol) {
|
|
|
|
|
AbstractProtocol protocol = (AbstractProtocol) handler;
|
|
|
|
|
protocol.setMaxConnections(Tomcat.this.maxConnections);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void customizeConnectionTimeout(
|
|
|
|
|