Top Inners Fields Constructors Methods
org.glassfish.grizzly.http2

pack-priv Class DefaultInputBuffer

extends Object
implements StreamInputBuffer
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.http2.StreamInputBuffer
Static Imports
org.glassfish.grizzly.http2.Termination.IN_FIN_TERMINATION

Author
oleksiys

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DefaultInputBuffer.InputElement

Class represent input queue element

Field Summary

Modifier and TypeField and Description
private volatile Termination
private static final AtomicReferenceFieldUpdater<DefaultInputBuffer, Termination>
private boolean
private final Object
private final Http2Session
private final AtomicBoolean
private final BlockingQueue<DefaultInputBuffer.InputElement>
private volatile int
private static final AtomicIntegerFieldUpdater<DefaultInputBuffer>
private static final Logger
private static final long
private long
private final Http2Stream
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static int
bufSz(final Buffer buffer)

private HttpContent
private HttpContent
buildHttpContent(final Buffer payload)

Builds HttpContent based on passed payload Buffer.

private boolean

Returns:

true if we don't expect more content, or false if we do expect more content or we're not sure because content-length header was not specified by peer.
checkContentLength
(final int
the number of bytes we've just got.
newDataChunkSize
)

Based on content-length header (which we may have or may not), double check if the payload we've just got is last.

private void
checkEOF(final DefaultInputBuffer.InputElement
the InputElement to check EOF status against.
inputElement
)

Checks if the passed InputElement is input buffer EOF element.

public void
close(final Termination termination)

Implements org.glassfish.grizzly.http2.StreamInputBuffer.close.

Graceful input buffer close.

public boolean
isClosed()

Implements org.glassfish.grizzly.http2.StreamInputBuffer.isClosed.

Returns true if the InputBuffer has been closed.

public boolean
offer(final Buffer data, final boolean isLast)

Implements org.glassfish.grizzly.http2.StreamInputBuffer.offer.

The method is called, when new input data arrives.

private void
offer0(final DefaultInputBuffer.InputElement inputElement)

The private method, which adds new InputElement to the input queue

public void
onReadEventComplete()

Implements org.glassfish.grizzly.http2.StreamInputBuffer.onReadEventComplete.

The method will be invoked once upstream completes READ operation processing.

