知识库--Zookeeper API Overview(59)

来源:互联网 发布:淘宝代运营骗局 编辑:程序博客网 时间:2024/05/18 06:25

Zookeeper API Overview
Znodes may or may not contain data. If a znode contains any data, the data is stored as a byte array. The exact fomat of the byte array is specific to each application, and ZooKeeper does not directly provide support to parse it. Serialization packages such as Protocol Buffers, Thrift, Avro, and MessagePack may be handy for dealing with the format of the data stored in znodes, but sometimes string encoding such as UTF-8 or ASCII suffice.

The ZooKeeper API exposes the following operations:

create /path data    Creates a znode named with /path and containing datadelete /path    Deletes the znode /pathexists /path    Checks whether /path existssetData /path data    Sets the data of znode /path to datagetData /path    Returns the data in /pathgetChildren /path    Returns the list of children under /path

One important note is that ZooKeeper does not allow partial writes or reads of the znode data. When setting the data of a znode or reading it, the content of the znode is replaced or read entirely.

ZooKeeper clients connect to a ZooKeeper service and establish a session through which they make API calls. If you are really anxious to use ZooKeeper, skip to “Sessions”, which explains how to run some ZooKeeper commands from a command shell.

0 0
原创粉丝点击