public class AbstractFramedStreamSinkConduit extends AbstractStreamSinkConduit<StreamSinkConduit>
When a write takes place all frames are attempted to be written out at once via a gathering write. Frames can be
queued via queueFrame(io.undertow.conduits.AbstractFramedStreamSinkConduit.FrameCallBack, java.nio.ByteBuffer...)
.
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractFramedStreamSinkConduit.FrameCallBack
Interface that is called when a frame event takes place.
|
protected static class |
AbstractFramedStreamSinkConduit.PooledBufferFrameCallback |
protected static class |
AbstractFramedStreamSinkConduit.PooledBuffersFrameCallback |
next
Modifier | Constructor and Description |
---|---|
protected |
AbstractFramedStreamSinkConduit(StreamSinkConduit next)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doTerminateWrites() |
protected void |
finished() |
protected boolean |
flushQueuedData() |
protected boolean |
isWritesTerminated() |
protected void |
queueCloseFrames() |
protected long |
queuedDataLength() |
protected void |
queueFrame(AbstractFramedStreamSinkConduit.FrameCallBack callback,
ByteBuffer... data)
Queues a frame for sending.
|
void |
terminateWrites()
Signal that no more write data is forthcoming.
|
long |
transferFrom(FileChannel src,
long position,
long count)
Transfer bytes into this conduit from the given file.
|
long |
transferFrom(StreamSourceChannel source,
long count,
ByteBuffer throughBuffer)
Transfers bytes from the given channel source.
|
void |
truncateWrites()
Terminate writes and discard any outstanding write data.
|
int |
write(ByteBuffer src)
Writes a sequence of bytes to this conduit from the given buffer.
|
long |
write(ByteBuffer[] srcs,
int offs,
int len)
Writes a sequence of bytes to this conduit from the given buffers.
|
int |
writeFinal(ByteBuffer src)
Writes some data to the conduit, with the same semantics as
StreamSinkConduit.write(java.nio.ByteBuffer) . |
long |
writeFinal(ByteBuffer[] srcs,
int offs,
int len)
Writes some data to the conduit, with the same semantics as
StreamSinkConduit.write(java.nio.ByteBuffer[], int, int) . |
awaitWritable, awaitWritable, flush, getWriteThread, isWriteResumed, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites, wakeupWrites
getWorker
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
awaitWritable, awaitWritable, flush, getWriteThread, isWriteResumed, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites, wakeupWrites
protected AbstractFramedStreamSinkConduit(StreamSinkConduit next)
next
- the delegate conduit to setprotected void queueFrame(AbstractFramedStreamSinkConduit.FrameCallBack callback, ByteBuffer... data)
callback
- data
- public long transferFrom(FileChannel src, long position, long count) throws IOException
StreamSinkConduit
transferFrom
in interface StreamSinkConduit
transferFrom
in class AbstractStreamSinkConduit<StreamSinkConduit>
src
- the file to read fromposition
- the position within the file from which the transfer is to begincount
- the number of bytes to be transferredIOException
- if an I/O error occurspublic long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException
StreamSinkConduit
throughBuffer
will be cleared. On exit, the
buffer will be flipped for emptying, and may be empty or may contain data. If this method returns a value less
than count
, then the remaining data in throughBuffer
may contain data read from source
which must be written to this channel to complete the operation.transferFrom
in interface StreamSinkConduit
transferFrom
in class AbstractStreamSinkConduit<StreamSinkConduit>
source
- the source to read fromcount
- the number of bytes to be transferredthroughBuffer
- the buffer to copy through.IOException
- if an I/O error occurspublic int write(ByteBuffer src) throws IOException
StreamSinkConduit
write
in interface StreamSinkConduit
write
in class AbstractStreamSinkConduit<StreamSinkConduit>
src
- the buffer containing data to writeClosedChannelException
- if this conduit's SinkConduit.terminateWrites()
method was previously calledIOException
- if an error occurspublic long write(ByteBuffer[] srcs, int offs, int len) throws IOException
StreamSinkConduit
write
in interface StreamSinkConduit
write
in class AbstractStreamSinkConduit<StreamSinkConduit>
srcs
- the buffers containing data to writeoffs
- the offset into the buffer arraylen
- the number of buffers to writeClosedChannelException
- if this conduit's SinkConduit.terminateWrites()
method was previously calledIOException
- if an error occurspublic int writeFinal(ByteBuffer src) throws IOException
StreamSinkConduit
StreamSinkConduit.write(java.nio.ByteBuffer)
. If all the data is written
out then the conduit will have its writes terminated. Semantically this
method is equivalent to:
int rem = src.remaining();
int written = conduit.write(src);
if(written == rem) {
conduit.terminateWrites()
}
writeFinal
in interface StreamSinkConduit
writeFinal
in class AbstractStreamSinkConduit<StreamSinkConduit>
src
- The data to writeIOException
public long writeFinal(ByteBuffer[] srcs, int offs, int len) throws IOException
StreamSinkConduit
StreamSinkConduit.write(java.nio.ByteBuffer[], int, int)
. If all the data is written
out then the conduit will have its writes terminated.writeFinal
in interface StreamSinkConduit
writeFinal
in class AbstractStreamSinkConduit<StreamSinkConduit>
srcs
- The buffers from which bytes are to be retrievedoffs
- The offset within the buffer array of the first buffer from
which bytes are to be retrieved; must be non-negative and no
larger than srcs.lengthlen
- The maximum number of buffers to be accessed; must be
non-negative and no larger than
srcs.length - offsetIOException
protected long queuedDataLength()
public void terminateWrites() throws IOException
SinkConduit
SinkConduit.flush()
ed before it is considered
to be shut down.terminateWrites
in interface SinkConduit
terminateWrites
in class AbstractSinkConduit<StreamSinkConduit>
IOException
protected void doTerminateWrites() throws IOException
IOException
protected boolean flushQueuedData() throws IOException
IOException
public void truncateWrites() throws IOException
SinkConduit
truncateWrites
in interface SinkConduit
truncateWrites
in class AbstractSinkConduit<StreamSinkConduit>
IOException
- if channel termination failed for some reasonprotected boolean isWritesTerminated()
protected void queueCloseFrames()
protected void finished()
Copyright © 2019 JBoss by Red Hat. All rights reserved.