org.apache.curator.framework
Class CuratorFrameworkFactory.Builder

java.lang.Object
  extended by org.apache.curator.framework.CuratorFrameworkFactory.Builder
Enclosing class:
CuratorFrameworkFactory

public static class CuratorFrameworkFactory.Builder
extends Object


Method Summary
 CuratorFrameworkFactory.Builder aclProvider(ACLProvider aclProvider)
           
 CuratorFrameworkFactory.Builder authorization(String scheme, byte[] auth)
          Add connection authorization
 CuratorFramework build()
          Apply the current values and build a new CuratorFramework
 CuratorTempFramework buildTemp()
          Apply the current values and build a new temporary CuratorFramework.
 CuratorTempFramework buildTemp(long inactiveThreshold, TimeUnit unit)
          Apply the current values and build a new temporary CuratorFramework.
 boolean canBeReadOnly()
           
 CuratorFrameworkFactory.Builder canBeReadOnly(boolean canBeReadOnly)
           
 CuratorFrameworkFactory.Builder compressionProvider(CompressionProvider compressionProvider)
           
 CuratorFrameworkFactory.Builder connectionTimeoutMs(int connectionTimeoutMs)
           
 CuratorFrameworkFactory.Builder connectString(String connectString)
          Set the list of servers to connect to.
 CuratorFrameworkFactory.Builder defaultData(byte[] defaultData)
          Sets the data to use when PathAndBytesable.forPath(String) is used.
 CuratorFrameworkFactory.Builder ensembleProvider(org.apache.curator.ensemble.EnsembleProvider ensembleProvider)
          Set the list ensemble provider.
 ACLProvider getAclProvider()
           
 String getAuthScheme()
           
 byte[] getAuthValue()
           
 CompressionProvider getCompressionProvider()
           
 int getConnectionTimeoutMs()
           
 byte[] getDefaultData()
           
 org.apache.curator.ensemble.EnsembleProvider getEnsembleProvider()
           
 String getNamespace()
           
 org.apache.curator.RetryPolicy getRetryPolicy()
           
 int getSessionTimeoutMs()
           
 ThreadFactory getThreadFactory()
           
 org.apache.curator.utils.ZookeeperFactory getZookeeperFactory()
           
 CuratorFrameworkFactory.Builder namespace(String namespace)
          As ZooKeeper is a shared space, users of a given cluster should stay within a pre-defined namespace.
 CuratorFrameworkFactory.Builder retryPolicy(org.apache.curator.RetryPolicy retryPolicy)
           
 CuratorFrameworkFactory.Builder sessionTimeoutMs(int sessionTimeoutMs)
           
 CuratorFrameworkFactory.Builder threadFactory(ThreadFactory threadFactory)
           
 CuratorFrameworkFactory.Builder zookeeperFactory(org.apache.curator.utils.ZookeeperFactory zookeeperFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

build

public CuratorFramework build()
Apply the current values and build a new CuratorFramework

Returns:
new CuratorFramework

buildTemp

public CuratorTempFramework buildTemp()
Apply the current values and build a new temporary CuratorFramework. Temporary CuratorFramework instances are meant for single requests to ZooKeeper ensembles over a failure prone network such as a WAN. The APIs available from CuratorTempFramework are limited. Further, the connection will be closed after 3 minutes of inactivity.

Returns:
temp instance

buildTemp

public CuratorTempFramework buildTemp(long inactiveThreshold,
                                      TimeUnit unit)
Apply the current values and build a new temporary CuratorFramework. Temporary CuratorFramework instances are meant for single requests to ZooKeeper ensembles over a failure prone network such as a WAN. The APIs available from CuratorTempFramework are limited. Further, the connection will be closed after inactiveThresholdMs milliseconds of inactivity.

Parameters:
inactiveThreshold - number of milliseconds of inactivity to cause connection close
unit - threshold unit
Returns:
temp instance

authorization

public CuratorFrameworkFactory.Builder authorization(String scheme,
                                                     byte[] auth)
Add connection authorization

Parameters:
scheme - the scheme
auth - the auth bytes
Returns:
this

connectString

public CuratorFrameworkFactory.Builder connectString(String connectString)
Set the list of servers to connect to. IMPORTANT: use either this or ensembleProvider(EnsembleProvider) but not both.

Parameters:
connectString - list of servers to connect to
Returns:
this

ensembleProvider

public CuratorFrameworkFactory.Builder ensembleProvider(org.apache.curator.ensemble.EnsembleProvider ensembleProvider)
Set the list ensemble provider. IMPORTANT: use either this or connectString(String) but not both.

Parameters:
ensembleProvider - the ensemble provider to use
Returns:
this

defaultData

public CuratorFrameworkFactory.Builder defaultData(byte[] defaultData)
Sets the data to use when PathAndBytesable.forPath(String) is used. This is useful for debugging purposes. For example, you could set this to be the IP of the client.

Parameters:
defaultData - new default data to use
Returns:
this

namespace

public CuratorFrameworkFactory.Builder namespace(String namespace)
As ZooKeeper is a shared space, users of a given cluster should stay within a pre-defined namespace. If a namespace is set here, all paths will get pre-pended with the namespace

Parameters:
namespace - the namespace
Returns:
this

sessionTimeoutMs

public CuratorFrameworkFactory.Builder sessionTimeoutMs(int sessionTimeoutMs)
Parameters:
sessionTimeoutMs - session timeout
Returns:
this

connectionTimeoutMs

public CuratorFrameworkFactory.Builder connectionTimeoutMs(int connectionTimeoutMs)
Parameters:
connectionTimeoutMs - connection timeout
Returns:
this

retryPolicy

public CuratorFrameworkFactory.Builder retryPolicy(org.apache.curator.RetryPolicy retryPolicy)
Parameters:
retryPolicy - retry policy to use
Returns:
this

threadFactory

public CuratorFrameworkFactory.Builder threadFactory(ThreadFactory threadFactory)
Parameters:
threadFactory - thread factory used to create Executor Services
Returns:
this

compressionProvider

public CuratorFrameworkFactory.Builder compressionProvider(CompressionProvider compressionProvider)
Parameters:
compressionProvider - the compression provider
Returns:
this

zookeeperFactory

public CuratorFrameworkFactory.Builder zookeeperFactory(org.apache.curator.utils.ZookeeperFactory zookeeperFactory)
Parameters:
zookeeperFactory - the zookeeper factory to use
Returns:
this

aclProvider

public CuratorFrameworkFactory.Builder aclProvider(ACLProvider aclProvider)
Parameters:
aclProvider - a provider for ACLs
Returns:
this

canBeReadOnly

public CuratorFrameworkFactory.Builder canBeReadOnly(boolean canBeReadOnly)
Parameters:
canBeReadOnly - if true, allow ZooKeeper client to enter read only mode in case of a network partition. See ZooKeeper.ZooKeeper(String, int, Watcher, long, byte[], boolean) for details
Returns:
this

getAclProvider

public ACLProvider getAclProvider()

getZookeeperFactory

public org.apache.curator.utils.ZookeeperFactory getZookeeperFactory()

getCompressionProvider

public CompressionProvider getCompressionProvider()

getThreadFactory

public ThreadFactory getThreadFactory()

getEnsembleProvider

public org.apache.curator.ensemble.EnsembleProvider getEnsembleProvider()

getSessionTimeoutMs

public int getSessionTimeoutMs()

getConnectionTimeoutMs

public int getConnectionTimeoutMs()

getRetryPolicy

public org.apache.curator.RetryPolicy getRetryPolicy()

getNamespace

public String getNamespace()

getAuthScheme

public String getAuthScheme()

getAuthValue

public byte[] getAuthValue()

getDefaultData

public byte[] getDefaultData()

canBeReadOnly

public boolean canBeReadOnly()


Copyright © 2011–2014 The Apache Software Foundation. All rights reserved.