private void
passPayloadUpstream(final DefaultInputBuffer.InputElement
InputElement element to be appended to the current input queue content and sent upstream
inputElement
,
int
the current input queue size (-1 if we don't have this information at the moment).
readyBuffersCount
)

Sends the available input data upstream.

public HttpContent
poll()

Implements org.glassfish.grizzly.http2.StreamInputBuffer.poll.

Retrieves available input buffer payload, waiting up to the Connection#getReadTimeout(java.util.concurrent.TimeUnit) wait time if necessary for payload to become available.

private Buffer
poll0()

Retrieves available input buffer payload, waiting up to the Connection#getReadTimeout(java.util.concurrent.TimeUnit) wait time if necessary for payload to become available.

private boolean
private int
private void
public void
terminate(final Termination termination)

Implements org.glassfish.grizzly.http2.StreamInputBuffer.terminate.

Forcibly closes the input buffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closeFlagback to summary
private volatile Termination closeFlag
Annotations
@SuppressWarnings:unused
closeFlagUpdaterback to summary
private static final AtomicReferenceFieldUpdater<DefaultInputBuffer, Termination> closeFlagUpdater
expectInputSwitchback to summary
private boolean expectInputSwitch
expectInputSwitchSyncback to summary
private final Object expectInputSwitchSync
http2Sessionback to summary
private final Http2Session http2Session
inputClosedback to summary
private final AtomicBoolean inputClosed
inputQueueback to summary
private final BlockingQueue<DefaultInputBuffer.InputElement> inputQueue
inputQueueSizeback to summary
private volatile int inputQueueSize
inputQueueSizeUpdaterback to summary
private static final AtomicIntegerFieldUpdater<DefaultInputBuffer> inputQueueSizeUpdater
LOGGERback to summary
private static final Logger LOGGER
NULL_CONTENT_LENGTHback to summary
private static final long NULL_CONTENT_LENGTH
remainingContentLengthback to summary
private long remainingContentLength
streamback to summary
private final Http2Stream stream
terminateSyncback to summary
private final Object terminateSync

Constructor Detail

DefaultInputBufferback to summary
pack-priv DefaultInputBuffer(final Http2Stream stream)

Method Detail

bufSzback to summary
private static int bufSz(final Buffer buffer)
buildBrokenHttpContentback to summary
private HttpContent buildBrokenHttpContent(final Throwable t)
buildHttpContentback to summary
private HttpContent buildHttpContent(final Buffer payload)

Builds HttpContent based on passed payload Buffer. If the payload size is 0 and the input buffer has been terminated - return HttpBrokenContent.

checkContentLengthback to summary
private boolean checkContentLength(final int newDataChunkSize)

Based on content-length header (which we may have or may not), double check if the payload we've just got is last.

Parameters
newDataChunkSize:int

the number of bytes we've just got.

Returns:boolean

true if we don't expect more content, or false if we do expect more content or we're not sure because content-length header was not specified by peer.

checkEOFback to summary
private void checkEOF(final DefaultInputBuffer.InputElement inputElement)

Checks if the passed InputElement is input buffer EOF element.

Parameters
inputElement:DefaultInputBuffer.InputElement

the InputElement to check EOF status against.

closeback to summary
public void close(final Termination termination)

Implements org.glassfish.grizzly.http2.StreamInputBuffer.close.

Graceful input buffer close. Marks the input buffer as closed by adding Termination input element to the input queue.

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Implements org.glassfish.grizzly.http2.StreamInputBuffer.isClosed.

Returns true if the InputBuffer has been closed.

Annotations
@Override
offerback to summary
public boolean offer(final Buffer data, final boolean isLast)

Implements org.glassfish.grizzly.http2.StreamInputBuffer.offer.

The method is called, when new input data arrives.

Annotations
@Override
offer0back to summary
private void offer0(final DefaultInputBuffer.InputElement inputElement)

The private method, which adds new InputElement to the input queue

onReadEventCompleteback to summary
public void onReadEventComplete()

Implements org.glassfish.grizzly.http2.StreamInputBuffer.onReadEventComplete.

The method will be invoked once upstream completes READ operation processing. Here we have to simulate NIO OP_READ event re-registration.

Annotations
@Override
passPayloadUpstreamback to summary
private void passPayloadUpstream(final DefaultInputBuffer.InputElement inputElement, int readyBuffersCount)

Sends the available input data upstream.

Parameters
inputElement:DefaultInputBuffer.InputElement

InputElement element to be appended to the current input queue content and sent upstream

readyBuffersCount:int

the current input queue size (-1 if we don't have this information at the moment).

pollback to summary
public HttpContent poll() throws IOException

Implements org.glassfish.grizzly.http2.StreamInputBuffer.poll.

Retrieves available input buffer payload, waiting up to the Connection#getReadTimeout(java.util.concurrent.TimeUnit) wait time if necessary for payload to become available.

Annotations
@Override
Exceptions
IOException:
if an error occurs with the poll operation.
poll0back to summary
private Buffer poll0() throws IOException

Retrieves available input buffer payload, waiting up to the Connection#getReadTimeout(java.util.concurrent.TimeUnit) wait time if necessary for payload to become available.

Exceptions
IOException:
if an error occurs with the poll operation.
switchOffExpectInputback to summary
private boolean switchOffExpectInput()
switchOffExpectInputIfQueueNotEmptyback to summary
private int switchOffExpectInputIfQueueNotEmpty()
switchOnExpectInputback to summary
private void switchOnExpectInput()
terminateback to summary
public void terminate(final Termination termination)

Implements org.glassfish.grizzly.http2.StreamInputBuffer.terminate.

Forcibly closes the input buffer. All the buffered data will be discarded.

Annotations
@Override
org.glassfish.grizzly.http2 back to summary

private final Class DefaultInputBuffer.InputElement

extends Object
Class Inheritance

Class represent input queue element

Field Summary

Modifier and TypeField and Description
private final Object
private final boolean
private final boolean

Constructor Summary

AccessConstructor and Description
public
InputElement(final Object content, final boolean isLast, final boolean isService)

Method Summary

Modifier and TypeMethod and Description
private Buffer
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final Object content
isLastback to summary
private final boolean isLast
isServiceback to summary
private final boolean isService

Constructor Detail

InputElementback to summary
public InputElement(final Object content, final boolean isLast, final boolean isService)

Method Detail

toBufferback to summary
private Buffer toBuffer()