@Contract(threading=IMMUTABLE) public final class MonitoringResponseOutOfOrderStrategy extends Object implements ResponseOutOfOrderStrategy
ResponseOutOfOrderStrategy
implementation which checks for premature responses every chunkSize
bytes. An 8 KiB chunk size is used by default based on testing using values between 4 KiB and 128 KiB. This is
optimized for correctness and results in a maximum upload speed of 8 MiB/s until maxChunksToCheck
is
reached.Modifier and Type | Field and Description |
---|---|
static MonitoringResponseOutOfOrderStrategy |
INSTANCE |
Constructor and Description |
---|
MonitoringResponseOutOfOrderStrategy()
Instantiates a default
MonitoringResponseOutOfOrderStrategy . |
MonitoringResponseOutOfOrderStrategy(long chunkSize)
Instantiates a
MonitoringResponseOutOfOrderStrategy with unlimited maxChunksToCheck . |
MonitoringResponseOutOfOrderStrategy(long chunkSize,
long maxChunksToCheck)
Instantiates a
MonitoringResponseOutOfOrderStrategy . |
Modifier and Type | Method and Description |
---|---|
boolean |
isEarlyResponseDetected(ClassicHttpRequest request,
HttpClientConnection connection,
InputStream inputStream,
long totalBytesSent,
long nextWriteSize)
Called before each write to the to a socket
OutputStream with the number of
bytes that have already been sent, and the size of the write that will occur if this check
does not encounter an out of order response. |
String |
toString() |
public static final MonitoringResponseOutOfOrderStrategy INSTANCE
public MonitoringResponseOutOfOrderStrategy()
MonitoringResponseOutOfOrderStrategy
. INSTANCE
may be used instead.public MonitoringResponseOutOfOrderStrategy(long chunkSize)
MonitoringResponseOutOfOrderStrategy
with unlimited maxChunksToCheck
.chunkSize
- The chunk size after which a response check is executed.public MonitoringResponseOutOfOrderStrategy(long chunkSize, long maxChunksToCheck)
MonitoringResponseOutOfOrderStrategy
.chunkSize
- The chunk size after which a response check is executed.maxChunksToCheck
- The maximum number of chunks to check, allowing expensive checks to be avoided
after a sufficient portion of the request entity has been transferred.public boolean isEarlyResponseDetected(ClassicHttpRequest request, HttpClientConnection connection, InputStream inputStream, long totalBytesSent, long nextWriteSize) throws IOException
ResponseOutOfOrderStrategy
OutputStream
with the number of
bytes that have already been sent, and the size of the write that will occur if this check
does not encounter an out of order response.isEarlyResponseDetected
in interface ResponseOutOfOrderStrategy
request
- The current request.connection
- The connection used to send the current request.inputStream
- The response stream, this may be used to check for an early response.totalBytesSent
- Number of bytes that have already been sent.nextWriteSize
- The size of a socket write operation that will follow this check.IOException
- in case of a network failure while checking for an early response.Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.