org.apache.curator.framework.imps
Class CuratorFrameworkImpl

java.lang.Object
  extended by org.apache.curator.framework.imps.CuratorFrameworkImpl
All Implemented Interfaces:
Closeable, CuratorFramework

public class CuratorFrameworkImpl
extends Object
implements CuratorFramework


Constructor Summary
  CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder)
           
protected CuratorFrameworkImpl(CuratorFrameworkImpl parent)
           
 
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
protected  void internalSync(CuratorFrameworkImpl impl, String path, Object context)
           
 CuratorTransaction inTransaction()
          Start a transaction builder
 boolean isStarted()
          Return true if the client is started, not closed, etc.
 org.apache.curator.utils.EnsurePath newNamespaceAwareEnsurePath(String path)
          Allocates an ensure path instance that is namespace aware
 CuratorFramework nonNamespaceView()
          Returns a facade of the current instance that does _not_ automatically pre-pend the namespace to all paths
 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 context)
          Perform a sync on the given path - syncs are always in the background
 CuratorFramework usingNamespace(String newNamespace)
          Returns a facade of the current instance that uses the specified namespace or no namespace if newNamespace is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CuratorFrameworkImpl

public CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder)

CuratorFrameworkImpl

protected CuratorFrameworkImpl(CuratorFrameworkImpl parent)
Method Detail

clearWatcherReferences

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

Specified by:
clearWatcherReferences in interface CuratorFramework
Parameters:
watcher - the watcher

getState

public CuratorFrameworkState getState()
Description copied from interface: CuratorFramework
Returns the state of this instance

Specified by:
getState in interface CuratorFramework
Returns:
state

isStarted

public boolean isStarted()
Description copied from interface: CuratorFramework
Return true if the client is started, not closed, etc.

Specified by:
isStarted in interface CuratorFramework
Returns:
true/false

blockUntilConnected

public boolean blockUntilConnected(int maxWaitTime,
                                   TimeUnit units)
                            throws InterruptedException
Description copied from interface: CuratorFramework
Block until a connection to ZooKeeper is available or the maxWaitTime has been exceeded

Specified by:
blockUntilConnected in interface CuratorFramework
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

public void blockUntilConnected()
                         throws InterruptedException
Description copied from interface: CuratorFramework
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

Specified by:
blockUntilConnected in interface CuratorFramework
Throws:
InterruptedException - If interrupted while waiting

start

public void start()
Description copied from interface: CuratorFramework
Start the client. Most mutator methods will not work until the client is started

Specified by:
start in interface CuratorFramework

close

public void close()
Description copied from interface: CuratorFramework
Stop the client

Specified by:
close in interface Closeable
Specified by:
close in interface CuratorFramework

nonNamespaceView

public CuratorFramework nonNamespaceView()
Description copied from interface: CuratorFramework
Returns a facade of the current instance that does _not_ automatically pre-pend the namespace to all paths

Specified by:
nonNamespaceView in interface CuratorFramework
Returns:
facade

getNamespace

public String getNamespace()
Description copied from interface: CuratorFramework
Return the current namespace or "" if none

Specified by:
getNamespace in interface CuratorFramework
Returns:
namespace

usingNamespace

public CuratorFramework usingNamespace(String newNamespace)
Description copied from interface: CuratorFramework
Returns a facade of the current instance that uses the specified namespace or no namespace if newNamespace is null.

Specified by:
usingNamespace in interface CuratorFramework
Parameters:
newNamespace - the new namespace or null for none
Returns:
facade

create

public CreateBuilder create()
Description copied from interface: CuratorFramework
Start a create builder

Specified by:
create in interface CuratorFramework
Returns:
builder object

delete

public DeleteBuilder delete()
Description copied from interface: CuratorFramework
Start a delete builder

Specified by:
delete in interface CuratorFramework
Returns:
builder object

checkExists

public ExistsBuilder checkExists()
Description copied from interface: CuratorFramework
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.

Specified by:
checkExists in interface CuratorFramework
Returns:
builder object

getData

public GetDataBuilder getData()
Description copied from interface: CuratorFramework
Start a get data builder

Specified by:
getData in interface CuratorFramework
Returns:
builder object

setData

public SetDataBuilder setData()
Description copied from interface: CuratorFramework
Start a set data builder

Specified by:
setData in interface CuratorFramework
Returns:
builder object

getChildren

public GetChildrenBuilder getChildren()
Description copied from interface: CuratorFramework
Start a get children builder

Specified by:
getChildren in interface CuratorFramework
Returns:
builder object

getACL

public GetACLBuilder getACL()
Description copied from interface: CuratorFramework
Start a get ACL builder

Specified by:
getACL in interface CuratorFramework
Returns:
builder object

setACL

public SetACLBuilder setACL()
Description copied from interface: CuratorFramework
Start a set ACL builder

Specified by:
setACL in interface CuratorFramework
Returns:
builder object

inTransaction

public CuratorTransaction inTransaction()
Description copied from interface: CuratorFramework
Start a transaction builder

Specified by:
inTransaction in interface CuratorFramework
Returns:
builder object

getConnectionStateListenable

public Listenable<ConnectionStateListener> getConnectionStateListenable()
Description copied from interface: CuratorFramework
Returns the listenable interface for the Connect State

Specified by:
getConnectionStateListenable in interface CuratorFramework
Returns:
listenable

getCuratorListenable

public Listenable<CuratorListener> getCuratorListenable()
Description copied from interface: CuratorFramework
Returns the listenable interface for events

Specified by:
getCuratorListenable in interface CuratorFramework
Returns:
listenable

getUnhandledErrorListenable

public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
Description copied from interface: CuratorFramework
Returns the listenable interface for unhandled errors

Specified by:
getUnhandledErrorListenable in interface CuratorFramework
Returns:
listenable

sync

public void sync(String path,
                 Object context)
Description copied from interface: CuratorFramework
Perform a sync on the given path - syncs are always in the background

Specified by:
sync in interface CuratorFramework
Parameters:
path - the path
context - optional context

sync

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

Specified by:
sync in interface CuratorFramework
Returns:
builder object

internalSync

protected void internalSync(CuratorFrameworkImpl impl,
                            String path,
                            Object context)

getZookeeperClient

public org.apache.curator.CuratorZookeeperClient getZookeeperClient()
Description copied from interface: CuratorFramework
Return the managed zookeeper client

Specified by:
getZookeeperClient in interface CuratorFramework
Returns:
client

newNamespaceAwareEnsurePath

public org.apache.curator.utils.EnsurePath newNamespaceAwareEnsurePath(String path)
Description copied from interface: CuratorFramework
Allocates an ensure path instance that is namespace aware

Specified by:
newNamespaceAwareEnsurePath in interface CuratorFramework
Parameters:
path - path to ensure
Returns:
new EnsurePath instance


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