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 class
ZKClient.State
-
Field Summary
Fields Modifier and Type Field Description 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
-
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 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, String data, org.apache.zookeeper.CreateMode createMode)
String
create(String path, 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, String data, org.apache.zookeeper.CreateMode createMode)
String
createWithParents(String path, 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 name)
protected Object
getField(Object obj, String... names)
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)
-
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:
close
in interfaceorg.linkedin.zookeeper.client.IZooKeeper
- Overrides:
close
in 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:
process
in interfaceorg.apache.zookeeper.Watcher
-
getZk
protected org.linkedin.zookeeper.client.IZooKeeper getZk()
- Specified by:
getZk
in classorg.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 interfaceorg.linkedin.zookeeper.client.IZKClient
-
removeListener
public void removeListener(org.linkedin.zookeeper.client.LifecycleListener listener)
- Specified by:
removeListener
in interfaceorg.linkedin.zookeeper.client.IZKClient
-
chroot
public org.linkedin.zookeeper.client.IZKClient chroot(String path)
- Specified by:
chroot
in interfaceorg.linkedin.zookeeper.client.IZKClient
-
isConnected
public boolean isConnected()
- Specified by:
isConnected
in interfaceorg.linkedin.zookeeper.client.IZKClient
-
isConfigured
public boolean isConfigured()
-
getConnectString
public String getConnectString()
- Specified by:
getConnectString
in 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:
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
-
-