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 |
| 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.
|
void |
releaseConnection(ClientCnx cnx) |
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 ConnectionPool(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) throws PulsarClientException
PulsarClientExceptionpublic ConnectionPool(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, Supplier<ClientCnx> clientCnxSupplier) throws PulsarClientException
PulsarClientExceptionpublic 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 releaseConnection(ClientCnx cnx)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic static int signSafeMod(long dividend,
int divisor)
Copyright © 2017–2020 Apache Software Foundation. All rights reserved.