Class RelayHandler<I>

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<I>
google.registry.proxy.handler.RelayHandler<I>
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
Direct Known Subclasses:
RelayHandler.FullHttpRequestRelayHandler, RelayHandler.FullHttpResponseRelayHandler

public class RelayHandler<I> extends io.netty.channel.SimpleChannelInboundHandler<I>
Receives inbound massage of type I, and writes it to the relayChannel stored in the inbound channel's attribute.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Specialized RelayHandler that takes a FullHttpRequest as inbound payload.
    static class 
    Specialized RelayHandler that takes a FullHttpResponse as inbound payload.

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final io.netty.util.AttributeKey<Deque<Object>>
    A queue that saves messages that failed to be relayed.
    static final io.netty.util.AttributeKey<io.netty.channel.Channel>
    Key used to retrieve the relay channel from a Channel's Attribute.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RelayHandler(Class<? extends I> clazz)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    channelRead0(io.netty.channel.ChannelHandlerContext ctx, I msg)
    Read message of type I, write it as-is into the relay channel.
    void
    exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
     
    static void
    writeToRelayChannel(io.netty.channel.Channel channel, io.netty.channel.Channel relayChannel, Object msg, boolean retry)
     

    Methods inherited from class io.netty.channel.SimpleChannelInboundHandler

    acceptInboundMessage, channelRead

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelReadComplete, 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
  • Field Details

    • RELAY_BUFFER_KEY

      public static final io.netty.util.AttributeKey<Deque<Object>> RELAY_BUFFER_KEY
      A queue that saves messages that failed to be relayed.

      This queue is null for channels that should not retry on failure, i. e. backend channels.

      This queue does not need to be synchronised because it is only accessed by the I/O thread of the channel, or its relay channel. Since both channels use the same EventLoop, their I/O activities are handled by the same thread.

    • RELAY_CHANNEL_KEY

      public static final io.netty.util.AttributeKey<io.netty.channel.Channel> RELAY_CHANNEL_KEY
      Key used to retrieve the relay channel from a Channel's Attribute.
  • Constructor Details

    • RelayHandler

      public RelayHandler(Class<? extends I> clazz)
  • Method Details

    • channelRead0

      protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, I msg)
      Read message of type I, write it as-is into the relay channel.
      Specified by:
      channelRead0 in class io.netty.channel.SimpleChannelInboundHandler<I>
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
      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
    • writeToRelayChannel

      public static void writeToRelayChannel(io.netty.channel.Channel channel, io.netty.channel.Channel relayChannel, Object msg, boolean retry)