Package org.glassfish.grizzly.http2
Class Http2Stream
java.lang.Object
org.glassfish.grizzly.http2.Http2Stream
- All Implemented Interfaces:
AttributeStorage,Closeable,OutputSink
The abstraction representing HTTP2 stream.
- Author:
- Grizzly team
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttp2Stream(Http2Session http2Session, HttpRequestPacket request, int priority) Construct upgrade stream, which is half HTTP, half HTTP2protectedHttp2Stream(Http2Session http2Session, HttpRequestPacket request, int streamId, int parentStreamId, boolean exclusive, int priority) Create HTTP2 stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseListener(CloseListener closeListener) Add theCloseListener, which will be notified once the stream will be closed.voidChecks if this Closeable is open and ready to be used.booleancanWrite()booleancanWrite(int length) Deprecated.close()Gracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.voidclose(CompletionHandler<Closeable> completionHandler) Deprecated.voidGracefully (if supported by the implementation) closes this stream and releases any system resources associated with it.voidcloseWithReason(IOException cause) Gracefully closes the Closeable and provides the reason description.Get associatedAttributeHolder.intgetId()intintintintstatic Http2StreamgetStreamFor(HttpHeader httpHeader) intbooleanbooleanisOpen()Is Closeable open and ready.booleanbooleanvoidnotifyCanWrite(WriteHandler writeHandler) Instructs theOutputSinkto invoke the providedWriteHandlerwhen it is possible to write more bytes (or characters).voidnotifyCanWrite(WriteHandler handler, int length) Deprecated.booleanremoveCloseListener(CloseListener closeListener) Remove theCloseListener.Closes this stream and releases any system resources associated with it.voidCloses this stream and releases any system resources associated with it.voidterminateWithReason(IOException cause) Closes the Closeable and provides the reason description.
-
Field Details
-
HTTP2_STREAM_ATTRIBUTE
-
HTTP2_PARENT_STREAM_ATTRIBUTE
-
-
Constructor Details
-
Http2Stream
protected Http2Stream(Http2Session http2Session, HttpRequestPacket request, int streamId, int parentStreamId, boolean exclusive, int priority) Create HTTP2 stream.- Parameters:
http2Session- theHttp2Sessionfor thisHttp2Stream.request- theHttpRequestPacketinitiating the stream.streamId- this stream's ID.parentStreamId- the parent stream, if any.priority- the priority of this stream.
-
Http2Stream
Construct upgrade stream, which is half HTTP, half HTTP2- Parameters:
http2Session- theHttp2Sessionfor thisHttp2Stream.request- theHttpRequestPacketinitiating the stream.priority- the priority of this stream.
-
-
Method Details
-
getStreamFor
-
getPeerWindowSize
public int getPeerWindowSize() -
getLocalWindowSize
public int getLocalWindowSize() -
getUnflushedWritesCount
public int getUnflushedWritesCount()- Returns:
- the number of writes (not bytes), that haven't reached network layer
-
getRequest
-
getResponse
-
isPushEnabled
public boolean isPushEnabled() -
getId
public int getId() -
getParentStreamId
public int getParentStreamId() -
getPriority
public int getPriority() -
isPushStream
public boolean isPushStream() -
isLocallyInitiatedStream
public boolean isLocallyInitiatedStream() -
isOpen
public boolean isOpen()Description copied from interface:CloseableIs Closeable open and ready. Returns true, if the Closeable is open and ready, or false otherwise. -
assertOpen
Description copied from interface:CloseableChecks if this Closeable is open and ready to be used. If this Closeable is closed then an IOException will be thrown- Specified by:
assertOpenin interfaceCloseable- Throws:
IOException- giving the reason why this Closeable was closed.
-
getAttributes
Description copied from interface:AttributeStorageGet associatedAttributeHolder. Implementation may return null ifAttributeHolderwasn't initialized yet.- Specified by:
getAttributesin interfaceAttributeStorage- Returns:
- associated
AttributeHolder. Implementation may return null ifAttributeHolderwasn't initialized yet.
-
canWrite
Deprecated.- Specified by:
canWritein interfaceOutputSink- Parameters:
length- specifies the number of bytes (or characters) that require writing- Returns:
trueif a write to thisOutputSinkwill succeed, otherwise returnsfalse.
-
canWrite
public boolean canWrite()- Specified by:
canWritein interfaceOutputSink- Returns:
trueif a write to thisOutputSinkwill succeed, otherwise returnsfalse.
-
notifyCanWrite
Deprecated.Description copied from interface:OutputSinkInstructs theOutputSinkto invoke the providedWriteHandlerwhen it is possible to writelengthbytes (or characters). Note that once theWriteHandlerhas been notified, it will not be considered for notification again at a later point in time.- Specified by:
notifyCanWritein interfaceOutputSink- Parameters:
handler- theWriteHandlerthat should be notified when it's possible to writelengthbytes.length- the number of bytes or characters that require writing.
-
notifyCanWrite
Description copied from interface:OutputSinkInstructs theOutputSinkto invoke the providedWriteHandlerwhen it is possible to write more bytes (or characters). Note that once theWriteHandlerhas been notified, it will not be considered for notification again at a later point in time.- Specified by:
notifyCanWritein interfaceOutputSink- Parameters:
writeHandler- theWriteHandlerthat should be notified when it's possible to write more data.
-
terminate
Description copied from interface:CloseableCloses this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. -
terminateSilently
public void terminateSilently()Description copied from interface:CloseableCloses 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.- Specified by:
terminateSilentlyin interfaceCloseable
-
terminateWithReason
Description copied from interface:CloseableCloses the Closeable and provides the reason description. This method is similar toCloseable.terminateSilently(), but additionally provides the reason why the Closeable will be closed.- Specified by:
terminateWithReasonin interfaceCloseable- Parameters:
cause- reason why terminated. This will be thrown isCloseable.isOpen()is called subsequently
-
close
Description copied from interface:CloseableGracefully (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. -
closeSilently
public void closeSilently()Description copied from interface:CloseableGracefully (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.- Specified by:
closeSilentlyin interfaceCloseable
-
close
Deprecated.please useclose()with the followingGrizzlyFuture.addCompletionHandler(org.glassfish.grizzly.CompletionHandler)callGracefully 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.- Specified by:
closein interfaceCloseable- Parameters:
completionHandler-CompletionHandlerto be called, when the stream is closed
-
closeWithReason
Description copied from interface:CloseableGracefully closes the Closeable and provides the reason description. This method is similar toCloseable.closeSilently(), but additionally provides the reason why the Closeable will be closed.- Specified by:
closeWithReasonin interfaceCloseable- Parameters:
cause- reason why closed, this will be thrown byCloseable.isOpen()if called subsequently
-
addCloseListener
Description copied from interface:CloseableAdd theCloseListener, which will be notified once the stream will be closed.- Specified by:
addCloseListenerin interfaceCloseable- Parameters:
closeListener-CloseListener.
-
removeCloseListener
Description copied from interface:CloseableRemove theCloseListener.- Specified by:
removeCloseListenerin interfaceCloseable- Parameters:
closeListener-CloseListener.- Returns:
- true if the listener was successfully removed, or false otherwise.
-
closeFuture
- Specified by:
closeFuturein interfaceCloseable- Returns:
- the
Future, that will be notified once this Closeable is closed
-
close()with the followingGrizzlyFuture.addCompletionHandler(org.glassfish.grizzly.CompletionHandler)call