Package org.apache.cassandra.net
Class AsyncStreamingInputPlus
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus
-
- org.apache.cassandra.io.util.RebufferingInputStream
-
- org.apache.cassandra.net.AsyncStreamingInputPlus
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataInput
,java.lang.AutoCloseable
,DataInputPlus
,StreamingDataInputPlus
public class AsyncStreamingInputPlus extends RebufferingInputStream implements StreamingDataInputPlus
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AsyncStreamingInputPlus.Consumer
-
Nested classes/interfaces inherited from interface org.apache.cassandra.io.util.DataInputPlus
DataInputPlus.DataInputStreamPlus
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.io.util.RebufferingInputStream
buffer
-
-
Constructor Summary
Constructors Constructor Description AsyncStreamingInputPlus(io.netty.channel.Channel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
append(io.netty.buffer.ByteBuf buf)
Append aByteBuf
to the end of the einternal queue.void
close()
Note: This should invoked on the consuming thread.void
consume(AsyncStreamingInputPlus.Consumer consumer, long length)
Consumes bytes in the stream until the given lengthio.netty.buffer.ByteBufAllocator
getAllocator()
boolean
isEmpty()
protected void
reBuffer()
Implementations must implement this method to refill the buffer.void
requestClosure()
Mark this stream as closed, but do not release any of the resources.int
unsafeAvailable()
As long as this method is invoked on the consuming thread the returned value will be accurate.-
Methods inherited from class org.apache.cassandra.io.util.RebufferingInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readFully, readInt, readLine, readLong, readPrimitiveSlowly, readShort, readUnsignedByte, readUnsignedShort, readUnsignedVInt, readUnsignedVInt32, readUTF, readVInt, readVInt32, skipBytes
-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF
-
Methods inherited from interface org.apache.cassandra.io.util.DataInputPlus
readUnsignedVInt, readUnsignedVInt32, readVInt, readVInt32, skipBytes, skipBytesFully
-
-
-
-
Method Detail
-
append
public boolean append(io.netty.buffer.ByteBuf buf) throws java.lang.IllegalStateException
Append aByteBuf
to the end of the einternal queue. Note: it's expected this method is invoked on the netty event loop.- Throws:
java.lang.IllegalStateException
-
reBuffer
protected void reBuffer() throws java.nio.channels.ClosedChannelException
Implementations must implement this method to refill the buffer. They can expect the buffer to be empty when this method is invoked. Release open buffers and poll thequeue
for more data.This is invoked on a consuming thread (not the event loop) because if we block on the queue we can't fill it on the event loop (as that's where the buffers are coming from).
- Specified by:
reBuffer
in classRebufferingInputStream
- Throws:
java.nio.channels.ClosedChannelException
- when no further reading from this instance should occur. Implies this instance is closed.
-
consume
public void consume(AsyncStreamingInputPlus.Consumer consumer, long length) throws java.io.IOException
Consumes bytes in the stream until the given length- Throws:
java.io.IOException
-
unsafeAvailable
public int unsafeAvailable()
As long as this method is invoked on the consuming thread the returned value will be accurate.
-
isEmpty
public boolean isEmpty()
-
close
public void close()
Note: This should invoked on the consuming thread.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceStreamingDataInputPlus
- Overrides:
close
in classjava.io.InputStream
-
requestClosure
public void requestClosure()
Mark this stream as closed, but do not release any of the resources. Note: this is best to be called from the producer thread.
-
getAllocator
public io.netty.buffer.ByteBufAllocator getAllocator()
-
-