Zookeeper internal implementation of distributed data consistency (the underlying system model) (a)

:( Zookeeper several concepts of these concepts will next write Zookeeper's internal workflow)

  • Data Model
  • Node characteristics
  • version
  • Watcher
  • ACL 

<1> Data Model :

  Zookeeper view hot like Unix file systems. But it does not introduce new directories and files related concepts; but the use of the concept of "data node", called ZNode;

  Znode ZK is the smallest unit of data, the data can be stored on each znode, you can mount the child node; i.e. the formation of a spatial hierarchical tree;

     Transaction ID: ZK, the transaction means capable of changing an operation state zk server, typically including creating and deleting data node, the data node and updates the client session creation and invalidation operation; for each transaction request, zk are assigned a globally unique transaction ID, represented by ZXID, is a 64 bit number; each corresponding to a transaction ZXID operation;

<2> node features:

  Each data node is ZK life cycle; depending on the type of data nodes;

  It can be divided into node types: Node persistence, temporary node, the node order;

  In the creation process node, it can be combined, so there are four combinations:

    (1) persistent node: The node Once created, ZK will always exist on the server until the delete operation to remove the active node;

    (2) persistent order of nodes: ZK, each parent node to its child node maintains a first stage of a sequence, the order for each node record.

    (3) Temporary Node: Life Cycle and client sessions temporary node bound together, the client session expires, the node is automatically cleaned up. (Client fails non-TCP connection is broken, the other can not be based on the temporary section

            Point create a child node).

    (4) the temporal order nodes: node characteristics similar sequence and durable;

     Status information: the node data zk for writing data and the sub-node creates two operation; some status Description:

      <1> czxid: Create ZXID: indicates the time of the transaction ID data node is created;

      <2> mzxid: Modified ZXID: represents the transaction when the node was last updated;

      <3> ctime: the node was created.

        version, cversion, aversion continue to introduce other subsequent state attribute

<3> version :( distributed data retention atomicity operation)

  zk version introduced the concept: each data node has three types of version information:

    (1) version: the version number of the data content of the current node;

    (2) cversion: current version number of the data sub-node;

    (3) aversion: the current data node ACL change the version number;

    To version as an example: a data node / zk is created after the node version value is 0 , representing been updated 0 times since its inception node ;

     Distributed areas - Lock: an optimistic locking transaction control is divided into three stages: data read, write verification, data is written; write to check is the key to the whole optimistic lock control. In writing verification stage, transaction data checks if there are other matters to modify the data, ensure data consistency in the reading stage; in zk using a version number of this version to achieve this. Get the current version and the version by contrast, to ensure the two versions match;

<4> Watcher and <5> ACL more content, subsequent chapters continue to introduce!

      

Guess you like

Origin www.cnblogs.com/startelk/p/11518992.html