Class ResolveAllBootstrap

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class ResolveAllBootstrap
    extends InstrumentedBootstrap
    The existing Netty Bootstrap has a limitation regarding connecting to remote hosts where the hostname resolves to more than one IP address. It will only try one resolved address and then fail if the connection cannot be established. This is a problem for us: If we have a service which is bound to the IPv4 address and the IPv6 address is added to the DNS, attempts to connect to the machine are likely to fail. This bootstrap will attempt to do the right thing by attempting to connect using each of the resolved IP addresses. A sort comparator may be provided to encourage preference in the order of connect attempts. To conform to de-facto standards, one should provide a comparator which will sort IPv6 addresses first. Created by acurtis on 4/20/18.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static io.netty.util.AttributeKey<java.util.Comparator<java.net.SocketAddress>> SORT_KEY  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.netty.bootstrap.Bootstrap clone​(io.netty.channel.EventLoopGroup group)  
      io.netty.channel.ChannelFuture connect()
      Connect a Channel to the remote peer.
      io.netty.channel.ChannelFuture connect​(java.net.SocketAddress remoteAddress)
      Connect a Channel to the remote peer.
      io.netty.channel.ChannelFuture connect​(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
      Connect a Channel to the remote peer.
      io.netty.bootstrap.Bootstrap sortResolvedAddress​(java.util.Comparator<java.net.SocketAddress> comparator)  
      • Methods inherited from class io.netty.bootstrap.Bootstrap

        config, connect, connect, remoteAddress, remoteAddress, remoteAddress, resolver, validate
      • Methods inherited from class io.netty.bootstrap.AbstractBootstrap

        attr, bind, bind, bind, bind, bind, channel, channelFactory, channelFactory, group, group, handler, localAddress, localAddress, localAddress, localAddress, option, register, toString
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SORT_KEY

        public static final io.netty.util.AttributeKey<java.util.Comparator<java.net.SocketAddress>> SORT_KEY
    • Constructor Detail

      • ResolveAllBootstrap

        public ResolveAllBootstrap​(@Nonnull
                                   CallTracker connectCallTracker,
                                   @Nonnull
                                   CallTracker resolveCallTracker)
        Constructor for the bootstrap.
        Parameters:
        connectCallTracker - CallTracker for connect operations.
        resolveCallTracker - CallTracker for resolveAll operations.
      • ResolveAllBootstrap

        public ResolveAllBootstrap​(@Nonnull
                                   java.util.function.Function<java.net.SocketAddress,​CallTracker> connectCallTracker,
                                   @Nonnull
                                   java.util.function.Function<java.net.SocketAddress,​CallTracker> resolveCallTracker)
        Constructor for the bootstrap
        Parameters:
        connectCallTracker - provide CallTracker for connect operations. Function must not return null.
        resolveCallTracker - provide CallTracker for resolveAll operations. Function must not return null.
    • Method Detail

      • sortResolvedAddress

        public io.netty.bootstrap.Bootstrap sortResolvedAddress​(@Nonnull
                                                                java.util.Comparator<java.net.SocketAddress> comparator)
      • connect

        public io.netty.channel.ChannelFuture connect​(java.net.SocketAddress remoteAddress,
                                                      java.net.SocketAddress localAddress)
        Description copied from class: InstrumentedBootstrap
        Connect a Channel to the remote peer.
        Overrides:
        connect in class InstrumentedBootstrap
      • clone

        public io.netty.bootstrap.Bootstrap clone​(io.netty.channel.EventLoopGroup group)
        Overrides:
        clone in class InstrumentedBootstrap