Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configuring the blocking timeout for Jetty connectors #1795

Merged
merged 1 commit into from Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/manual/configuration.rst
Expand Up @@ -303,6 +303,9 @@ idleTimeout 30 seconds The maximum idle time for a connect
or when waiting for a new message to be sent on a connection.
This value is interpreted as the maximum time between some progress being made on the
connection. So if a single byte is read or written, then the timeout is reset.
blockingTimeout (none) The timeout applied to blocking operations. This timeout is in addition to
the `idleTimeout`, and applies to the total operation (as opposed to the
idle timeout that applies to the time no data is being sent).
minBufferPoolSize 64 bytes The minimum size of the buffer pool.
bufferPoolIncrement 1KiB The increment by which the buffer pool should be increased.
maxBufferPoolSize 64KiB The maximum size of the buffer pool.
Expand Down
Expand Up @@ -116,6 +116,14 @@
* </td>
* </tr>
* <tr>
* <td>{@code blockingTimeout}</td>
* <td>(none)</td>
* <td>The timeout applied to blocking operations. This timeout is in addition to the {@code idleTimeout},
* and applies to the total operation (as opposed to the idle timeout that applies to the time no data
* is being sent).
* </td>
* </tr>
* <tr>
* <td>{@code minBufferPoolSize}</td>
* <td>64 bytes</td>
* <td>The minimum size of the buffer pool.</td>
Expand Down Expand Up @@ -220,6 +228,8 @@ public static ConnectorFactory admin() {
@MinDuration(value = 1, unit = TimeUnit.MILLISECONDS)
private Duration idleTimeout = Duration.seconds(30);

private Duration blockingTimeout = null;

@NotNull
@MinSize(value = 1, unit = SizeUnit.BYTES)
private Size minBufferPoolSize = Size.bytes(64);
Expand Down Expand Up @@ -337,6 +347,16 @@ public void setIdleTimeout(Duration idleTimeout) {
this.idleTimeout = idleTimeout;
}

@JsonProperty
public Duration getBlockingTimeout() {
return blockingTimeout;
}

@JsonProperty
public void setBlockingTimeout(Duration blockingTimeout) {
this.blockingTimeout = blockingTimeout;
}

@JsonProperty
public Size getMinBufferPoolSize() {
return minBufferPoolSize;
Expand Down Expand Up @@ -527,6 +547,9 @@ protected HttpConfiguration buildHttpConfiguration() {
if (useForwardedHeaders) {
httpConfig.addCustomizer(new ForwardedRequestCustomizer());
}
if (blockingTimeout != null) {
httpConfig.setBlockingTimeout(blockingTimeout.toMilliseconds());
}
return httpConfig;
}

Expand Down
Expand Up @@ -74,6 +74,7 @@ public void testParseMinimalConfiguration() throws Exception {
assertThat(http.isUseServerHeader()).isFalse();
assertThat(http.isUseDateHeader()).isTrue();
assertThat(http.isUseForwardedHeaders()).isTrue();
assertThat(http.getBlockingTimeout()).isNull();
}

@Test
Expand Down Expand Up @@ -102,6 +103,7 @@ public void testParseFullConfiguration() throws Exception {
assertThat(http.isUseServerHeader()).isTrue();
assertThat(http.isUseDateHeader()).isFalse();
assertThat(http.isUseForwardedHeaders()).isFalse();
assertThat(http.getBlockingTimeout()).isEqualTo(Duration.seconds(30));
}

@Test
Expand All @@ -112,6 +114,7 @@ public void testBuildConnector() throws Exception {
http.setSelectorThreads(2);
http.setAcceptQueueSize(1024);
http.setSoLingerTime(Duration.seconds(30));
http.setBlockingTimeout(Duration.minutes(1));

Server server = new Server();
MetricRegistry metrics = new MetricRegistry();
Expand Down Expand Up @@ -158,6 +161,7 @@ public void testBuildConnector() throws Exception {
assertThat(httpConfiguration.getSendDateHeader()).isTrue();
assertThat(httpConfiguration.getSendServerVersion()).isFalse();
assertThat(httpConfiguration.getCustomizers()).hasAtLeastOneElementOfType(ForwardedRequestCustomizer.class);
assertThat(httpConfiguration.getBlockingTimeout()).isEqualTo(60000L);

connector.stop();
server.stop();
Expand Down
Expand Up @@ -8,6 +8,7 @@ maxRequestHeaderSize: 4KiB
maxResponseHeaderSize: 4KiB
inputBufferSize: 4KiB
idleTimeout: 10 seconds
blockingTimeout: 30 seconds
minBufferPoolSize: 128B
bufferPoolIncrement: 500B
maxBufferPoolSize: 32KiB
Expand Down