Class ByteBufQueueInputStream

java.lang.Object
java.io.InputStream
org.apache.tinkerpop.gremlin.driver.stream.ByteBufQueueInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class ByteBufQueueInputStream extends InputStream
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 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 <= 0 makes the read block indefinitely, deferring the liveness bound to the connection's readTimeout (see ReadTimeoutHandler). A positive value acts only as a backstop and is expected to be set longer than readTimeout so the pipeline read-timeout fires first on a stalled connection.

      This takes the already-resolved bound rather than a readTimeout to translate: the translation (adding the backstop grace) lives with its caller in HttpStreamingResponseHandler. 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

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException