BlockingReadTimeoutHandler allows configurable blocking I/O timeouts
for read operations within an exchange.
Unlike Options.READ_TIMEOUT this only applies to blocking operations which can be helpful to prevent the worker pool from becoming saturated when clients stop responding.
When a timeout occurs, a ReadTimeoutException is thrown, and the
ServerConnection is closed.
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final HttpHandler | |
| private final ConduitWrapper |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static BlockingReadTimeoutHandler. | |
| public void | handleRequest(HttpServerExchange
the HTTP request/response exchange exchange)Implements io. Handle the request. |
| next | back to summary |
|---|---|
| private final HttpHandler next | |
| streamSourceConduitWrapper | back to summary |
|---|---|
| private final ConduitWrapper<StreamSourceConduit> streamSourceConduitWrapper | |
| BlockingReadTimeoutHandler | back to summary |
|---|---|
| private BlockingReadTimeoutHandler(HttpHandler next, Duration readTimeout) | |
| builder | back to summary |
|---|---|
| public static BlockingReadTimeoutHandler. | |
| handleRequest | back to summary |
|---|---|
| public void handleRequest(HttpServerExchange exchange) throws Exception Implements io. Doc from io. Handle the request.
| |
| Modifier and Type | Field and Description |
|---|---|
| private HttpHandler | |
| private Duration |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public HttpHandler | |
| public BlockingReadTimeoutHandler. | |
| public BlockingReadTimeoutHandler. |
| nextHandler | back to summary |
|---|---|
| private HttpHandler nextHandler | |
| readTimeout | back to summary |
|---|---|
| private Duration readTimeout | |
| Builder | back to summary |
|---|---|
| private Builder() | |
| build | back to summary |
|---|---|
| public HttpHandler build() | |
| nextHandler | back to summary |
|---|---|
| public BlockingReadTimeoutHandler. | |
| readTimeout | back to summary |
|---|---|
| public BlockingReadTimeoutHandler. | |
| Modifier and Type | Field and Description |
|---|---|
| private final StreamSourceConduit | |
| private long | |
| private final ServerConnection | |
| private final long |
| Access | Constructor and Description |
|---|---|
| pack-priv | TimeoutStreamSourceConduit(StreamSourceConduit delegate, ServerConnection serverConnection, long timeoutNanos)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | awaitReadable()
Implements org. Block until this channel becomes readable again. |
| public void | awaitReadable(long
the time to wait duration, TimeUnit the time unit unit)Implements org. Block until this conduit becomes readable again, or until the timeout expires. |
| public XnioIoThread | |
| public XnioWorker | getWorker()
Implements org. Get the XNIO worker associated with this conduit. |
| public boolean | isReadResumed()
Implements org. Determine whether read notifications are currently enabled. |
| public boolean | isReadShutdown()
Implements org. Determine whether reads have been shut down on this conduit. |
| public int | read(ByteBuffer
the buffer to fill with data from the conduit byteBuffer)Implements org. Read a sequence of bytes from this conduit to the given buffer. |
| public long | read(ByteBuffer[]
the buffers to fill with data from the conduit byteBuffers, int the offset into the buffer array offset, int the number of buffers to fill length)Implements org. Read a sequence of bytes from this conduit to the given buffers. |
| private long | |
| private int | |
| public void | resumeReads()
Implements org. Indicate that the conduit's |
| public void | setReadReadyHandler(ReadReadyHandler
the filter to receive readiness notifications readReadyHandler)Implements org. Set the handler which should receive readiness notifications. |
| public void | suspendReads()
Implements org. Indicate that calling the conduit's |
| public void | terminateReads()
Implements org. Indicate that no more data will be read from this conduit. |
| public long | transferTo(long
the position within the file from which the transfer is to begin position, long the number of bytes to be transferred count, FileChannel the file to write to fileChannel)Implements org. Transfers bytes into the given file from this channel. |
| public long | transferTo(long
the number of bytes to be transferred count, ByteBuffer the buffer to copy through. byteBuffer, StreamSinkChannel the destination to write to streamSinkChannel)Implements org. Transfers bytes into the given channel target. |
| public void | wakeupReads()
Implements org. Indicate that the conduit's |
| delegate | back to summary |
|---|---|
| private final StreamSourceConduit delegate | |
| remaining | back to summary |
|---|---|
| private long remaining | |
| serverConnection | back to summary |
|---|---|
| private final ServerConnection serverConnection | |
| timeoutNanos | back to summary |
|---|---|
| private final long timeoutNanos | |
| TimeoutStreamSourceConduit | back to summary |
|---|---|
| pack-priv TimeoutStreamSourceConduit(StreamSourceConduit delegate, ServerConnection serverConnection, long timeoutNanos) | |
| awaitReadable | back to summary |
|---|---|
| public void awaitReadable() throws IOException Implements org. Doc from org. Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.
| |
| awaitReadable | back to summary |
|---|---|
| public void awaitReadable(long duration, TimeUnit unit) throws IOException Implements org. Doc from org. Block until this conduit becomes readable again, or until the timeout expires. This method may return spuriously before the conduit becomes readable or the timeout expires.
| |
| getReadThread | back to summary |
|---|---|
| public XnioIoThread getReadThread() Implements org. Doc from org. Get the XNIO read thread.
| |
| getWorker | back to summary |
|---|---|
| public XnioWorker getWorker() Implements org. Doc from org. Get the XNIO worker associated with this conduit.
| |
| isReadResumed | back to summary |
|---|---|
| public boolean isReadResumed() Implements org. Doc from org. Determine whether read notifications are currently enabled.
| |
| isReadShutdown | back to summary |
|---|---|
| public boolean isReadShutdown() Implements org. Doc from org. Determine whether reads have been shut down on this conduit.
| |
| read | back to summary |
|---|---|
| public int read(ByteBuffer byteBuffer) throws IOException Implements org. Doc from org. Read a sequence of bytes from this conduit to the given buffer.
| |
| read | back to summary |
|---|---|
| public long read(ByteBuffer[] byteBuffers, int offset, int length) throws IOException Implements org. Doc from org. Read a sequence of bytes from this conduit to the given buffers.
| |
| resetTimeoutIfReadSucceeded | back to summary |
|---|---|
| private long resetTimeoutIfReadSucceeded(long value) | |
| resetTimeoutIfReadSucceeded | back to summary |
|---|---|
| private int resetTimeoutIfReadSucceeded(int value) | |
| resumeReads | back to summary |
|---|---|
| public void resumeReads() Implements org. Doc from org. Indicate that the conduit's
| |
| setReadReadyHandler | back to summary |
|---|---|
| public void setReadReadyHandler(ReadReadyHandler readReadyHandler) Implements org. Doc from org. Set the handler which should receive readiness notifications. A filter may pass this invocation on to the filter it wraps, or it may substitute itself.
| |
| suspendReads | back to summary |
|---|---|
| public void suspendReads() Implements org. Doc from org. Indicate that calling the conduit's
| |
| terminateReads | back to summary |
|---|---|
| public void terminateReads() throws IOException Implements org. Doc from org. Indicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.
| |
| transferTo | back to summary |
|---|---|
| public long transferTo(long position, long count, FileChannel fileChannel) throws IOException Implements org. Doc from org. Transfers bytes into the given file from this channel.
| |
| transferTo | back to summary |
|---|---|
| public long transferTo(long count, ByteBuffer byteBuffer, StreamSinkChannel streamSinkChannel) throws IOException Implements org. Doc from org. Transfers bytes into the given channel target. On entry,
| |
| wakeupReads | back to summary |
|---|---|
| public void wakeupReads() Implements org. Doc from org. Indicate that the conduit's
| |
| Modifier and Type | Field and Description |
|---|---|
| private final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public StreamSourceConduit | wrap(ConduitFactory<StreamSourceConduit>
the original conduit factory, HttpServerExchange the in-flight HTTP exchange exchange)Implements io. Wrap the conduit. |
| timeoutNanoseconds | back to summary |
|---|---|
| private final long timeoutNanoseconds | |
| TimeoutStreamSourceConduitWrapper | back to summary |
|---|---|
| pack-priv TimeoutStreamSourceConduitWrapper(Duration readTimeout) | |
| wrap | back to summary |
|---|---|
| public StreamSourceConduit wrap(ConduitFactory<StreamSourceConduit> factory, HttpServerExchange exchange) Implements io. Doc from io. Wrap the conduit. The wrapper should not return
| |