Class HostProviderFactory

java.lang.Object
org.apache.zookeeper.client.HostProviderFactory

@Public public class HostProviderFactory extends Object
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 Details

    • HostProviderFactory

      public HostProviderFactory()
  • Method Details

    • create

      public static HostProvider create(String connectString)
      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 parser
      clientConfig - ZooKeeper client configuration
      Returns:
      appropriate HostProvider