Class CuratorConfig


  • public class CuratorConfig
    extends Object
    Configuration for Curator, which is mainly the ZooKeeper connection string along with some properties to configure the retry policy.

    Currently the only supported retry policy is BoundedExponentialBackoffRetry.

    • Field Detail

      • DEFAULT_ZK_CONNECT_STRING

        public static final String DEFAULT_ZK_CONNECT_STRING
        We default to localhost:2181 but clearly this will not be useful in most production environments. It might be OK in some unit testing scenarios.
        See Also:
        Constant Field Values
      • DEFAULT_SESSION_TIMEOUT_MS

        public static final int DEFAULT_SESSION_TIMEOUT_MS
        Default session timeout when creating new CuratorFramework instances.
        Implementation Note:
        Set to the value of DEFAULT_SESSION_TIMEOUT_MS in CuratorFrameworkFactory which is, unfortunately, private so we cannot simply reference it directly.
      • DEFAULT_CONNECTION_TIMEOUT_MS

        public static final int DEFAULT_CONNECTION_TIMEOUT_MS
        Default connection timeout when creating new CuratorFramework instances.
        Implementation Note:
        Set to the value of DEFAULT_CONNECTION_TIMEOUT_MS CuratorFrameworkFactory which is, unfortunately, private so we cannot simply reference it directly.
      • DEFAULT_MAX_RETRIES

        public static final int DEFAULT_MAX_RETRIES
        Default is 29, because (private) max value in ExponentialBackoffRetry is 29.
        See Also:
        Constant Field Values
      • DEFAULT_BASE_SLEEP_MS

        public static final int DEFAULT_BASE_SLEEP_MS
        Default for base sleep milliseconds. Required by BoundedExponentialBackoffRetry.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_SLEEP_SECONDS

        public static final int DEFAULT_MAX_SLEEP_SECONDS
        Default for max sleep milliseconds. Required by BoundedExponentialBackoffRetry.
        See Also:
        Constant Field Values
      • DEFAULT_HEALTH_CHECK_NAME

        public static final String DEFAULT_HEALTH_CHECK_NAME
        Default health check name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CuratorConfig

        public CuratorConfig()
        Create new instance using a default ZooKeeperConfigProvider configured with DEFAULT_ZK_CONNECT_STRING as the connect string.
      • CuratorConfig

        public CuratorConfig​(org.kiwiproject.config.provider.ZooKeeperConfigProvider zkConfigProvider)
        Create new instance using the given ZooKeeperConfigProvider.
        Parameters:
        zkConfigProvider - the config provider
    • Method Detail

      • copyOf

        public static CuratorConfig copyOf​(CuratorConfig original)
        Create a copy of the original CuratorConfig.
        Parameters:
        original - the config to copy
        Returns:
        a new instance with the same values
      • copyOfWithZkConnectString

        public static CuratorConfig copyOfWithZkConnectString​(CuratorConfig original,
                                                              String newZkConnectString)
        Create a copy of the original CuratorConfig except with newZkConnectString as the ZooKeeper connect string.
        Parameters:
        original - the config to copy
        newZkConnectString - the ZooKeeper connect string to set in the returned "copy"
        Returns:
        a new instance with the same values except the connect string
      • getZkConnectString

        public String getZkConnectString()
        Return the ZooKeeper connect string using an explicitly configured value, or using the resolution of the ZooKeeperConfigProvider in this instance.
        Returns:
        the ZooKeeper connect string
        Throws:
        IllegalStateException - if there is no explicit connect string value or it cannot be resolved by the ZooKeeperConfigProvider