search
HomeJavajavaTutorialZooKeeper data model

ZooKeeper data model

Jun 26, 2017 am 11:12 AM
zookeeperdataModel

ZooKeeper has a hierarchical namespace, similar to a distributed file system. The only difference between them is that each node in the namespace can have data associations as their child nodes. It's like having a file system that allows files to also be directories of files. Node paths are usually expressed as canonical, slash-separated absolute paths. They don't have relative paths. Any unicode characters included in the path must comply with the following constraints:
1) Null characters cannot be used as path names;
2) The following strings cannot be used as, which is superior to their display unfriendly, or easy to cause confusion (\u0001 - \u001F and \u007F - \u009F)
3) The following strings are not allowed. (\ud800 - uF8FF, \uFFF0 - uFFFF)
4) The "." character can be used as part of the name, but "." and ".." cannot exist alone to represent the path of a node, because ZooKeeper does not use relative path. The following examples are invalid "/a/b/./c" or "/a/b/../c"
5) The "zookeeper" keyword is reserved

ZNodes

Each node in the ZooKeeper tree structure can be called a znode. Znodes maintain a state data structure, including data change version number, ACL change and timestamp. The version number plus a timestamp allows ZooKeeper to perform cache replacement and coordinate updates. Whenever the data of a znode changes, the version number will be incremented. For example, whenever a client receives data, it also receives a version of this data. At the same time, when the client performs an update or delete operation, it must provide the data version of the changing znode node. If the version number provided by the znode does not match the actual version number of the current data, the update will fail.

Note:

In a distributed application project, the word node can be considered as a single host, a server, a member of the whole, and a client processor and so on. In the ZooKeeper documentation, znodes are considered data nodes. Servers are considered the hosts that make up the ZooKeeper service. Quorum peers are considered to be servers that form a whole, and clients are considered to be a host or a process that is using the ZooKeeper service.

Znodes are the main entities accessed by programmers. They have many features worth understanding:

Watches

Clients can listen on znodes. Changes to the znode will trigger this listener and then clear it. When a listener is triggered, ZooKeeper sends a notification to the client.

Data Access

The data stored in the znode in the namespace is read or written atomically. Read operations will read all data bytes associated with the znode, and write operations will replace all data. Each node has an Access Control List (ACL) data access list that restricts who can do what.

ZooKeeper is not designed to be used as a database or large object storage. Instead, it is used to manage and coordinate data. The source form of data can be configuration information, status information, region information, etc. A common property of the different forms of coordination data is that they are relatively small, in the range of KB bytes. Both the ZooKeeper client and server have sanity checks to ensure that znodes are less than 1M data, but the data can be much smaller than this average. Operating on relatively large data will cause the operation to take a long time, thus affecting the delay of other operations, because this extra time requires data migration through the network or storage media. If the storage of big data is necessary, the usual way to handle this data is to keep it in a large storage system, such as NFS or HDFS, and then store a pointer to the data storage location in ZooKeeper.

Ephemeral Nodes

ZooKeeper has the concept of temporary nodes. As long as the session that created the nodes is active, these nodes still exist. When the session is closed, these nodes will also be deleted. Because of this behavior, temporary nodes are not allowed to have child nodes.

Sequence Nodes -- Unique Naming (sequence node-unique naming)

When creating a node you can ask ZooKeeper to add a monotonically increasing counter at the end of the path. This counter is unique to this parent node. The format of the counter is %010d (decimal padded with zeros), formatted for simple sorting. For example "0000000001". Check out Queue Recipe for an example using this feature. Note: The counter used to store the next sequence number is a signed int maintained by the parent node. This counter will overflow when incremented beyond 2147483647 (the result should be "-2147483647").

The above is the detailed content of ZooKeeper data model. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?Mar 17, 2025 pm 05:46 PM

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management?How do I create and use custom Java libraries (JAR files) with proper versioning and dependency management?Mar 17, 2025 pm 05:45 PM

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?Mar 17, 2025 pm 05:44 PM

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?Mar 17, 2025 pm 05:43 PM

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

How does Java's classloading mechanism work, including different classloaders and their delegation models?How does Java's classloading mechanism work, including different classloaders and their delegation models?Mar 17, 2025 pm 05:35 PM

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use