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

public Class Http2Stream

extends Object
implements AttributeStorage, OutputSink, Closeable
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.Closeable, org.glassfish.grizzly.OutputSink, org.glassfish.grizzly.attributes.AttributeStorage
Static Imports
org.glassfish.grizzly.http2.Termination.CLOSED_BY_PEER_STRING, .Termination.LOCAL_CLOSE_TERMINATION, .Termination.PEER_CLOSE_TERMINATION, .Termination.RESET_TERMINATION, .Termination.UNEXPECTED_FRAME_TERMINATION

The abstraction representing HTTP2 stream.
Author
Grizzly team

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private final AttributeHolder
private Buffer
private boolean
private volatile GrizzlyFuture<CloseReason>
private final Queue<CloseListener<T extends Closeable, C extends ICloseType>>
private volatile CloseReason
private static final AtomicReferenceFieldUpdater<Http2Stream, CloseReason>
private volatile int
private static final AtomicIntegerFieldUpdater<Http2Stream>
private final boolean
public static final String
public static final String
private final Http2Session
private static final Attribute<Http2Stream>
private int
pack-priv final StreamInputBuffer
pack-priv volatile boolean
private static final Logger
pack-priv final StreamOutputSink
private final int
private final int
private final HttpRequestPacket
pack-priv Http2Stream.State
private final int
private volatile int
pack-priv static final AtomicIntegerFieldUpdater<Http2Stream>
pack-priv static final int

Constructor Summary

AccessConstructor and Description
protected
Http2Stream(final Http2Session http2Session, final HttpRequestPacket
the HttpRequestPacket initiating the stream.
request
,
final int
this stream's ID.
streamId
,
final int
the parent stream, if any.
parentStreamId
,
final boolean exclusive, final int
the priority of this stream.
priority
)

Create HTTP2 stream.

protected
Http2Stream(final Http2Session http2Session, final HttpRequestPacket
the HttpRequestPacket initiating the stream.
request
,
final int
the priority of this stream.
priority
)

Construct upgrade stream, which is half HTTP, half HTTP2

Method Summary

