Package org.apache.cassandra.net
Class AsyncMessageOutputPlus
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.cassandra.io.util.DataOutputStreamPlus
-
- org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
-
- org.apache.cassandra.net.AsyncChannelOutputPlus
-
- org.apache.cassandra.net.AsyncMessageOutputPlus
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataOutput,java.io.Flushable,java.lang.AutoCloseable,DataOutputPlus
public class AsyncMessageOutputPlus extends AsyncChannelOutputPlus
ADataOutputStreamPlusthat writes ASYNCHRONOUSLY to a Netty Channel. Intended as single use, to write one (large) message. The close() and flush() methods synchronously wait for pending writes, and will propagate any exceptions encountered in writing them to the wire. The correctness of this class depends on the ChannelPromise we create against a Channel always being completed, which appears to be a guarantee provided by Netty so long as the event loop is running.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.net.AsyncChannelOutputPlus
AsyncChannelOutputPlus.FlushException
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
buffer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Flush any remaining writes, and release any buffers.voiddiscard()Discard any buffered data, and the buffers that contain it.protected voiddoFlush(int count)longposition()Returns the current position of the underlying target like a file-pointer or the position withing a buffer.-
Methods inherited from class org.apache.cassandra.net.AsyncChannelOutputPlus
beginFlush, flush, flushed, flushedToNetwork, newDefaultChannel, parkUntilFlushed, releaseSpace
-
Methods inherited from class org.apache.cassandra.io.util.BufferedDataOutputStreamPlus
order, write, write, write, write, writeBoolean, writeByte, writeBytes, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
Methods inherited from class org.apache.cassandra.io.util.DataOutputStreamPlus
retrieveTemporaryBuffer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.io.util.DataOutputPlus
hasPosition, write, writeUnsignedVInt, writeVInt
-
-
-
-
Method Detail
-
doFlush
protected void doFlush(int count) throws java.io.IOException- Specified by:
doFlushin classAsyncChannelOutputPlus- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionDescription copied from class:AsyncChannelOutputPlusFlush any remaining writes, and release any buffers. The channel is not closed, as it is assumed to be managed externally. WARNING: This method requires mutual exclusivity with all other producer methods to run safely. It should only be invoked by the owning thread, never the eventLoop; the eventLoop should propagate errors toAsyncChannelOutputPlus.flushFailed, which will propagate them to the producer thread no later than its final invocation toAsyncChannelOutputPlus.close()orAsyncChannelOutputPlus.flush()(that must not be followed by any further writes).- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classAsyncChannelOutputPlus- Throws:
java.io.IOException
-
position
public long position()
Description copied from interface:DataOutputPlusReturns the current position of the underlying target like a file-pointer or the position withing a buffer. Not every implementation may support this functionality. Whether or not this functionality is supported can be checked via theDataOutputPlus.hasPosition().- Specified by:
positionin interfaceDataOutputPlus- Specified by:
positionin classAsyncChannelOutputPlus
-
discard
public void discard()
Discard any buffered data, and the buffers that contain it. May be invoked instead ofclose()if we terminate exceptionally.- Specified by:
discardin classAsyncChannelOutputPlus
-
-