@InterfaceAudience.Private public class ChaosZKClient extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ChaosZKClient.TaskObject |
Modifier and Type | Field and Description |
---|---|
private static String |
CHAOS_AGENT_PARENT_ZNODE |
private static String |
CHAOS_AGENT_STATUS_ZNODE |
private static String |
CONNECTION_LOSS |
(package private) org.apache.zookeeper.AsyncCallback.DataCallback |
getStatusCallback |
private static org.slf4j.Logger |
LOG |
private String |
quorum |
private static int |
SESSION_TIMEOUT_ZK |
(package private) org.apache.zookeeper.AsyncCallback.StatCallback |
setStatusWatchCallback |
(package private) org.apache.zookeeper.Watcher |
setStatusWatcher
Watcher to get notification whenever status of task changes.
|
(package private) org.apache.zookeeper.AsyncCallback.StringCallback |
submitTaskCallback |
private static String |
TASK_BOOLEAN_FALSE |
private static String |
TASK_BOOLEAN_TRUE |
private static String |
TASK_COMPLETION_STRING |
private static String |
TASK_ERROR_STRING |
private static int |
TASK_EXECUTION_TIMEOUT |
private static String |
TASK_PREFIX |
(package private) org.apache.zookeeper.AsyncCallback.VoidCallback |
taskDeleteCallback |
private String |
taskStatus |
private org.apache.zookeeper.ZooKeeper |
zk |
private static String |
ZNODE_PATH_SEPARATOR |
Constructor and Description |
---|
ChaosZKClient(String quorum) |
Modifier and Type | Method and Description |
---|---|
void |
createNewZKConnection()
Creates connection with ZooKeeper
|
private void |
deleteTask(String path)
Delete task after getting its status
|
private void |
getStatus(String path,
Object ctx)
To get status of task submitted
|
private boolean |
isChaosAgentRunning(String hostname)
Checks if ChaosAgent is running or not on target host by checking its ZNode.
|
private void |
recreateZKConnection() |
private void |
setStatusWatch(String name,
ChaosZKClient.TaskObject taskObject)
Set a watch on task submitted
|
String |
submitTask(ChaosZKClient.TaskObject taskObject)
Creates tasks for target hosts by creating ZNodes.
|
private static final org.slf4j.Logger LOG
private static final String CHAOS_AGENT_PARENT_ZNODE
private static final String CHAOS_AGENT_STATUS_ZNODE
private static final String ZNODE_PATH_SEPARATOR
private static final String TASK_PREFIX
private static final String TASK_ERROR_STRING
private static final String TASK_COMPLETION_STRING
private static final String TASK_BOOLEAN_TRUE
private static final String TASK_BOOLEAN_FALSE
private static final String CONNECTION_LOSS
private static final int SESSION_TIMEOUT_ZK
private static final int TASK_EXECUTION_TIMEOUT
private volatile String taskStatus
private org.apache.zookeeper.ZooKeeper zk
org.apache.zookeeper.Watcher setStatusWatcher
org.apache.zookeeper.AsyncCallback.DataCallback getStatusCallback
org.apache.zookeeper.AsyncCallback.StatCallback setStatusWatchCallback
org.apache.zookeeper.AsyncCallback.StringCallback submitTaskCallback
org.apache.zookeeper.AsyncCallback.VoidCallback taskDeleteCallback
public ChaosZKClient(String quorum)
public void createNewZKConnection() throws IOException
IOException
- when not able to create connection properlyprivate boolean isChaosAgentRunning(String hostname)
hostname
- hostname to check for chaosagentpublic String submitTask(ChaosZKClient.TaskObject taskObject)
taskObject
- Object data represents commandprivate void getStatus(String path, Object ctx)
path
- path at which to get statusctx
- path contextprivate void setStatusWatch(String name, ChaosZKClient.TaskObject taskObject)
name
- ZNode name to set a watchtaskObject
- context for ZNode nameprivate void deleteTask(String path)
path
- path to delete ZNodeprivate void recreateZKConnection()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.