public static class CuratorFrameworkFactory.Builder extends Object
public CuratorFramework build()
public CuratorTempFramework buildTemp()
CuratorTempFramework
are limited. Further, the connection will be closed after 3 minutes of inactivity.public CuratorTempFramework buildTemp(long inactiveThreshold, TimeUnit unit)
CuratorTempFramework
are limited. Further, the connection will be closed after inactiveThresholdMs
milliseconds of inactivity.inactiveThreshold
- number of milliseconds of inactivity to cause connection closeunit
- threshold unitpublic CuratorFrameworkFactory.Builder authorization(String scheme, byte[] auth)
scheme
- the schemeauth
- the auth bytespublic CuratorFrameworkFactory.Builder authorization(List<AuthInfo> authInfos)
authorization(java.lang.String, byte[])
for backward compatibility.
Subsequent calls to this method overwrite the prior calls.authInfos
- list of AuthInfo
objects with scheme and authpublic CuratorFrameworkFactory.Builder connectString(String connectString)
ensembleProvider(EnsembleProvider)
but not both.connectString
- list of servers to connect topublic CuratorFrameworkFactory.Builder ensembleProvider(EnsembleProvider ensembleProvider)
connectString(String)
but not both.ensembleProvider
- the ensemble provider to usepublic CuratorFrameworkFactory.Builder ensembleTracker(boolean withEnsembleTracker)
true
.ensembleProvider(EnsembleProvider)
to provide
an instance that returns false
on EnsembleProvider.updateServerListEnabled()
in order
to fully achieve that ensemble server list changes are ignoredwithEnsembleTracker
- use false
if you want to avoid following ensemble configuration changespublic boolean withEnsembleTracker()
true
if ensemble configuration changes MUST be watchedpublic CuratorFrameworkFactory.Builder defaultData(byte[] defaultData)
PathAndBytesable.forPath(String)
is used.
This is useful for debugging purposes. For example, you could set this to be the IP of the
client.defaultData
- new default data to usepublic CuratorFrameworkFactory.Builder namespace(String namespace)
namespace
- the namespacepublic CuratorFrameworkFactory.Builder sessionTimeoutMs(int sessionTimeoutMs)
sessionTimeoutMs
- session timeoutpublic CuratorFrameworkFactory.Builder connectionTimeoutMs(int connectionTimeoutMs)
connectionTimeoutMs
- connection timeoutpublic CuratorFrameworkFactory.Builder maxCloseWaitMs(int maxCloseWaitMs)
maxCloseWaitMs
- time to wait during close to join background threadspublic CuratorFrameworkFactory.Builder retryPolicy(RetryPolicy retryPolicy)
retryPolicy
- retry policy to usepublic CuratorFrameworkFactory.Builder threadFactory(ThreadFactory threadFactory)
threadFactory
- thread factory used to create Executor Servicespublic CuratorFrameworkFactory.Builder compressionProvider(CompressionProvider compressionProvider)
compressionProvider
- the compression providerpublic CuratorFrameworkFactory.Builder zookeeperFactory(ZookeeperFactory zookeeperFactory)
zookeeperFactory
- the zookeeper factory to usepublic CuratorFrameworkFactory.Builder aclProvider(ACLProvider aclProvider)
aclProvider
- a provider for ACLspublic CuratorFrameworkFactory.Builder canBeReadOnly(boolean canBeReadOnly)
canBeReadOnly
- if true, allow ZooKeeper client to enter
read only mode in case of a network partition. See
ZooKeeper(String, int, Watcher, long, byte[], boolean)
for detailspublic CuratorFrameworkFactory.Builder dontUseContainerParents()
CreateBuilderMain.creatingParentContainersIfNeeded()
if the ZK JAR supports CreateMode.CONTAINER
. Call this method to turn off this behavior.public CuratorFrameworkFactory.Builder connectionStateErrorPolicy(ConnectionStateErrorPolicy connectionStateErrorPolicy)
StandardConnectionStateErrorPolicy
connectionStateErrorPolicy
- new error policypublic CuratorFrameworkFactory.Builder waitForShutdownTimeoutMs(int waitForShutdownTimeoutMs)
CuratorZookeeperClient.close(int)
}.
The default is 0, which means that this feature is disabled.waitForShutdownTimeoutMs
- default timeoutpublic CuratorFrameworkFactory.Builder simulatedSessionExpirationPercent(int simulatedSessionExpirationPercent)
Prior to 3.0.0, Curator did not try to manage session expiration other than the functionality provided by ZooKeeper itself. Starting with 3.0.0, Curator has the option of attempting to monitor session expiration above what is provided by ZooKeeper. The percentage set by this method determines how and if Curator will check for session expiration.
The default percentage is 100.
If it is set to 0, Curator does not do any additional checking for session expiration.
If a positive number is set, Curator will check for session expiration as follows: when ZooKeeper sends a Disconnect event, Curator will start a timer. If re-connection is not achieved before the elapsed time exceeds the negotiated session time multiplied by the session expiration percent, Curator will simulate a session expiration. Due to timing/network issues, it is not possible for a client to match the server's session timeout with complete accuracy. Thus, the need for a session expiration percentage.
simulatedSessionExpirationPercent
- new simulated session expiration percentagepublic CuratorFrameworkFactory.Builder zkClientConfig(org.apache.zookeeper.client.ZKClientConfig zkClientConfig)
public CuratorFrameworkFactory.Builder schemaSet(SchemaSet schemaSet)
schemaSet
- the schema setpublic CuratorFrameworkFactory.Builder runSafeService(Executor runSafeService)
threadFactory(java.util.concurrent.ThreadFactory)
. Use this method
to set a custom executor.runSafeService
- executor to use for calls to notifyAll from Watcher callbacks etcpublic CuratorFrameworkFactory.Builder connectionStateListenerManagerFactory(ConnectionStateListenerManagerFactory connectionStateListenerManagerFactory)
ConnectionStateListenerManagerFactory.circuitBreaking(org.apache.curator.RetryPolicy)
connectionStateListenerManagerFactory
- manager factory to usepublic Executor getRunSafeService()
public ACLProvider getAclProvider()
public ZookeeperFactory getZookeeperFactory()
public CompressionProvider getCompressionProvider()
public ThreadFactory getThreadFactory()
public EnsembleProvider getEnsembleProvider()
public int getSessionTimeoutMs()
public int getConnectionTimeoutMs()
public int getWaitForShutdownTimeoutMs()
public int getMaxCloseWaitMs()
public RetryPolicy getRetryPolicy()
public String getNamespace()
public boolean useContainerParentsIfAvailable()
public ConnectionStateErrorPolicy getConnectionStateErrorPolicy()
public int getSimulatedSessionExpirationPercent()
public org.apache.zookeeper.client.ZKClientConfig getZkClientConfig()
public SchemaSet getSchemaSet()
@Deprecated public String getAuthScheme()
@Deprecated public byte[] getAuthValue()
public byte[] getDefaultData()
public boolean canBeReadOnly()
public ConnectionStateListenerManagerFactory getConnectionStateListenerManagerFactory()
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.