Read and analyze the KFS source code of the Distributed File System (iv): RPC implementation mechanism (kfsclient)

Source: Internet
Author: User

The previous blog introduced the implementation of the RPC implementation mechanism metaserver in KFS. Next we will introduce the implementation framework of kfsclient.

Kfsclient is for the ApplicationProgramExposed interface class, which is in the ApplicationCodeIt serves as a bridge between KFS servers (metaserver and chunkserver). For a metaserver, there can only be one kfsclient. The kfsclientfactory single-State factory class is responsible for creating kfsclient for different metaservers.

Kfsclientimpl is the implementation class of kfsclient. It is responsible for interacting with the RPC requests of metaserver, such as Directory operations (Cd, mkdir, rmdir, readdir, etc ), file Operations (create, remove, rename, etc ).

Filetableentry caches the handles of opened files/directories, including the current file offset (fileposition object), file attribute information, and the set of chunkattr attributes), Chunk cache (chunkbuffer object), open mode, and so on.

Fileposition records the position of the file pointer, including two aspects: the offset of the file is converted into a chunk number and the offset within the chunk. To improve performance, the client caches read and write data in the current chunk, which is achieved through pendingchunkread, and caches the chunkbuffer in the corresponding filetableentry.

Chunkattr contains the location, Chunk ID, size, version number, and other basic attributes of the chunk server.

Chunkbuffer is a buffer set to accelerate small read/write operations. It caches a piece of data from the current chunk.

Pendingchunkread is used for pre-read operations of Chunk: It initiates read requests to the chunk server, receives data from the chunk server, and cancels read requests by resetting the connection with the chunk server.

The relationships between these classes are outlined as follows:

 

(1) kfsclient contains a proxy class kfsclientimpl;

(2) kfsclientimpl maintains a filetableentry set and records the handles of all opened files/directories;

(3) In filetableentry, the chunk attribute information (such as the chunk position) is cached through chunkattr, the current chunk information is cached through fileposition, and the current Chunk is buffered through chunkbuffer;

(4) chunkattr records attributes such as the chunk server location and Chunk ID;

(5) fileposition: Pre-read through pendingchunkread.

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.