org.apache.curator.framework
Interface CuratorFramework

All Superinterfaces:
Closeable
All Known Implementing Classes:
CuratorFrameworkImpl

public interface CuratorFramework
extends Closeable

Zookeeper framework-style client


Method Summary
 void blockUntilConnected()
          Block until a connection to ZooKeeper is available.
 boolean blockUntilConnected(int maxWaitTime, TimeUnit units)
          Block until a connection to ZooKeeper is available or the maxWaitTime has been exceeded
 ExistsBuilder checkExists()
          Start an exists builder
 void clearWatcherReferences(org.apache.zookeeper.Watcher watcher)
          Curator can hold internal references to watchers that may inhibit garbage collection.
 void close()
          Stop the client
 CreateBuilder create()
          Start a create builder
 DeleteBuilder delete()
          Start a delete builder
 GetACLBuilder getACL()
          Start a get ACL builder
 GetChildrenBuilder getChildren()
          Start a get children builder
 Listenable<ConnectionStateListener> getConnectionStateListenable()
          Returns the listenable interface for the Connect State
 Listenable<CuratorListener> getCuratorListenable()
          Returns the listenable interface for events
 GetDataBuilder getData()
          Start a get data builder
 String getNamespace()
          Return the current namespace or "" if none
 CuratorFrameworkState getState()
          Returns the state of this instance
 Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
          Returns the listenable interface for unhandled errors
 org.apache.curator.CuratorZookeeperClient getZookeeperClient()
          Return the managed zookeeper client
 CuratorTransaction inTransaction()
          Start a transaction builder
 boolean isStarted()
          Deprecated. use getState() instead
 org.apache.curator.utils.EnsurePath newNamespaceAwareEnsurePath(String path)
          Allocates an ensure path instance that is namespace aware
 CuratorFramework nonNamespaceView()
          Deprecated. use usingNamespace(java.lang.String) passing null
 SetACLBuilder setACL()
          Start a set ACL builder
 SetDataBuilder setData()
          Start a set data builder
 void start()
          Start the client.
 SyncBuilder sync()
          Start a sync builder.
 void sync(String path, Object backgroundContextObject)
          Deprecated. use sync() instead
 CuratorFramework usingNamespace(String newNamespace)
          Returns a facade of the current instance that uses the specified namespace or no namespace if newNamespace is null.
 

Method Detail

start

void start()
Start the client. Most mutator methods will not work until the client is started


close

void close()
Stop the client

Specified by:
close in interface Closeable

getState

CuratorFrameworkState getState()
Returns the state of this instance

Returns:
state

isStarted

boolean isStarted()
Deprecated. use getState() instead

Return true if the client is started, not closed, etc.

Returns:
true/false

create

CreateBuilder create()
Start a create builder

Returns:
builder object

delete

DeleteBuilder delete()
Start a delete builder

Returns:
builder object

checkExists

ExistsBuilder checkExists()
Start an exists builder

The builder will return a Stat object as if org.apache.zookeeper.ZooKeeper.exists() were called. Thus, a null means that it does not exist and an actual Stat object means it does exist.

Returns:
builder object

getData

GetDataBuilder getData()
Start a get data builder

Returns:
builder object

setData

SetDataBuilder setData()
Start a set data builder

Returns:
builder object

getChildren

GetChildrenBuilder getChildren()
Start a get children builder

Returns:
builder object

getACL

GetACLBuilder getACL()
Start a get ACL builder

Returns:
builder object

setACL

SetACLBuilder setACL()
Start a set ACL builder

Returns:
builder object

inTransaction

CuratorTransaction inTransaction()
Start a transaction builder

Returns:
builder object

sync

void sync(String path,
          Object backgroundContextObject)
Deprecated. use sync() instead

Perform a sync on the given path - syncs are always in the background

Parameters:
path - the path
backgroundContextObject - optional context

sync

SyncBuilder sync()
Start a sync builder. Note: sync is ALWAYS in the background even if you don't use one of the background() methods

Returns:
builder object

getConnectionStateListenable

Listenable<ConnectionStateListener> getConnectionStateListenable()
Returns the listenable interface for the Connect State

Returns:
listenable

getCuratorListenable

Listenable<CuratorListener> getCuratorListenable()
Returns the listenable interface for events

Returns:
listenable

getUnhandledErrorListenable

Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
Returns the listenable interface for unhandled errors

Returns:
listenable

nonNamespaceView

CuratorFramework nonNamespaceView()
Deprecated. use usingNamespace(java.lang.String) passing null

Returns a facade of the current instance that does _not_ automatically pre-pend the namespace to all paths

Returns:
facade

usingNamespace

CuratorFramework usingNamespace(String newNamespace)
Returns a facade of the current instance that uses the specified namespace or no namespace if newNamespace is null.

Parameters:
newNamespace - the new namespace or null for none
Returns:
facade

getNamespace

String getNamespace()
Return the current namespace or "" if none

Returns:
namespace

getZookeeperClient

org.apache.curator.CuratorZookeeperClient getZookeeperClient()
Return the managed zookeeper client

Returns:
client

newNamespaceAwareEnsurePath

org.apache.curator.utils.EnsurePath newNamespaceAwareEnsurePath(String path)
Allocates an ensure path instance that is namespace aware

Parameters:
path - path to ensure
Returns:
new EnsurePath instance

clearWatcherReferences

void clearWatcherReferences(org.apache.zookeeper.Watcher watcher)
Curator can hold internal references to watchers that may inhibit garbage collection. Call this method on watchers you are no longer interested in.

Parameters:
watcher - the watcher

blockUntilConnected

boolean blockUntilConnected(int maxWaitTime,
                            TimeUnit units)
                            throws InterruptedException
Block until a connection to ZooKeeper is available or the maxWaitTime has been exceeded

Parameters:
maxWaitTime - The maximum wait time. Specify a value <= 0 to wait indefinitely
units - The time units for the maximum wait time.
Returns:
True if connection has been established, false otherwise.
Throws:
InterruptedException - If interrupted while waiting

blockUntilConnected

void blockUntilConnected()
                         throws InterruptedException
Block until a connection to ZooKeeper is available. This method will not return until a connection is available or it is interrupted, in which case an InterruptedException will be thrown

Throws:
InterruptedException - If interrupted while waiting


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