org.apache.activemq.leveldb.replicated.groups
Class ZKClient

java.lang.Object
  extended by org.linkedin.zookeeper.client.AbstractZooKeeper
      extended by org.linkedin.zookeeper.client.AbstractZKClient
          extended by org.apache.activemq.leveldb.replicated.groups.ZKClient
All Implemented Interfaces:
org.apache.zookeeper.Watcher, org.linkedin.zookeeper.client.IZKClient, org.linkedin.zookeeper.client.IZooKeeper

public class ZKClient
extends org.linkedin.zookeeper.client.AbstractZKClient
implements org.apache.zookeeper.Watcher


Nested Class Summary
static class ZKClient.State
           
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event
 
Field Summary
protected  org.linkedin.zookeeper.client.IZooKeeperFactory _factory
           
protected  Object _lock
           
protected  org.linkedin.util.clock.Timespan _reconnectTimeout
           
protected  ZKClient.State _state
           
protected  org.linkedin.zookeeper.client.IZooKeeper _zk
           
protected  org.linkedin.util.clock.Timespan sessionTimeout
           
 
Fields inherited from class org.linkedin.zookeeper.client.AbstractZKClient
log, MODULE
 
Constructor Summary
ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory)
          Constructor
ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory, String chroot)
          Constructor
ZKClient(String connectString, org.linkedin.util.clock.Timespan sessionTimeout, org.apache.zookeeper.Watcher watcher)
          Constructor
 
Method Summary
protected  Map<Object,Boolean> callListeners(Map<Object,Boolean> history, Boolean connectedEvent)
           
protected  Object callMethod(Object obj, String name, Object... args)
           
protected  void changeState(ZKClient.State newState)
           
 org.linkedin.zookeeper.client.IZKClient chroot(String path)
           
 void close()
           
 void connect()
           
 String create(String path, byte[] data, org.apache.zookeeper.CreateMode createMode)
           
 String create(String path, org.apache.zookeeper.CreateMode createMode)
           
 String create(String path, String data, org.apache.zookeeper.CreateMode createMode)
           
 org.apache.zookeeper.data.Stat createOrSetByteWithParents(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
           
 org.apache.zookeeper.data.Stat createOrSetWithParents(String path, byte[] data, org.apache.zookeeper.CreateMode createMode)
           
 org.apache.zookeeper.data.Stat createOrSetWithParents(String path, String data, org.apache.zookeeper.CreateMode createMode)
           
 String createWithParents(String path, byte[] data, org.apache.zookeeper.CreateMode createMode)
           
 String createWithParents(String path, org.apache.zookeeper.CreateMode createMode)
           
 String createWithParents(String path, String data, org.apache.zookeeper.CreateMode createMode)
           
protected  String doGetNodeACLs(String path)
           
protected  void doStart()
           
 void fixACLs(String path, boolean recursive)
           
 String getConnectString()
           
protected  Object getField(Object obj, String... names)
           
protected  Object getField(Object obj, String name)
           
protected  Thread getSendThread()
           
protected  org.linkedin.zookeeper.client.IZooKeeper getZk()
           
 boolean isConfigured()
           
 boolean isConnected()
           
 void process(org.apache.zookeeper.WatchedEvent event)
           
 void registerListener(org.linkedin.zookeeper.client.LifecycleListener listener)
           
 void removeListener(org.linkedin.zookeeper.client.LifecycleListener listener)
           
 void setACLs(Map<String,String> acls)
           
 void setPassword(String password)
           
 void start()
           
 void testGenerateConnectionLoss()
           
protected  void tryConnect()
           
 void waitForConnected()
           
 void waitForConnected(org.linkedin.util.clock.Timespan timeout)
           
 void waitForState(ZKClient.State state, org.linkedin.util.clock.Timespan timeout)
           
 
Methods inherited from class org.linkedin.zookeeper.client.AbstractZKClient
create, createBytesNode, createBytesNodeWithParents, createOrSetWithParents, createWithParents, delete, deleteWithChildren, exists, getAllChildren, getChildren, getData, getStringData, getZKByteData, getZKByteData, getZKChildren, getZKStringData, getZKStringData, setByteData, setData
 
Methods inherited from class org.linkedin.zookeeper.client.AbstractZooKeeper
addAuthInfo, adjustPath, adjustPath, create, create, delete, delete, exists, exists, exists, exists, getACL, getACL, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getData, getData, getData, getData, getSessionId, getSessionPasswd, getSessionTimeout, getState, register, setACL, setACL, setData, setData, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.linkedin.zookeeper.client.IZooKeeper
addAuthInfo, create, create, delete, delete, exists, exists, exists, exists, getACL, getACL, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getChildren, getData, getData, getData, getData, getSessionId, getSessionPasswd, getSessionTimeout, getState, register, setACL, setACL, setData, setData, sync
 

Field Detail

_lock

protected final Object _lock

_state

protected volatile ZKClient.State _state

_factory

protected org.linkedin.zookeeper.client.IZooKeeperFactory _factory

_zk

protected org.linkedin.zookeeper.client.IZooKeeper _zk

_reconnectTimeout

protected org.linkedin.util.clock.Timespan _reconnectTimeout

sessionTimeout

protected org.linkedin.util.clock.Timespan sessionTimeout
Constructor Detail

ZKClient

public ZKClient(String connectString,
                org.linkedin.util.clock.Timespan sessionTimeout,
                org.apache.zookeeper.Watcher watcher)
Constructor


ZKClient

public ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory)
Constructor


