public class ConnectionPool extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected io.netty.resolver.dns.DnsNameResolver |
dnsResolver |
protected ConcurrentHashMap<InetSocketAddress,ConcurrentMap<Integer,CompletableFuture<ClientCnx>>> |
pool |
static String |
TLS_HANDLER |
| Constructor and Description |
|---|
ConnectionPool(ClientConfigurationData conf,
io.netty.channel.EventLoopGroup eventLoopGroup) |
ConnectionPool(ClientConfigurationData conf,
io.netty.channel.EventLoopGroup eventLoopGroup,
Supplier<ClientCnx> clientCnxSupplier) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
CompletableFuture<ClientCnx> |
getConnection(InetSocketAddress address) |
CompletableFuture<ClientCnx> |
getConnection(InetSocketAddress logicalAddress,
InetSocketAddress physicalAddress)
Get a connection from the pool.
|
static int |
signSafeMod(long dividend,
int divisor) |
protected final ConcurrentHashMap<InetSocketAddress,ConcurrentMap<Integer,CompletableFuture<ClientCnx>>> pool
protected final io.netty.resolver.dns.DnsNameResolver dnsResolver
public static final String TLS_HANDLER
public ConnectionPool(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup)
public ConnectionPool(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, Supplier<ClientCnx> clientCnxSupplier)
public CompletableFuture<ClientCnx> getConnection(InetSocketAddress address)
public CompletableFuture<ClientCnx> getConnection(InetSocketAddress logicalAddress, InetSocketAddress physicalAddress)
The connection can either be created or be coming from the pool itself.
When specifying multiple addresses, the logicalAddress is used as a tag for the broker, while the physicalAddress is where the connection is actually happening.
These two addresses can be different when the client is forced to connect through a proxy layer. Essentially, the pool is using the logical address as a way to decide whether to reuse a particular connection.
logicalAddress - the address to use as the broker tagphysicalAddress - the real address where the TCP connection should be madepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic static int signSafeMod(long dividend,
int divisor)
Copyright © 2017–2018 Apache Software Foundation. All rights reserved.