Modifier and TypeMethod and Description
public void
addCloseListener(final CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Implements org.glassfish.grizzly.Closeable.addCloseListener.

Add the CloseListener, which will be notified once the stream will be closed.

private IOException
assertCanAcceptData(final boolean fin)

pack-priv IOException
assertCanAcceptHeader(final boolean fin)

public void
assertOpen()

Implements org.glassfish.grizzly.Closeable.assertOpen.

Checks if this Closeable is open and ready to be used.

pack-priv boolean

Returns:

true if the stream can receive frames, otherwise false.
canReceiveFrames
()

Checks if the specified stream is can receive frames.

pack-priv boolean

Returns:

true if the stream can send frames, otherwise false.
canSendFrames
()

Checks if the specified stream is can send frames.

public boolean
canWrite(int length)

Implements org.glassfish.grizzly.OutputSink.canWrite.

Deprecated

public boolean
public GrizzlyFuture<Closeable>
close()

Implements org.glassfish.grizzly.Closeable.close.

Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.

public void
close(final CompletionHandler<Closeable> completionHandler)

Implements org.glassfish.grizzly.Closeable.close.

Gracefully closes this stream and releases any system resources associated with it.

pack-priv void
close0(final CompletionHandler<Closeable> completionHandler, final CloseType closeType, final IOException cause, final boolean isCloseOutputGracefully)
References Deprecated CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

pack-priv void
closedRemotely()

Notifies the Http2Stream that it's been closed remotely.

private void
public GrizzlyFuture<CloseReason>
public void
closeSilently()

Implements org.glassfish.grizzly.Closeable.closeSilently.

Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.

private void
public void
closeWithReason(final IOException cause)

Implements org.glassfish.grizzly.Closeable.closeWithReason.

Gracefully closes the Closeable and provides the reason description.

pack-priv void
public AttributeHolder
pack-priv Http2Session
public int
pack-priv int
pack-priv HttpHeader
public int
pack-priv HttpHeader
pack-priv StreamOutputSink
public int
public int
public int
public HttpRequestPacket
public HttpResponsePacket
pack-priv Http2Stream.State

Returns:

the current State.
getState
()

The state of the specified stream.

public static Http2Stream
getStreamFor(final HttpHeader httpHeader)

public int
getUnflushedWritesCount()

Returns: the number of writes (not bytes), that haven't reached network layer

pack-priv boolean

Returns:

true if the stream is closed, otherwise false.
isClosed
()

Checks if the specified stream is closed.

pack-priv boolean

Returns:

true if the stream is idle, otherwise false.
isIdle
()

Checks if the specified stream is idle.

public boolean
public boolean
isOpen()

Implements org.glassfish.grizzly.Closeable.isOpen.

Is Closeable open and ready.

public boolean
public boolean
public void
notifyCanWrite(final WriteHandler handler, final int length)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Deprecated

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write length bytes (or characters).

public void
notifyCanWrite(final WriteHandler writeHandler)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write more bytes (or characters).

private void
notifyCloseListeners()

Notify all close listeners

pack-priv void
offerInputData(final Buffer data, final boolean fin)

pack-priv void
pack-priv void
pack-priv void
pack-priv void
onRcvHeaders(final boolean
flag indicating if the end-of-stream has been reached
isEOS
)

The method is called when an inbound headers are decoded for the stream, which means all the header frames arrived and we're ready to parse the headers.

private void
onReceiveEndOfStream()

Transition the stream from: - OPEN -> HALF_CLOSED_REMOTE - HALF_CLOSED_LOCAL -> CLOSED

private void
onReceiveHeaders()

Transition the stream from: - IDLE -> OPEN - RESERVED_REMOTE -> HALF_CLOSED_LOCAL

pack-priv void
onReceivePushPromise()

Transition the stream from IDLE to RESERVED_REMOTE.

private void
onReset()

Transition the stream from: - OPEN -> CLOSED - RESERVED_LOCAL -> CLOSED - RESERVED_REMOTE -> CLOSED - HALF_CLOSED_LOCAL -> CLOSED - HALF_CLOSED_REMOTE -> CLOSED

private void
onSendEndOfStream()

Transition the stream from: - OPEN -> HALF_CLOSED_LOCAL - HALF_CLOSED_REMOTE -> CLOSED

private void
onSendHeaders()

Transition the stream from: - IDLE -> OPEN - RESERVED_LOCAL -> HALF_CLOSED_REMOTE

pack-priv void
onSendPushPromise()

Transition the stream from IDLE to RESERVED_LOCAL.

pack-priv void
onSndHeaders(final boolean
flag indicating if the end-of-stream has been reached
isEOS
)

The method is called when an outbound headers are about to be sent to the peer.

pack-priv HttpContent
public boolean
pack-priv void
resetRemotely()

Notify the Http2Stream that peer sent RST_FRAME.

public GrizzlyFuture<Closeable>
terminate()

Implements org.glassfish.grizzly.Closeable.terminate.

Closes this stream and releases any system resources associated with it.

public void
terminateSilently()

Implements org.glassfish.grizzly.Closeable.terminateSilently.

Closes this stream and releases any system resources associated with it.

public void
terminateWithReason(final IOException cause)

Implements org.glassfish.grizzly.Closeable.terminateWithReason.

Closes the Closeable and provides the reason description.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final AttributeHolder attributes
cachedInputBufferback to summary
private Buffer cachedInputBuffer
cachedIsLastback to summary
private boolean cachedIsLast
closeFutureback to summary
private volatile GrizzlyFuture<CloseReason> closeFuture
closeListenersback to summary
private final Queue<CloseListener<T extends Closeable, C extends ICloseType>> closeListeners
closeReasonback to summary
private volatile CloseReason closeReason
Annotations
@SuppressWarnings:unused
closeReasonUpdaterback to summary
private static final AtomicReferenceFieldUpdater<Http2Stream, CloseReason> closeReasonUpdater
completeFinalizationCounterback to summary
private volatile int completeFinalizationCounter
Annotations
@SuppressWarnings:unused
completeFinalizationCounterUpdaterback to summary
private static final AtomicIntegerFieldUpdater<Http2Stream> completeFinalizationCounterUpdater
exclusiveback to summary
private final boolean exclusive
HTTP2_PARENT_STREAM_ATTRIBUTEback to summary
public static final String HTTP2_PARENT_STREAM_ATTRIBUTE
HTTP2_STREAM_ATTRIBUTEback to summary
public static final String HTTP2_STREAM_ATTRIBUTE
http2Sessionback to summary
private final Http2Session http2Session
HTTP_RQST_HTTP2_STREAM_ATTRback to summary
private static final Attribute<Http2Stream> HTTP_RQST_HTTP2_STREAM_ATTR
inboundHeaderFramesCounterback to summary
private int inboundHeaderFramesCounter
inputBufferback to summary
pack-priv final StreamInputBuffer inputBuffer
isProcessingCompleteback to summary
pack-priv volatile boolean isProcessingComplete
LOGGERback to summary
private static final Logger LOGGER
outputSinkback to summary
pack-priv final StreamOutputSink outputSink
parentStreamIdback to summary
private final int parentStreamId
priorityback to summary
private final int priority
requestback to summary
private final HttpRequestPacket request
stateback to summary
pack-priv Http2Stream.State state
streamIdback to summary
private final int streamId
unackedReadBytesback to summary
private volatile int unackedReadBytes
Annotations
@SuppressWarnings:unused
unackedReadBytesUpdaterback to summary
pack-priv static final AtomicIntegerFieldUpdater<Http2Stream> unackedReadBytesUpdater
UPGRADE_STREAM_IDback to summary
pack-priv static final int UPGRADE_STREAM_ID

Constructor Detail

Http2Streamback to summary
protected Http2Stream(final Http2Session http2Session, final HttpRequestPacket request, final int streamId, final int parentStreamId, final boolean exclusive, final int priority)

Create HTTP2 stream.

Parameters
http2Session:Http2Session

the Http2Session for this Http2Stream.

request:HttpRequestPacket

the HttpRequestPacket initiating the stream.

streamId:int

this stream's ID.

parentStreamId:int

the parent stream, if any.

priority:int

the priority of this stream.

Http2Streamback to summary
protected Http2Stream(final Http2Session http2Session, final HttpRequestPacket request, final int priority)

Construct upgrade stream, which is half HTTP, half HTTP2

Parameters
http2Session:Http2Session

the Http2Session for this Http2Stream.

request:HttpRequestPacket

the HttpRequestPacket initiating the stream.

priority:int

the priority of this stream.

Method Detail

addCloseListenerback to summary
public void addCloseListener(final CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Implements org.glassfish.grizzly.Closeable.addCloseListener.

Doc from org.glassfish.grizzly.Closeable.addCloseListener.

Add the CloseListener, which will be notified once the stream will be closed.

Annotations
@Override
@SuppressWarnings:unchecked
assertCanAcceptDataback to summary
private IOException assertCanAcceptData(final boolean fin)
assertCanAcceptHeaderback to summary
pack-priv IOException assertCanAcceptHeader(final boolean fin)
assertOpenback to summary
public void assertOpen() throws IOException

Implements org.glassfish.grizzly.Closeable.assertOpen.

Doc from org.glassfish.grizzly.Closeable.assertOpen.

Checks if this Closeable is open and ready to be used. If this Closeable is closed then an IOException will be thrown

Annotations
@Override
Exceptions
IOException:
giving the reason why this Closeable was closed.
canReceiveFramesback to summary
pack-priv boolean canReceiveFrames()

Checks if the specified stream is can receive frames.

Returns:boolean

true if the stream can receive frames, otherwise false.

canSendFramesback to summary
pack-priv boolean canSendFrames()

Checks if the specified stream is can send frames.

Returns:boolean

true if the stream can send frames, otherwise false.

canWriteback to summary
public boolean canWrite(int length)

Implements org.glassfish.grizzly.OutputSink.canWrite.

Deprecated

Annotations
@Override
@Deprecated
canWriteback to summary
public boolean canWrite()

Implements org.glassfish.grizzly.OutputSink.canWrite.

Annotations
@Override
closeback to summary
public GrizzlyFuture<Closeable> close()

Implements org.glassfish.grizzly.Closeable.close.

Doc from org.glassfish.grizzly.Closeable.close.

Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

Annotations
@Override
closeback to summary
public void close(final CompletionHandler<Closeable> completionHandler)

Implements org.glassfish.grizzly.Closeable.close.

Doc from org.glassfish.grizzly.Closeable.close.

Gracefully closes this stream and releases any system resources associated with it. This operation waits for all pending output data to be flushed before closing the stream. If the stream is already closed then invoking this method has no effect.

Annotations
@Deprecated
@Override
close0back to summary
pack-priv void close0(final CompletionHandler<Closeable> completionHandler, final CloseType closeType, final IOException cause, final boolean isCloseOutputGracefully)

References Deprecated

CloseType is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

closedRemotelyback to summary
pack-priv void closedRemotely()

Notifies the Http2Stream that it's been closed remotely.

closedStateSwitchback to summary
private void closedStateSwitch()
closeFutureback to summary
public GrizzlyFuture<CloseReason> closeFuture()

Implements org.glassfish.grizzly.Closeable.closeFuture.

Annotations
@SuppressWarnings:Duplicates
@Override
closeSilentlyback to summary
public void closeSilently()

Implements org.glassfish.grizzly.Closeable.closeSilently.

Doc from org.glassfish.grizzly.Closeable.closeSilently.

Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. Use this method, when no completion notification is needed.

Annotations
@Override
closeStreamback to summary
private void closeStream()
closeWithReasonback to summary
public void closeWithReason(final IOException cause)

Implements org.glassfish.grizzly.Closeable.closeWithReason.

Doc from org.glassfish.grizzly.Closeable.closeWithReason.

Gracefully closes the Closeable and provides the reason description. This method is similar to closeSilently(), but additionally provides the reason why the Closeable will be closed.

Annotations
@Override
flushInputDataback to summary
pack-priv void flushInputData() throws Http2SessionException
getAttributesback to summary
public AttributeHolder getAttributes()

Implements org.glassfish.grizzly.attributes.AttributeStorage.getAttributes.

Doc from org.glassfish.grizzly.attributes.AttributeStorage.getAttributes.

Get associated AttributeHolder. Implementation may return null if AttributeHolder wasn't initialized yet.

Annotations
@Override
getHttp2Sessionback to summary
pack-priv Http2Session getHttp2Session()
getIdback to summary
public int getId()
getInboundHeaderFramesCounterback to summary
pack-priv int getInboundHeaderFramesCounter()
getInputHttpHeaderback to summary
pack-priv HttpHeader getInputHttpHeader()
getLocalWindowSizeback to summary
public int getLocalWindowSize()
getOutputHttpHeaderback to summary
pack-priv HttpHeader getOutputHttpHeader()
getOutputSinkback to summary
pack-priv StreamOutputSink getOutputSink()
getParentStreamIdback to summary
public int getParentStreamId()
Annotations
@SuppressWarnings:unused
getPeerWindowSizeback to summary
public int getPeerWindowSize()
getPriorityback to summary
public int getPriority()
Annotations
@SuppressWarnings:unused
getRequestback to summary
public HttpRequestPacket getRequest()
getResponseback to summary
public HttpResponsePacket getResponse()
getStateback to summary
pack-priv Http2Stream.State getState()

The state of the specified stream.

Returns:Http2Stream.State

the current State.

getStreamForback to summary
public static Http2Stream getStreamFor(final HttpHeader httpHeader)
getUnflushedWritesCountback to summary
public int getUnflushedWritesCount()
Returns:int

the number of writes (not bytes), that haven't reached network layer

isClosedback to summary
pack-priv boolean isClosed()

Checks if the specified stream is closed.

Returns:boolean

true if the stream is closed, otherwise false.

isIdleback to summary
pack-priv boolean isIdle()

Checks if the specified stream is idle.

Returns:boolean

true if the stream is idle, otherwise false.

isLocallyInitiatedStreamback to summary
public boolean isLocallyInitiatedStream()
isOpenback to summary
public boolean isOpen()

Implements org.glassfish.grizzly.Closeable.isOpen.

Doc from org.glassfish.grizzly.Closeable.isOpen.

Is Closeable open and ready. Returns true, if the Closeable is open and ready, or false otherwise.

Annotations
@Override
isPushEnabledback to summary
public boolean isPushEnabled()
Annotations
@SuppressWarnings:unused
isPushStreamback to summary
public boolean isPushStream()
notifyCanWriteback to summary
public void notifyCanWrite(final WriteHandler handler, final int length)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Doc from org.glassfish.grizzly.OutputSink.notifyCanWrite.

Deprecated

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write length bytes (or characters). Note that once the WriteHandler has been notified, it will not be considered for notification again at a later point in time.

Annotations
@Override
@Deprecated
notifyCanWriteback to summary
public void notifyCanWrite(final WriteHandler writeHandler)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Doc from org.glassfish.grizzly.OutputSink.notifyCanWrite.

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write more bytes (or characters). Note that once the WriteHandler has been notified, it will not be considered for notification again at a later point in time.

Annotations
@Override
notifyCloseListenersback to summary
private void notifyCloseListeners()

Notify all close listeners

Annotations
@SuppressWarnings:unchecked
offerInputDataback to summary
pack-priv void offerInputData(final Buffer data, final boolean fin) throws IOException
onInputClosedback to summary
pack-priv void onInputClosed()
onOutputClosedback to summary
pack-priv void onOutputClosed()
onProcessingCompleteback to summary
pack-priv void onProcessingComplete()
onRcvHeadersback to summary
pack-priv void onRcvHeaders(final boolean isEOS) throws Http2StreamException

The method is called when an inbound headers are decoded for the stream, which means all the header frames arrived and we're ready to parse the headers.

Parameters
isEOS:boolean

flag indicating if the end-of-stream has been reached

Exceptions
Http2StreamException:
if an error occurs processing the headers frame
onReceiveEndOfStreamback to summary
private void onReceiveEndOfStream()

Transition the stream from: - OPEN -> HALF_CLOSED_REMOTE - HALF_CLOSED_LOCAL -> CLOSED

onReceiveHeadersback to summary
private void onReceiveHeaders()

Transition the stream from: - IDLE -> OPEN - RESERVED_REMOTE -> HALF_CLOSED_LOCAL

onReceivePushPromiseback to summary
pack-priv void onReceivePushPromise()

Transition the stream from IDLE to RESERVED_REMOTE.

onResetback to summary
private void onReset()

Transition the stream from: - OPEN -> CLOSED - RESERVED_LOCAL -> CLOSED - RESERVED_REMOTE -> CLOSED - HALF_CLOSED_LOCAL -> CLOSED - HALF_CLOSED_REMOTE -> CLOSED

onSendEndOfStreamback to summary
private void onSendEndOfStream()

Transition the stream from: - OPEN -> HALF_CLOSED_LOCAL - HALF_CLOSED_REMOTE -> CLOSED

onSendHeadersback to summary
private void onSendHeaders()

Transition the stream from: - IDLE -> OPEN - RESERVED_LOCAL -> HALF_CLOSED_REMOTE

onSendPushPromiseback to summary
pack-priv void onSendPushPromise()

Transition the stream from IDLE to RESERVED_LOCAL.

onSndHeadersback to summary
pack-priv void onSndHeaders(final boolean isEOS)

The method is called when an outbound headers are about to be sent to the peer.

Parameters
isEOS:boolean

flag indicating if the end-of-stream has been reached

pollInputDataback to summary
pack-priv HttpContent pollInputData() throws IOException
removeCloseListenerback to summary
public boolean removeCloseListener(final CloseListener<T extends Closeable, C extends ICloseType> closeListener)

Implements org.glassfish.grizzly.Closeable.removeCloseListener.

Doc from org.glassfish.grizzly.Closeable.removeCloseListener.

Remove the CloseListener.

Annotations
@Override
resetRemotelyback to summary
pack-priv void resetRemotely()

Notify the Http2Stream that peer sent RST_FRAME.

terminateback to summary
public GrizzlyFuture<Closeable> terminate()

Implements org.glassfish.grizzly.Closeable.terminate.

Doc from org.glassfish.grizzly.Closeable.terminate.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

Annotations
@Override
terminateSilentlyback to summary
public void terminateSilently()

Implements org.glassfish.grizzly.Closeable.terminateSilently.

Doc from org.glassfish.grizzly.Closeable.terminateSilently.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. Use this method, when no completion notification is needed.

Annotations
@Override
terminateWithReasonback to summary
public void terminateWithReason(final IOException cause)

Implements org.glassfish.grizzly.Closeable.terminateWithReason.

Doc from org.glassfish.grizzly.Closeable.terminateWithReason.

Closes the Closeable and provides the reason description. This method is similar to terminateSilently(), but additionally provides the reason why the Closeable will be closed.

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

public final Enum Http2Stream.State

extends Enum<Http2Stream.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Http2Stream.State
public static final Http2Stream.State
public static final Http2Stream.State
public static final Http2Stream.State
public static final Http2Stream.State
public static final Http2Stream.State
public static final Http2Stream.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Http2Stream.State
public static Http2Stream.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLOSEDback to summary
public static final Http2Stream.State CLOSED
HALF_CLOSED_LOCALback to summary
public static final Http2Stream.State HALF_CLOSED_LOCAL
HALF_CLOSED_REMOTEback to summary
public static final Http2Stream.State HALF_CLOSED_REMOTE
IDLEback to summary
public static final Http2Stream.State IDLE
OPENback to summary
public static final Http2Stream.State OPEN
RESERVED_LOCALback to summary
public static final Http2Stream.State RESERVED_LOCAL
RESERVED_REMOTEback to summary
public static final Http2Stream.State RESERVED_REMOTE

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static Http2Stream.State valueOf(String name)
valuesback to summary
public static Http2Stream.State[] values()