Package io.netty.bootstrap
Class ResolveAllBootstrap
- java.lang.Object
-
- io.netty.bootstrap.AbstractBootstrap<io.netty.bootstrap.Bootstrap,io.netty.channel.Channel>
-
- io.netty.bootstrap.Bootstrap
-
- io.netty.bootstrap.InstrumentedBootstrap
-
- io.netty.bootstrap.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
-
Constructor Summary
Constructors Modifier Constructor Description ResolveAllBootstrap(CallTracker connectCallTracker, CallTracker resolveCallTracker)
Constructor for the bootstrap.protected
ResolveAllBootstrap(ResolveAllBootstrap old)
ResolveAllBootstrap(java.util.function.Function<java.net.SocketAddress,CallTracker> connectCallTracker, java.util.function.Function<java.net.SocketAddress,CallTracker> resolveCallTracker)
Constructor for the bootstrap
-
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 aChannel
to the remote peer.io.netty.channel.ChannelFuture
connect(java.net.SocketAddress remoteAddress)
Connect aChannel
to the remote peer.io.netty.channel.ChannelFuture
connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Connect aChannel
to the remote peer.io.netty.bootstrap.Bootstrap
sortResolvedAddress(java.util.Comparator<java.net.SocketAddress> comparator)
-
Methods inherited from class io.netty.bootstrap.InstrumentedBootstrap
clone
-
Methods inherited from class io.netty.bootstrap.Bootstrap
config, connect, connect, remoteAddress, remoteAddress, remoteAddress, resolver, validate
-
-
-
-
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.
-
ResolveAllBootstrap
protected ResolveAllBootstrap(ResolveAllBootstrap old)
-
-
Method Detail
-
sortResolvedAddress
public io.netty.bootstrap.Bootstrap sortResolvedAddress(@Nonnull java.util.Comparator<java.net.SocketAddress> comparator)
-
connect
public io.netty.channel.ChannelFuture connect()
Description copied from class:InstrumentedBootstrap
Connect aChannel
to the remote peer.- Overrides:
connect
in classInstrumentedBootstrap
-
connect
public io.netty.channel.ChannelFuture connect(java.net.SocketAddress remoteAddress)
Description copied from class:InstrumentedBootstrap
Connect aChannel
to the remote peer.- Overrides:
connect
in classInstrumentedBootstrap
-
connect
public io.netty.channel.ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Description copied from class:InstrumentedBootstrap
Connect aChannel
to the remote peer.- Overrides:
connect
in classInstrumentedBootstrap
-
clone
public io.netty.bootstrap.Bootstrap clone(io.netty.channel.EventLoopGroup group)
- Overrides:
clone
in classInstrumentedBootstrap
-
-