Top Description Fields Constructors Methods
org.apache.hc.core5.http.impl.io

public final Class MonitoringResponseOutOfOrderStrategy

extends Object
implements ResponseOutOfOrderStrategy
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy
Annotations
@Contract
threading:IMMUTABLE
Imports
org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.ClassicHttpRequest, org.apache.hc.core5.http.io.HttpClientConnection, .ResponseOutOfOrderStrategy, org.apache.hc.core5.util.Args, .Timeout, java.io.IOException, .InputStream

A 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.
Since
5.1

Field Summary

Modifier and TypeField and Description
private final long
private static final int
public static final MonitoringResponseOutOfOrderStrategy
private final long

Constructor Summary

AccessConstructor and Description
public
public
MonitoringResponseOutOfOrderStrategy(final long
The chunk size after which a response check is executed.
chunkSize
)

Instantiates a MonitoringResponseOutOfOrderStrategy with unlimited maxChunksToCheck.

public
MonitoringResponseOutOfOrderStrategy(final long
The chunk size after which a response check is executed.
chunkSize
,
final long
The maximum number of chunks to check, allowing expensive checks to be avoided after a sufficient portion of the request entity has been transferred.
maxChunksToCheck
)

Instantiates a MonitoringResponseOutOfOrderStrategy.

Method Summary

Modifier and TypeMethod and Description
public boolean
isEarlyResponseDetected(final ClassicHttpRequest
The current request.
request
,
final HttpClientConnection
The connection used to send the current request.
connection
,
final InputStream
The response stream, this may be used to check for an early response.
inputStream
,
final long
Number of bytes that have already been sent.
totalBytesSent
,
final long
The size of a socket write operation that will follow this check.
nextWriteSize
)

Implements org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy.isEarlyResponseDetected.

Called before each write to the to a socket java.io.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.
private boolean
nextWriteStartsNewChunk(final long totalBytesSent, final long nextWriteSize)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

chunkSizeback to summary
private final long chunkSize
DEFAULT_CHUNK_SIZEback to summary
private static final int DEFAULT_CHUNK_SIZE
INSTANCEback to summary
public static final MonitoringResponseOutOfOrderStrategy INSTANCE
maxChunksToCheckback to summary
private final long maxChunksToCheck

Constructor Detail

MonitoringResponseOutOfOrderStrategyback to summary
public MonitoringResponseOutOfOrderStrategy()

Instantiates a default MonitoringResponseOutOfOrderStrategy. INSTANCE may be used instead.

MonitoringResponseOutOfOrderStrategyback to summary
public MonitoringResponseOutOfOrderStrategy(final long chunkSize)

Instantiates a MonitoringResponseOutOfOrderStrategy with unlimited maxChunksToCheck.

Parameters
chunkSize:long

The chunk size after which a response check is executed.

MonitoringResponseOutOfOrderStrategyback to summary
public MonitoringResponseOutOfOrderStrategy(final long chunkSize, final long maxChunksToCheck)

Instantiates a MonitoringResponseOutOfOrderStrategy.

Parameters
chunkSize:long

The chunk size after which a response check is executed.

maxChunksToCheck:long

The maximum number of chunks to check, allowing expensive checks to be avoided after a sufficient portion of the request entity has been transferred.

Method Detail

isEarlyResponseDetectedback to summary
public boolean isEarlyResponseDetected(final ClassicHttpRequest request, final HttpClientConnection connection, final InputStream inputStream, final long totalBytesSent, final long nextWriteSize) throws IOException

Implements org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy.isEarlyResponseDetected.

Doc from org.apache.hc.core5.http.io.ResponseOutOfOrderStrategy.isEarlyResponseDetected.

Called before each write to the to a socket java.io.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.

Parameters
request:ClassicHttpRequest

The current request.

connection:HttpClientConnection

The connection used to send the current request.

inputStream:InputStream

The response stream, this may be used to check for an early response.

totalBytesSent:long

Number of bytes that have already been sent.

nextWriteSize:long

The size of a socket write operation that will follow this check.

Returns:boolean

True if an early response was detected, otherwise false.

Annotations
@Override
Exceptions
IOException:
in case of a network failure while checking for an early response.
nextWriteStartsNewChunkback to summary
private boolean nextWriteStartsNewChunk(final long totalBytesSent, final long nextWriteSize)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override