Class KafkaProxyBackendHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.kroxylicious.proxy.internal.KafkaProxyBackendHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class KafkaProxyBackendHandler extends io.netty.channel.ChannelInboundHandlerAdapter
  • Nested Class Summary

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

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

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
    Netty callback that upstream/server channel has successfully connected to the remote peer.
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
    Netty callback to notify that the upstream/server channel TCP connection has disconnected.
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
    Netty callback that something has been read from the upstream/server channel.
    void
    channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
    Invoked when the last message read by the current read operation has been consumed by channelRead(ChannelHandlerContext, Object).
    void
    channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
    Netty callback that resources have been allocated for the channel.
    void
    channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)
    Propagates backpressure to the downstream/client connection by notifying the ServerConnectionStateMachine when the upstream/server connection blocks or unblocks.
    void
    exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
    Netty callback indicating that an exception reached it.
     
    void
    userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object event)
    Netty callback.

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelUnregistered

    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, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Method Details

    • channelWritabilityChanged

      public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Propagates backpressure to the downstream/client connection by notifying the ServerConnectionStateMachine when the upstream/server connection blocks or unblocks.
      Specified by:
      channelWritabilityChanged in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelWritabilityChanged in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - the handler context for upstream/server channel
      Throws:
      Exception - If something went wrong
    • channelRegistered

      public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Netty callback that resources have been allocated for the channel. This is the first point at which we become aware of the upstream/server channel.
      Specified by:
      channelRegistered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRegistered in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - the context for the upstream/server channel.
      Throws:
      Exception - If something went wrong.
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Netty callback that upstream/server channel has successfully connected to the remote peer. This does not mean that the channel is usable by the proxy as TLS negotiation, if required, is still in progress.
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - the context for the upstream/server channel.
      Throws:
      Exception - If something went wrong.
    • userEventTriggered

      public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object event) throws Exception
      Netty callback. Used to notify us of custom events. Events such as the SSL Handshake completing.
      This method is called for every custom event, so its up to us to filter out the ones we care about.
      Specified by:
      userEventTriggered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - the channel handler context on which the event was triggered.
      event - the information being notified
      Throws:
      Exception - any errors in processing.
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
      Netty callback to notify that the upstream/server channel TCP connection has disconnected.
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - The context for the upstream/server channel.
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
      Netty callback indicating that an exception reached it. Which means the proxy should give up as all hope for this connection is lost.
      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
      Parameters:
      ctx - The context for the upstream/server channel.
      cause - The exception which reached netty.
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Netty callback that something has been read from the upstream/server channel. There may be further calls to this method before a call to channelReadComplete() signals the end of the current read operation.
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - The context for the upstream/server channel.
      msg - the message read from the channel.
    • channelReadComplete

      public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) throws Exception

      Invoked when the last message read by the current read operation has been consumed by channelRead(ChannelHandlerContext, Object).

      This allows the proxy to batch requests.
      Specified by:
      channelReadComplete in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - The upstream/server context
      Throws:
      Exception
    • toString

      public String toString()
      Overrides:
      toString in class Object