Easy Tutorial
❮ Android Tutorial Fragment Demo1 Cpp Two Colon Usage ❯

9.0 Zookeeper Node Features

Category Zookeeper Tutorial

This section introduces the node features of Zookeeper and simple usage scenarios. It is due to these node features that Zookeeper can develop different application scenarios.

1. Keys at the same level are unique

Example:

$ ls /
$ create /tutorialpro 2

If the /tutorialpro node already exists, attempting to create it again will prompt that it already exists.

2. When creating a node, the full path must be provided

Example:

$ ls /tutorialpro
$ create /tutorialpro/child 0
$ create /tutorialpro/child/ch01 0

3. Temporary nodes are cleared when the session closes

Example:

$ ls /tutorialpro
$ create -e /tutorialpro/echild 0

Check the node in another terminal:

$ ls /tutorialpro

After closing the first terminal connection with ctrl+c, the /tutorialpro/echild node disappears in the second terminal.

$ ls /tutorialpro

4. Automatically create sequential nodes

Example:

$ create -s -e /tutorialpro 0

5. Watch mechanism, monitoring node changes

The event listening mechanism is similar to the observer pattern. The watch process involves the client registering a watcher with the server on a node path, and the client also storing a specific watcher. When the node data or child nodes change, the server notifies the client, which then performs callback processing. Note: The watch event is triggered only once and then becomes invalid.

Tip: Refer to the common commands section for using the get command to watch with watch. The implementation principles of watch will be detailed in later sections.

6. The delete command can only delete layer by layer

Example:

$ ls /
$ delete /tutorialpro

Tip: Newer versions can use the deleteall command for recursive deletion.

With these various node features, Zookeeper can develop different classic application scenarios, such as:

-1.0 Zookeeper Tutorial -2.0 Zookeeper Installation and Configuration -3.0 Zookeeper Linux Server Cluster Setup Steps -4.0 Zookeeper Java Client Setup -5.0 ZooKeeper Data Model znode Structure Detailed -6.0 Zookeeper Session Basic Principles -7.0 Zookeeper Basic Client Commands Usage -8.0 Zookeeper Four-Letter Commands

WeChat Subscription

❮ Android Tutorial Fragment Demo1 Cpp Two Colon Usage ❯