Zookeeper the use of combat zookeeper API

Source: Internet
Author: User
Tags zookeeper

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 = " 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.