ZooKeeper源碼-1-DataTree

    ZooKeeper is a high-performance coordination service for distributed applications. It exposes common services - such as naming, configuration management, synchronization, and group services.

    Zookeeper是一個高效的分佈式應用程序協調服務。它爲分佈式應用提供一些基礎服務。比如,命名管理、配置管理、分佈式同步以及組管理等。

    ZooKeeper has a hierarchal name space, much like a distributed file system. The only difference is that each node in the namespace can have data associated with it as well as children. It is like having a file system that allows a file to also be a directory.

    ZooKeeper就像分佈式文件系統一樣,有一個層級的命名空間。與文件系統不同的是,ZooKeeper中每個節點(ZNode)除了和子節點有關聯外,還可以有自己的數據。

    ZooKeeper源碼分析首先需要了解ZooKeeper底層的數據結構。

編解碼

    ZooKeeper採用Jute作爲自己的序列化組件,其位於工程中的zookeeper-jute 模塊。在zookeeper-jute 模塊的package.html文件中這樣描述Hadoop Record I/O。

Software systems of any significant complexity require mechanisms for data interchange with the outside world. These interchanges typically involve the marshaling and unmarshaling of logical units of data to and from data streams (files, network connections, memory buffers etc.).

任何有顯著複雜性的軟件系統都需要有能與外界進行數據交換的機制。這些數據交換常常涉及邏輯數據單元與數據流之間的編解碼。

Applications usually have some code for serializing and deserializing the data types that they manipulate embedded in them. The work of serialization has several features that make automatic code generation for it worthwhile.

應用軟件通常在內部嵌套了用於編解碼這些數據類型的代碼。序列化的工作有一些顯著的特徵使得代碼可以自動生成。

ZooKeeper最初是使用了Jute作爲序列化工具,沿用至今。沒有使用目前更加通用的Avro、Thrift、Protobuf等,應該考慮到版本的兼容行以及性能上未出現瓶頸吧。zookeeper-jute模塊中的zookeeper.jute定義了ZooKeeper中的數據結構、程序中使用的協議以及一些事務定義。等分析到具體的邏輯過程時再參考。

DataTree

    ZooKeeper的數據模型是由多個節點組成的樹狀結構。

 

 

 

    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章