The basic concept of zookeeper

Source: Internet
Author: User

Cluster roles, sessions, data nodes, versions, watcher, ACL permissions control


Cluster Role:

Leader,follower,observer

Leader server is the core of the whole zookeeper cluster working mechanism.

The follower server is the follower of the Zookeeper cluster state.

The Observer server acts as an observer.

Leader, follow design mode

Observer design mode.


session:

The connection between the client and the zookeeper server, the session in zookeeper is called sessions, the client relies on establishing a TCP long connection with the server to maintain a session, and the client first establishes a TCP connection with the server when it is started, and through this connection, The client can maintain a valid session with the server through heartbeat detection, and can also send requests to the ZK server and get a response.


Data node:

There are two types of nodes in zookeeper:

1. A machine in the cluster becomes a node;

2. Data unit Znode in the data model, divided into persistent nodes and temporary nodes

Zookeeper data model is a tree, the node of the tree is Znode.


version:

Version: The revision number of the current data node data content.

Cversion: The version number of the node in the current data section.

Aversion: Current data node ACL change version number.

Pessimistic lock and optimistic lock:

Pessimistic lock, also known as pessimistic concurrency lock, is a very strict locking policy in the database, with strong exclusivity, to avoid the data inconsistency caused by concurrent updates of the same data by different transactions, the next transaction cannot access the same resources until the last transaction is complete, and is suitable for a very competitive scene of data update.

Optimistic lock: Pessimistic lock when the transaction access to the same data must be mutual interference, so the simple rude use of exclusive access, and optimistic locking that different transactions access to the same resources is very few mutual interference, so during transaction processing does not need concurrency control, of course, optimistic lock is exclusive lock, It still has concurrency control. A typical practice for a database is to add a version field to each table, read the data before the transaction modifies the data, and, of course, read the version number, and then add the read-out version number to the condition of the UPDATE statement.


Watcher: Listener
Zookeeper allows the user to register some watcher on the specified node, and when the data node changes, the zookeeper server sends these changes to interested clients.


ACL Permission control:
The shorthand for access control lists, zookeeper uses ACL policy for permission control. Have the following permissions:

Create: Permissions for creating child nodes

READ: Get Permissions for node data and child node lists
WRITE: Permissions to update node data

Delete: Delete permissions for child nodes
ADMIN: Set permissions for node ACLs

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.