private final class DefaultHttp2ConnectionEncoder.FlowControlledData extends DefaultHttp2ConnectionEncoder.FlowControlledBase
size()
calculation deterministic thereby greatly simplifying the implementation.
If frame-splitting is required to fit within max-frame-size and flow-control constraints we ensure that the passed promise is not completed until last frame write.
Modifier and Type | Field and Description |
---|---|
private int |
dataSize |
private CoalescingBufferQueue |
queue |
endOfStream, padding, promise, stream
CLOSE, CLOSE_ON_FAILURE, FIRE_EXCEPTION_ON_FAILURE
Constructor and Description |
---|
FlowControlledData(Http2Stream stream,
ByteBuf buf,
int padding,
boolean endOfStream,
ChannelPromise promise) |
Modifier and Type | Method and Description |
---|---|
void |
error(ChannelHandlerContext ctx,
java.lang.Throwable cause)
Called to indicate that an error occurred before this object could be completely written.
|
boolean |
merge(ChannelHandlerContext ctx,
Http2RemoteFlowController.FlowControlled next)
Merge the contents of the
next message into this message so they can be written out as one unit. |
int |
size()
The size of the payload in terms of bytes applied to the flow-control window.
|
void |
write(ChannelHandlerContext ctx,
int allowedBytes)
Writes up to
allowedBytes of the encapsulated payload to the stream. |
operationComplete, writeComplete
private final CoalescingBufferQueue queue
private int dataSize
FlowControlledData(Http2Stream stream, ByteBuf buf, int padding, boolean endOfStream, ChannelPromise promise)
public int size()
Http2RemoteFlowController.FlowControlled
HEADER
frames have no cost against flow control and would
return 0 for this value even though they produce a non-zero number of bytes on
the wire. Other frames like DATA
frames have both their payload and padding count
against flow-control.public void error(ChannelHandlerContext ctx, java.lang.Throwable cause)
Http2RemoteFlowController.FlowControlled
The Http2RemoteFlowController
will make exactly one call to either
this method or Http2RemoteFlowController.FlowControlled.writeComplete()
.
ctx
- The context to use if any communication needs to occur as a result of the error.
This may be null
if an exception occurs when the connection has not been established yet.cause
- of the error.public void write(ChannelHandlerContext ctx, int allowedBytes)
Http2RemoteFlowController.FlowControlled
allowedBytes
of the encapsulated payload to the stream. Note that
a value of 0 may be passed which will allow payloads with flow-control size == 0 to be
written. The flow-controller may call this method multiple times with different values until
the payload is fully written, i.e it's size after the write is 0.
When an exception is thrown the Http2RemoteFlowController
will make a call to
Http2RemoteFlowController.FlowControlled.error(ChannelHandlerContext, Throwable)
.
ctx
- The context to use for writing.allowedBytes
- an upper bound on the number of bytes the payload can write at this time.public boolean merge(ChannelHandlerContext ctx, Http2RemoteFlowController.FlowControlled next)
Http2RemoteFlowController.FlowControlled
next
message into this message so they can be written out as one unit.
This allows many small messages to be written as a single DATA frame.true
if next
was successfully merged and does not need to be enqueued,
false
otherwise.