Package io.grpc.netty

Class AbstractNettyHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.http2.Http2ConnectionHandler
io.grpc.netty.GrpcHttp2ConnectionHandler
io.grpc.netty.AbstractNettyHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler, io.netty.handler.codec.http2.Http2LifecycleManager
Direct Known Subclasses:
NettyClientHandler, NettyServerHandler

abstract class AbstractNettyHandler extends GrpcHttp2ConnectionHandler
Base class for all Netty gRPC handlers. This class standardizes exception handling (always shutdown the connection) as well as sending the initial connection window at startup.
  • Field Details

    • GRACEFUL_SHUTDOWN_NO_TIMEOUT

      private static final long GRACEFUL_SHUTDOWN_NO_TIMEOUT
      See Also:
    • initialConnectionWindow

      private final int initialConnectionWindow
    • flowControlPing

      private final AbstractNettyHandler.FlowControlPinger flowControlPing
    • autoTuneFlowControlOn

      private boolean autoTuneFlowControlOn
    • ctx

      private io.netty.channel.ChannelHandlerContext ctx
    • initialWindowSent

      private boolean initialWindowSent
    • ticker

      private final com.google.common.base.Ticker ticker
    • BDP_MEASUREMENT_PING

      private static final long BDP_MEASUREMENT_PING
      See Also:
  • Constructor Details

    • AbstractNettyHandler

      AbstractNettyHandler(io.netty.channel.ChannelPromise channelUnused, io.netty.handler.codec.http2.Http2ConnectionDecoder decoder, io.netty.handler.codec.http2.Http2ConnectionEncoder encoder, io.netty.handler.codec.http2.Http2Settings initialSettings, ChannelLogger negotiationLogger, boolean autoFlowControl, AbstractNettyHandler.PingLimiter pingLimiter, com.google.common.base.Ticker ticker)
  • Method Details

    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.handler.codec.http2.Http2ConnectionHandler
      Throws:
      Exception
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.handler.codec.http2.Http2ConnectionHandler
      Throws:
      Exception
    • exceptionCaught

      public final 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.handler.codec.http2.Http2ConnectionHandler
      Throws:
      Exception
    • ctx

      protected final io.netty.channel.ChannelHandlerContext ctx()
    • sendInitialConnectionWindow

      private void sendInitialConnectionWindow() throws io.netty.handler.codec.http2.Http2Exception
      Sends initial connection window to the remote endpoint if necessary.
      Throws:
      io.netty.handler.codec.http2.Http2Exception
    • flowControlPing

    • setAutoTuneFlowControl

      void setAutoTuneFlowControl(boolean isOn)