Book Image

Apache ZooKeeper Essentials

By : Saurav Haloi
Book Image

Apache ZooKeeper Essentials

By: Saurav Haloi

Overview of this book

Table of Contents (14 chapters)
Apache ZooKeeper Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Performing Common Distributed System Tasks
Index

The ZooKeeper operations


ZooKeeper's data model and its API support the following nine basic operations:

Operation

Description

create

Creates a znode in a specified path of the ZooKeeper namespace

delete

Deletes a znode from a specified path of the ZooKeeper namespace

exists

Checks if a znode exists in the path

getChildren

Gets a list of children of a znode

getData

Gets the data associated with a znode

setData

Sets/writes data into the data field of a znode

getACL

Gets the ACL of a znode

setACL

Sets the ACL in a znode

sync

Synchronizes a client's view of a znode with ZooKeeper

Let's look at the ZooKeeper operations mentioned in the preceding table using ZooKeeper Java shell:

  1. Create a znode called root with ThisIsTheRootNode as its data:

    [zk: localhost(CONNECTED) 0] create /root "ThisIsTheRootNode"
    Created /root
    
  2. Get the content of the just created znode root:

    [zk: localhost(CONNECTED) 1] get /root
    "ThisIsTheRootNode"
    …… ……
    …… ……
    
  3. Create a child znode child...