Package org.kiwiproject.curator.config
Class CuratorConfig
- java.lang.Object
-
- org.kiwiproject.curator.config.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 Summary
Fields Modifier and Type Field Description static intDEFAULT_BASE_SLEEP_MSDefault for base sleep milliseconds.static intDEFAULT_CONNECTION_TIMEOUT_MSDefault connection timeout when creating newCuratorFrameworkinstances.static StringDEFAULT_HEALTH_CHECK_NAMEDefault health check name.static intDEFAULT_MAX_RETRIESDefault is 29, because (private) max value inExponentialBackoffRetryis 29.static intDEFAULT_MAX_SLEEP_SECONDSDefault for max sleep milliseconds.static intDEFAULT_SESSION_TIMEOUT_MSDefault session timeout when creating newCuratorFrameworkinstances.static StringDEFAULT_ZK_CONNECT_STRINGWe default to localhost:2181 but clearly this will not be useful in most production environments.
-
Constructor Summary
Constructors Constructor Description CuratorConfig()Create new instance using a defaultZooKeeperConfigProviderconfigured withDEFAULT_ZK_CONNECT_STRINGas the connect string.CuratorConfig(org.kiwiproject.config.provider.ZooKeeperConfigProvider zkConfigProvider)Create new instance using the givenZooKeeperConfigProvider.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CuratorConfigcopyOf(CuratorConfig original)Create a copy of the original CuratorConfig.static CuratorConfigcopyOfWithZkConnectString(CuratorConfig original, String newZkConnectString)Create a copy of the original CuratorConfig except withnewZkConnectStringas the ZooKeeper connect string.StringgetZkConnectString()Return the ZooKeeper connect string using an explicitly configured value, or using the resolution of theZooKeeperConfigProviderin this instance.
-
-
-
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 newCuratorFrameworkinstances.- Implementation Note:
- Set to the value of
DEFAULT_SESSION_TIMEOUT_MSinCuratorFrameworkFactorywhich 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 newCuratorFrameworkinstances.- Implementation Note:
- Set to the value of
DEFAULT_CONNECTION_TIMEOUT_MSCuratorFrameworkFactorywhich 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 inExponentialBackoffRetryis 29.- See Also:
- Constant Field Values
-
DEFAULT_BASE_SLEEP_MS
public static final int DEFAULT_BASE_SLEEP_MS
Default for base sleep milliseconds. Required byBoundedExponentialBackoffRetry.- See Also:
- Constant Field Values
-
DEFAULT_MAX_SLEEP_SECONDS
public static final int DEFAULT_MAX_SLEEP_SECONDS
Default for max sleep milliseconds. Required byBoundedExponentialBackoffRetry.- 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 defaultZooKeeperConfigProviderconfigured withDEFAULT_ZK_CONNECT_STRINGas the connect string.
-
CuratorConfig
public CuratorConfig(org.kiwiproject.config.provider.ZooKeeperConfigProvider zkConfigProvider)
Create new instance using the givenZooKeeperConfigProvider.- 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 withnewZkConnectStringas the ZooKeeper connect string.- Parameters:
original- the config to copynewZkConnectString- 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 theZooKeeperConfigProviderin this instance.- Returns:
- the ZooKeeper connect string
- Throws:
IllegalStateException- if there is no explicit connect string value or it cannot be resolved by theZooKeeperConfigProvider
-
-