Class HttpStreamingResponseHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.MessageToMessageDecoder<io.netty.handler.codec.http.HttpObject>
org.apache.tinkerpop.gremlin.driver.handler.HttpStreamingResponseHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class HttpStreamingResponseHandler extends io.netty.handler.codec.MessageToMessageDecoder<io.netty.handler.codec.http.HttpObject>
Decodes chunked HTTP responses into streaming results without buffering the full response body.

For GraphBinary responses, content chunks are passed to a ByteBufQueueInputStream consumed by a GraphBinaryStreamResponseReader on a separate thread. That reader deserializes results incrementally, delivers them to the ResultSet, and handles completion and cleanup. For non-GraphBinary error responses (e.g., JSON 401/500), the error body is accumulated and parsed when the response ends, then LAST_CONTENT_READ_RESPONSE is fired for GremlinResponseHandler to process.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
    HttpStreamingResponseHandler(GraphBinaryReader graphBinaryReader, AtomicReference<ResultSet> pendingResultSet, ExecutorService readerPool)
     
    HttpStreamingResponseHandler(GraphBinaryReader graphBinaryReader, AtomicReference<ResultSet> pendingResultSet, ExecutorService readerPool, long readTimeoutMillis)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    protected void
    decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpObject msg, List<Object> out)
     
    void
    exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
     

    Methods inherited from class io.netty.handler.codec.MessageToMessageDecoder

    acceptInboundMessage, channelRead, channelReadComplete

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

    • HttpStreamingResponseHandler

      public HttpStreamingResponseHandler(GraphBinaryReader graphBinaryReader, AtomicReference<ResultSet> pendingResultSet, ExecutorService readerPool)
    • HttpStreamingResponseHandler

      public HttpStreamingResponseHandler(GraphBinaryReader graphBinaryReader, AtomicReference<ResultSet> pendingResultSet, ExecutorService readerPool, long readTimeoutMillis)
      Parameters:
      readTimeoutMillis - the connection's readTimeout. When positive, the reader thread's own timeout is armed as a backstop 5000Lms longer, so the pipeline ReadTimeoutHandler fires first on a stalled connection and terminates the response with a properly typed exception. A value <= 0 (the default, meaning "no timeout") leaves the reader blocking indefinitely.

      The translation to the backstop bound lives here rather than in ByteBufQueueInputStream's constructor so that the stream can be constructed with the effective bound directly (small values in tests, without paying the full grace).

  • Method Details

    • decode

      protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpObject msg, List<Object> out) throws Exception
      Specified by:
      decode in class io.netty.handler.codec.MessageToMessageDecoder<io.netty.handler.codec.http.HttpObject>
      Throws:
      Exception
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception