Package org.apache.zookeeper.client
Class HostProviderFactory
java.lang.Object
org.apache.zookeeper.client.HostProviderFactory
Factory for creating appropriate HostProvider instances based on connect string format.
This factory enables zero-code-change migration by automatically detecting the connect
string format and creating the appropriate HostProvider implementation.
Supported formats:
- Host:Port: "host1:port1,host2:port2,host3:port3" (StaticHostProvider)
- DNS SRV: "dns-srv://service.domain.com" (DnsSrvHostProvider)
- Future formats can be easily added by extending the factory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic HostProviderCreates a HostProvider based on the connect string format.static HostProvidercreate(ConnectStringParser connectStringParser, ZKClientConfig clientConfig) Creates a HostProvider based on the connect string format.
-
Constructor Details
-
HostProviderFactory
public HostProviderFactory()
-
-
Method Details
-
create
Creates a HostProvider based on the connect string format. This is a convenience method for zero-code-change migration.- Parameters:
connectString- the connect string- Returns:
- appropriate HostProvider
-
create
@Private public static HostProvider create(ConnectStringParser connectStringParser, ZKClientConfig clientConfig) Creates a HostProvider based on the connect string format.- Parameters:
connectStringParser- the connect string parserclientConfig- ZooKeeper client configuration- Returns:
- appropriate HostProvider
-