Package org.apache.activemq.partition
Class ZKClient
- java.lang.Object
-
- org.linkedin.zookeeper.client.AbstractZooKeeper
-
- org.linkedin.zookeeper.client.AbstractZKClient
-
- org.apache.activemq.partition.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
Nested Classes Modifier and Type Class Description static classZKClient.State
-
Field Summary
Fields Modifier and Type Field Description protected org.linkedin.zookeeper.client.IZooKeeperFactory_factoryprotected Object_lockprotected org.linkedin.util.clock.Timespan_reconnectTimeoutprotected ZKClient.State_stateprotected org.linkedin.zookeeper.client.IZooKeeper_zkprotected org.linkedin.util.clock.TimespansessionTimeout
-
Constructor Summary
Constructors Constructor Description ZKClient(String connectString, org.linkedin.util.clock.Timespan sessionTimeout, org.apache.zookeeper.Watcher watcher)ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory)ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory, String chroot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<Object,Boolean>callListeners(Map<Object,Boolean> history, Boolean connectedEvent)protected ObjectcallMethod(Object obj, String name, Object... args)protected voidchangeState(ZKClient.State newState)org.linkedin.zookeeper.client.IZKClientchroot(String path)voidclose()voidconnect()Stringcreate(String path, byte[] data, org.apache.zookeeper.CreateMode createMode)Stringcreate(String path, String data, org.apache.zookeeper.CreateMode createMode)Stringcreate(String path, org.apache.zookeeper.CreateMode createMode)org.apache.zookeeper.data.StatcreateOrSetByteWithParents(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)org.apache.zookeeper.data.StatcreateOrSetWithParents(String path, byte[] data, org.apache.zookeeper.CreateMode createMode)org.apache.zookeeper.data.StatcreateOrSetWithParents(String path, String data, org.apache.zookeeper.CreateMode createMode)StringcreateWithParents(String path, byte[] data, org.apache.zookeeper.CreateMode createMode)StringcreateWithParents(String path, String data, org.apache.zookeeper.CreateMode createMode)StringcreateWithParents(String path, org.apache.zookeeper.CreateMode createMode)protected StringdoGetNodeACLs(String path)protected voiddoStart()voidfixACLs(String path, boolean recursive)StringgetConnectString()protected ObjectgetField(Object obj, String name)protected ObjectgetField(Object obj, String... names)protected ThreadgetSendThread()protected org.linkedin.zookeeper.client.IZooKeepergetZk()booleanisConfigured()booleanisConnected()voidprocess(org.apache.zookeeper.WatchedEvent event)voidregisterListener(org.linkedin.zookeeper.client.LifecycleListener listener)voidremoveListener(org.linkedin.zookeeper.client.LifecycleListener listener)voidsetACLs(Map<String,String> acls)voidsetPassword(String password)voidstart()voidtestGenerateConnectionLoss()protected voidtryConnect()voidwaitForConnected()voidwaitForConnected(org.linkedin.util.clock.Timespan timeout)voidwaitForState(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)
-
ZKClient
public ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory)
-
ZKClient
public ZKClient(org.linkedin.zookeeper.client.IZooKeeperFactory factory, String chroot)
-
-
Method Detail
-
setPassword
public void setPassword(String password)
-
doStart
protected void doStart() throws UnsupportedEncodingException- Throws:
UnsupportedEncodingException
-
close
public void close()
- Specified by:
closein interfaceorg.linkedin.zookeeper.client.IZooKeeper- Overrides:
closein classorg.linkedin.zookeeper.client.AbstractZooKeeper
-
getSendThread
protected Thread getSendThread()
-
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:
processin interfaceorg.apache.zookeeper.Watcher
-
getZk
protected org.linkedin.zookeeper.client.IZooKeeper getZk()
- Specified by:
getZkin classorg.linkedin.zookeeper.client.AbstractZooKeeper
-
waitForConnected
public void waitForConnected(org.linkedin.util.clock.Timespan timeout) throws InterruptedException, TimeoutException- Throws:
InterruptedExceptionTimeoutException
-
waitForConnected
public void waitForConnected() throws InterruptedException, TimeoutException- Throws:
InterruptedExceptionTimeoutException
-
waitForState
public void waitForState(ZKClient.State state, org.linkedin.util.clock.Timespan timeout) throws TimeoutException, InterruptedException
- Throws:
TimeoutExceptionInterruptedException
-
registerListener
public void registerListener(org.linkedin.zookeeper.client.LifecycleListener listener)
- Specified by:
registerListenerin interfaceorg.linkedin.zookeeper.client.IZKClient
-
removeListener
public void removeListener(org.linkedin.zookeeper.client.LifecycleListener listener)
- Specified by:
removeListenerin interfaceorg.linkedin.zookeeper.client.IZKClient
-
chroot
public org.linkedin.zookeeper.client.IZKClient chroot(String path)
- Specified by:
chrootin interfaceorg.linkedin.zookeeper.client.IZKClient
-
isConnected
public boolean isConnected()
- Specified by:
isConnectedin interfaceorg.linkedin.zookeeper.client.IZKClient
-
isConfigured
public boolean isConfigured()
-
getConnectString
public String getConnectString()
- Specified by:
getConnectStringin interfaceorg.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:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
create
public String create(String path, org.apache.zookeeper.CreateMode createMode) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
create
public String create(String path, String data, org.apache.zookeeper.CreateMode createMode) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
create
public String create(String path, byte[] data, org.apache.zookeeper.CreateMode createMode) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
createWithParents
public String createWithParents(String path, org.apache.zookeeper.CreateMode createMode) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
createWithParents
public String createWithParents(String path, String data, org.apache.zookeeper.CreateMode createMode) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
createWithParents
public String createWithParents(String path, byte[] data, org.apache.zookeeper.CreateMode createMode) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.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:
InterruptedExceptionorg.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:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
fixACLs
public void fixACLs(String path, boolean recursive) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
-