Sorry this is a pretty lame question. I googled and searched on the ZK websites for a long time before I finally opted to ask here though!
When I start ZooKeeper's zkCli.sh and type help, for the create command it says:
create [-s] [-e] path data acl
What are the -s and -e for?
While that is really I need to know, I would also like to know where this information is defined, documented and/or described because as I said, I searched for a long time and was not able to find it!
thanks for any help!
zkCli.sh is a utility to connect to a local or remote ZooKeeper service and execute some commands. This article describes how zkCli.sh can be used to connect to clusters in Instaclustr.
In order to perform ZooKeeper CLI operations, at very first we have to turn on our ZooKeeper server (“bin/zkServer.sh start”). Afterward, we will also turn on ZooKeeper client (“bin/zkCli.sh”). Hence, we can perform the following operation, once the client starts: Create znodes.
create -s /myznode/xyz "x" creates a sequential node inside /myznode. The name of the znode will start with xyz followed by the running count of the current node.
The -s and -e options are for specifying sequential or ephemeral nodes.
Unfortunately, I am not sure if this is documented anywhere. Luckily, Zookeeper is open source. We can just go ahead and check the best source of truth - the code.
https://github.com/apache/zookeeper/blob/trunk/bin/zkCli.sh
The shell script is starting a new java process - org.apache.zookeeper.ZooKeeperMain. Next step might be a bit harder without some basic Java knowledge, but we can try a simple code search and see if we can spot something:
https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
It appears the actual command has its own class:
https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/cli/CreateCommand.java
Bingo. We can see the options right at the top:
options.addOption(new Option("e", false, "ephemeral"));
options.addOption(new Option("s", false, "sequential"));
Let's try to confirm this. Later on in the code, we can see all the possible cases:
CreateMode flags = CreateMode.PERSISTENT;
if(cl.hasOption("e") && cl.hasOption("s")) {
flags = CreateMode.EPHEMERAL_SEQUENTIAL;
} else if (cl.hasOption("e")) {
flags = CreateMode.EPHEMERAL;
} else if (cl.hasOption("s")) {
flags = CreateMode.PERSISTENT_SEQUENTIAL;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With