ZKClient

public ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory,
                String chroot)
Constructor

Method Detail

start

public void start()
           throws Exception
Throws:
Exception

setACLs

public void setACLs(Map<String,String> acls)

setPassword

public void setPassword(String password)

doStart

protected void doStart()
                throws org.osgi.framework.InvalidSyntaxException,
                       org.osgi.service.cm.ConfigurationException,
                       UnsupportedEncodingException
Throws:
org.osgi.framework.InvalidSyntaxException
org.osgi.service.cm.ConfigurationException
UnsupportedEncodingException

close

public void close()
Specified by:
close in interface org.linkedin.zookeeper.client.IZooKeeper
Overrides:
close in class org.linkedin.zookeeper.client.AbstractZooKeeper

getSendThread

protected Thread getSendThread()

getField

protected Object getField(Object obj,
                          String... names)
                   throws Exception
Throws:
Exception

getField

protected Object getField(Object obj,
                          String name)
                   throws Exception
Throws:
Exception

changeState

protected void changeState(ZKClient.State newState)

testGenerateConnectionLoss

public void testGenerateConnectionLoss()
                                throws Exception
Throws:
Exception

callMethod

protected Object callMethod(Object obj,
                            String name,
                            Object... args)
                     throws Exception
Throws:
Exception

tryConnect

protected void tryConnect()

connect

public void connect()
             throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

process

public void process(org.apache.zookeeper.WatchedEvent event)
Specified by:
process in interface org.apache.zookeeper.Watcher

getZk

protected org.linkedin.zookeeper.client.IZooKeeper getZk()
Specified by:
getZk in class org.linkedin.zookeeper.client.AbstractZooKeeper

waitForConnected

public void waitForConnected(org.linkedin.util.clock.Timespan timeout)
                      throws InterruptedException,
                             TimeoutException
Throws:
InterruptedException
TimeoutException

waitForConnected

public void waitForConnected()
                      throws InterruptedException,
                             TimeoutException
Throws:
InterruptedException
TimeoutException

waitForState

public void waitForState(ZKClient.State state,
                         org.linkedin.util.clock.Timespan timeout)
                  throws TimeoutException,
                         InterruptedException
Throws:
TimeoutException
InterruptedException

registerListener

public void registerListener(org.linkedin.zookeeper.client.LifecycleListener listener)
Specified by:
registerListener in interface org.linkedin.zookeeper.client.IZKClient

removeListener

public void removeListener(org.linkedin.zookeeper.client.LifecycleListener listener)
Specified by:
removeListener in interface org.linkedin.zookeeper.client.IZKClient

chroot

public org.linkedin.zookeeper.client.IZKClient chroot(String path)
Specified by:
chroot in interface org.linkedin.zookeeper.client.IZKClient

isConnected

public boolean isConnected()
Specified by:
isConnected in interface org.linkedin.zookeeper.client.IZKClient

isConfigured

public boolean isConfigured()

getConnectString

public String getConnectString()
Specified by:
getConnectString in interface org.linkedin.zookeeper.client.IZKClient

callListeners

protected Map<Object,Boolean> callListeners(Map<Object,Boolean> history,
                                            Boolean connectedEvent)

createOrSetByteWithParents

public org.apache.zookeeper.data.Stat createOrSetByteWithParents(String path,
                                                                 byte[] data,
                                                                 List<org.apache.zookeeper.data.ACL> acl,
                                                                 org.apache.zookeeper.CreateMode createMode)
                                                          throws InterruptedException,
                                                                 org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

create

public String create(String path,
                     org.apache.zookeeper.CreateMode createMode)
              throws InterruptedException,
                     org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

create

public String create(String path,
                     String data,
                     org.apache.zookeeper.CreateMode createMode)
              throws InterruptedException,
                     org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

create

public String create(String path,
                     byte[] data,
                     org.apache.zookeeper.CreateMode createMode)
              throws InterruptedException,
                     org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

createWithParents

public String createWithParents(String path,
                                org.apache.zookeeper.CreateMode createMode)
                         throws InterruptedException,
                                org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

createWithParents

public String createWithParents(String path,
                                String data,
                                org.apache.zookeeper.CreateMode createMode)
                         throws InterruptedException,
                                org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

createWithParents

public String createWithParents(String path,
                                byte[] data,
                                org.apache.zookeeper.CreateMode createMode)
                         throws InterruptedException,
                                org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

createOrSetWithParents

public org.apache.zookeeper.data.Stat createOrSetWithParents(String path,
                                                             String data,
                                                             org.apache.zookeeper.CreateMode createMode)
                                                      throws InterruptedException,
                                                             org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

createOrSetWithParents

public org.apache.zookeeper.data.Stat createOrSetWithParents(String path,
                                                             byte[] data,
                                                             org.apache.zookeeper.CreateMode createMode)
                                                      throws InterruptedException,
                                                             org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

fixACLs

public void fixACLs(String path,
                    boolean recursive)
             throws InterruptedException,
                    org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

doGetNodeACLs

protected String doGetNodeACLs(String path)


Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.