io.undertow.protocols.http2

## Class Http2StreamSinkChannel

- java.lang.Object
- - io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>
  - - io.undertow.protocols.http2.AbstractHttp2StreamSinkChannel
    - - io.undertow.protocols.http2.Http2StreamSinkChannel

All Implemented Interfaces:
  Closeable, AutoCloseable, Channel, GatheringByteChannel, InterruptibleChannel, WritableByteChannel, org.xnio.channels.CloseableChannel, org.xnio.channels.Configurable, org.xnio.channels.StreamSinkChannel, org.xnio.channels.SuspendableWriteChannel

Direct Known Subclasses:
  Http2DataStreamSinkChannel, Http2SettingsStreamSinkChannel

    public abstract class Http2StreamSinkChannel
    extends AbstractHttp2StreamSinkChannel

Stream sink channel used for HTTP2 communication.

Author:
  Stuart Douglas, Flavia Rainone

### Field Summary

### Fields inherited from interface org.xnio.channels.Configurable

`EMPTY`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected PooledByteBuffer[]` `allocateAll(PooledByteBuffer[] allHeaderBuffers, PooledByteBuffer currentBuffer)`
`void` `awaitWritable()` Invokes super awaitWritable, with an extra check for flowControlWindow.
`void` `awaitWritable(long time, TimeUnit timeUnit)` Invokes super awaitWritable, with an extra check for flowControlWindow.
`protected void` `channelForciblyClosed()` Called when a channel has been forcibly closed, and data (frames) have already been written.
`protected SendFrameHeader` `createFrameHeader()`
`protected abstract SendFrameHeader` `createFrameHeaderImpl()`
`int` `getStreamId()`
`protected int` `grabFlowControlBytes(int toSend)` This method should be called before sending.
`protected void` `handleFlushComplete(boolean channelClosed)`

### Methods inherited from class io.undertow.protocols.http2.AbstractHttp2StreamSinkChannel

`isLastFrame`

### Methods inherited from class io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel

`close, flush, getAwaitWritableTimeout, getBuffer, getChannel, getCloseSetter, getIoThread, getOption, getWorker, getWriteSetter, getWriteThread, isBroken, isBufferFull, isFinalFrameQueued, isFirstDataWritten, isFlushRequiredOnEmptyBuffer, isOpen, isReadyForFlush, isWriteResumed, isWritesShutdown, markBroken, preWriteTransform, resumeWrites, resumeWritesInternal, safeToSend, send, sendInternal, setOption, shutdownWrites, supportsOption, suspendWrites, transferFrom, transferFrom, wakeupWrites, write, write, write, writeFinal, writeFinal, writeFinal`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getStreamId

    public int getStreamId()

#### createFrameHeaderImpl

    protected abstract SendFrameHeader createFrameHeaderImpl()

#### channelForciblyClosed

    protected void channelForciblyClosed()
                                  throws IOException

Description copied from class: `AbstractFramedStreamSinkChannel`
Called when a channel has been forcibly closed, and data (frames) have already been written. The action this should take is protocol dependent, e.g. for SPDY a RST_STREAM should be sent, for websockets the channel should be closed. By default this will just close the underlying channel

Overrides:
  `channelForciblyClosed` in class `AbstractFramedStreamSinkChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>`
Throws:
  `IOException`

#### createFrameHeader

    protected final SendFrameHeader createFrameHeader()

Overrides:
  `createFrameHeader` in class `AbstractFramedStreamSinkChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>`

#### handleFlushComplete

    protected void handleFlushComplete(boolean channelClosed)

Overrides:
  `handleFlushComplete` in class `AbstractFramedStreamSinkChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>`

#### grabFlowControlBytes

    protected int grabFlowControlBytes(int toSend)

This method should be called before sending. It will return the amount of data that can be sent, taking into account the stream and connection flow control windows, and the toSend parameter.

It will decrement the flow control windows by the amount that can be sent, so this method should only be called as a frame is being queued.

Returns:
  The number of bytes that can be sent

#### allocateAll

    protected PooledByteBuffer[] allocateAll(PooledByteBuffer[] allHeaderBuffers,
                                             PooledByteBuffer currentBuffer)

#### awaitWritable

    public void awaitWritable()
                       throws IOException

Invokes super awaitWritable, with an extra check for flowControlWindow. The purpose of this is to warn clearly that peer is not updating the flow control window. This method will block for the maximum amount of time specified by `AbstractFramedStreamSinkChannel.getAwaitWritableTimeout()`

Specified by:
  `awaitWritable` in interface `org.xnio.channels.SuspendableWriteChannel`
Overrides:
  `awaitWritable` in class `AbstractFramedStreamSinkChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>`
Throws:
  `IOException` - if an IO error occurs

#### awaitWritable

    public void awaitWritable(long time,
                              TimeUnit timeUnit)
                       throws IOException

Invokes super awaitWritable, with an extra check for flowControlWindow. The purpose of this is to warn clearly that peer is not updating the flow control window.

Specified by:
  `awaitWritable` in interface `org.xnio.channels.SuspendableWriteChannel`
Overrides:
  `awaitWritable` in class `AbstractFramedStreamSinkChannel<Http2Channel,AbstractHttp2StreamSourceChannel,AbstractHttp2StreamSinkChannel>`
Parameters:
  `time` - the time to wait
  `timeUnit` - the time unit
Throws:
  `IOException` - if an IO error occurs