Package org.apache.zookeeper.client
Class HostConnectionManager
java.lang.Object
org.apache.zookeeper.client.HostConnectionManager
Manages ZooKeeper server connections with round-robin selection and load balancing during
cluster reconfiguration.
Key Features:
- Round-robin server selection with IP address resolution
- Migrates clients to balance load when servers are added or removed
- Probabilistic client migration during server list updates
Reconfiguration Behavior:
When server list changes, enters "reconfigMode" and calculates migration probabilities to balance load between old and new servers.See ZOOKEEPER-1355 for more details.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for address resolution to support testing and different resolution strategies. -
Constructor Summary
ConstructorsConstructorDescriptionHostConnectionManager(Collection<InetSocketAddress> serverAddresses, long randomnessSeed, HostConnectionManager.Resolver resolver, ZKClientConfig clientConfig) Constructs a HostConnectionManager with custom resolver.HostConnectionManager(Collection<InetSocketAddress> serverAddresses, long randomnessSeed, ZKClientConfig clientConfig) Constructs a HostConnectionManager with default resolver. -
Method Summary
-
Constructor Details
-
HostConnectionManager
public HostConnectionManager(Collection<InetSocketAddress> serverAddresses, long randomnessSeed, ZKClientConfig clientConfig) Constructs a HostConnectionManager with default resolver.- Parameters:
serverAddresses- possibly unresolved ZooKeeper server addressesrandomnessSeed- a seed used to initialize sourceOfRandomnessclientConfig- ZooKeeper client configuration- Throws:
IllegalArgumentException- if serverAddresses is empty
-
HostConnectionManager
public HostConnectionManager(Collection<InetSocketAddress> serverAddresses, long randomnessSeed, HostConnectionManager.Resolver resolver, ZKClientConfig clientConfig) Constructs a HostConnectionManager with custom resolver.- Parameters:
serverAddresses- possibly unresolved ZooKeeper server addressesrandomnessSeed- a seed used to initialize sourceOfRandomnessresolver- custom resolver implementationclientConfig- ZooKeeper client configuration- Throws:
IllegalArgumentException- if serverAddresses is empty
-