Package org.apache.zookeeper
Class ZooKeeperMain
- java.lang.Object
-
- org.apache.zookeeper.ZooKeeperMain
-
@Public public class ZooKeeperMain extends java.lang.Object
The command line client to ZooKeeper.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.zookeeper.ZooKeeperMain.MyCommandOptionsclprotected intcommandCountprotected java.util.HashMap<java.lang.Integer,java.lang.String>historyprotected java.lang.Stringhostprotected booleanprintWatchesprotected ZooKeeperzk
-
Constructor Summary
Constructors Constructor Description ZooKeeperMain(java.lang.String[] args)ZooKeeperMain(ZooKeeper zk)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddToHistory(int i, java.lang.String cmd)Makes a list of possible completions, either for commands or for zk nodes if the token to complete begins with /protected voidconnectToZK(java.lang.String newHost)static booleancreateQuota(ZooKeeper zk, java.lang.String path, long bytes, int numNodes)this method creates a quota node for the pathstatic booleandelQuota(ZooKeeper zk, java.lang.String path, boolean bytes, boolean numNodes)this method deletes quota for a node.voidexecuteLine(java.lang.String line)static java.util.List<java.lang.String>getCommands()booleangetPrintWatches()protected java.lang.StringgetPrompt()static voidmain(java.lang.String[] args)static voidprintMessage(java.lang.String msg)protected booleanprocessCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co)protected booleanprocessZKCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co)
-
-
-
Field Detail
-
cl
protected org.apache.zookeeper.ZooKeeperMain.MyCommandOptions cl
-
history
protected java.util.HashMap<java.lang.Integer,java.lang.String> history
-
commandCount
protected int commandCount
-
printWatches
protected boolean printWatches
-
zk
protected ZooKeeper zk
-
host
protected java.lang.String host
-
-
Constructor Detail
-
ZooKeeperMain
public ZooKeeperMain(java.lang.String[] args) throws java.io.IOException, java.lang.InterruptedException- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
ZooKeeperMain
public ZooKeeperMain(ZooKeeper zk)
-
-
Method Detail
-
getPrintWatches
public boolean getPrintWatches()
-
addToHistory
protected void addToHistory(int i, java.lang.String cmd)Makes a list of possible completions, either for commands or for zk nodes if the token to complete begins with /
-
getCommands
public static java.util.List<java.lang.String> getCommands()
-
getPrompt
protected java.lang.String getPrompt()
-
printMessage
public static void printMessage(java.lang.String msg)
-
connectToZK
protected void connectToZK(java.lang.String newHost) throws java.lang.InterruptedException, java.io.IOException- Throws:
java.lang.InterruptedExceptionjava.io.IOException
-
main
public static void main(java.lang.String[] args) throws KeeperException, java.io.IOException, java.lang.InterruptedException- Throws:
KeeperExceptionjava.io.IOExceptionjava.lang.InterruptedException
-
executeLine
public void executeLine(java.lang.String line) throws java.lang.InterruptedException, java.io.IOException, KeeperException- Throws:
java.lang.InterruptedExceptionjava.io.IOExceptionKeeperException
-
delQuota
public static boolean delQuota(ZooKeeper zk, java.lang.String path, boolean bytes, boolean numNodes) throws KeeperException, java.io.IOException, java.lang.InterruptedException
this method deletes quota for a node.- Parameters:
zk- the zookeeper clientpath- the path to delete quota forbytes- true if number of bytes needs to be unsetnumNodes- true if number of nodes needs to be unset- Returns:
- true if quota deletion is successful
- Throws:
KeeperExceptionjava.io.IOExceptionjava.lang.InterruptedException
-
createQuota
public static boolean createQuota(ZooKeeper zk, java.lang.String path, long bytes, int numNodes) throws KeeperException, java.io.IOException, java.lang.InterruptedException
this method creates a quota node for the path- Parameters:
zk- the ZooKeeper clientpath- the path for which quota needs to be createdbytes- the limit of bytes on this pathnumNodes- the limit of number of nodes on this path- Returns:
- true if its successful and false if not.
- Throws:
KeeperExceptionjava.io.IOExceptionjava.lang.InterruptedException
-
processCmd
protected boolean processCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co) throws KeeperException, java.io.IOException, java.lang.InterruptedException- Throws:
KeeperExceptionjava.io.IOExceptionjava.lang.InterruptedException
-
processZKCmd
protected boolean processZKCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co) throws KeeperException, java.io.IOException, java.lang.InterruptedException- Throws:
KeeperExceptionjava.io.IOExceptionjava.lang.InterruptedException
-
-