Original link: Zookeeper Combat use zookeeper API
Several previous articles introduced the installation of zookeeper, today to see how to use the Zookeeper API to operate zookeeper. To use the Zookeeper API, you first need to create a zookeeper object to connect to the zookeeper server.
You can then manipulate the Znode node in the following ways
Create: Creates a Znode node.
Delete: Remove the Znode node, where you need to be aware that if the Znode node you want to delete has child nodes, you need to remove all child nodes first.
SetData: Modifies or sets the value of the Znode node.
GetData: Gets the value of the Znode node.
exists: Determine if a znode node is present, and return a stat object.
GetChildren: Gets the child nodes of a node.
Below look at the specific code implementation
Package my.zookeeperstudy;
Import org.apache.zookeeper.*;
Import java.util.List;
public class Test {private static final String HOST = "