Class ByteBufQueueInputStream
java.lang.Object
java.io.InputStream
org.apache.tinkerpop.gremlin.driver.stream.ByteBufQueueInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
An
InputStream backed by a BlockingQueue of ByteBuf objects. The Netty event loop
offers ByteBufs to the queue as HTTP content chunks arrive, and a reader thread consumes them via
standard InputStream reads.-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
ByteBufQueueInputStream
public ByteBufQueueInputStream() -
ByteBufQueueInputStream
public ByteBufQueueInputStream(long timeoutMillis) - Parameters:
timeoutMillis- the effective maximum time a read blocks waiting for the next chunk. A value<= 0makes the read block indefinitely, deferring the liveness bound to the connection'sreadTimeout(seeReadTimeoutHandler). A positive value acts only as a backstop and is expected to be set longer thanreadTimeoutso the pipeline read-timeout fires first on a stalled connection.This takes the already-resolved bound rather than a
readTimeoutto translate: the translation (adding the backstop grace) lives with its caller inHttpStreamingResponseHandler. Keeping the constructor parameter as the effective bound also lets tests exercise the timeout with small values instead of paying the full backstop grace.
-
-
Method Details
-
offer
public void offer(io.netty.buffer.ByteBuf buf) Offer a ByteBuf to the queue. The caller must have already retained the ByteBuf if needed. The ByteBuf will be released after it is fully read. If the stream is already closed, the buffer is released immediately. -
signalEndOfStream
public void signalEndOfStream()Signal that no more ByteBufs will be offered. -
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-