WO2015180070A1 - 一种用于分布式存储系统的数据缓存方法及装置 - Google Patents

一种用于分布式存储系统的数据缓存方法及装置 Download PDF

Info

Publication number
WO2015180070A1
WO2015180070A1 PCT/CN2014/078656 CN2014078656W WO2015180070A1 WO 2015180070 A1 WO2015180070 A1 WO 2015180070A1 CN 2014078656 W CN2014078656 W CN 2014078656W WO 2015180070 A1 WO2015180070 A1 WO 2015180070A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
cache
node
file
name
Prior art date
Application number
PCT/CN2014/078656
Other languages
English (en)
French (fr)
Inventor
李挥
郭涵
Original Assignee
北京大学深圳研究生院
深圳赛思鹏科技发展有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京大学深圳研究生院, 深圳赛思鹏科技发展有限公司 filed Critical 北京大学深圳研究生院
Priority to PCT/CN2014/078656 priority Critical patent/WO2015180070A1/zh
Priority to CN201480078749.6A priority patent/CN107111615A/zh
Publication of WO2015180070A1 publication Critical patent/WO2015180070A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • the present invention relates to a distributed storage system, and more particularly to a data caching method and apparatus for a distributed storage system.
  • Distributed File System means that the physical storage resources managed by the file system are not necessarily directly connected to the local node, but are connected to the node through the computer network.
  • the design of a distributed file system is based on the client/server model.
  • a typical network may include multiple servers for multi-user access.
  • peer-to-peer features allow some systems to play the dual role of client and server.
  • HDFS Hadoop's distributed file system.
  • HDFS was originally developed as the infrastructure for the Apache Nutch search engine project.
  • HDFS is part of the Apache Hadoop Core project. It has much in common with existing distributed file systems. But at the same time, the difference between it and other distributed file systems is also obvious.
  • HDFS is a highly fault-tolerant system that is suitable for deployment on inexpensive machines.
  • HDFS provides high-throughput data access and is ideal for applications on large-scale data sets.
  • HDFS relaxes a part of the P0SIX constraint to achieve the purpose of streaming file system data.
  • HDFS is one of the best choices for building massive data storage platforms. For example, in the video storage space, using H DFS as a storage platform has significant advantages.
  • any data flow can be added to the cache, so you can add cache on the client, use CDN cache, proxy server cache, and cache of distributed storage data nodes. Adding caches inside the distributed file system can be divided into different types of cache designs according to different needs. Depending on the location, you can add the cache to the metadata server and data node server. Depending on the physical material, you can use disk, flash, and memory as different levels of cache. Depending on the role, you can cache the metadata, retrieve the record cache, file list cache, data content cache, and more.
  • HDFS high-speed streaming
  • HDCache distributed cache structure
  • HDCache adds a caching system based on HDFS, and designs and implements a caching system on the upper layer of HDFS to provide better services for large-scale fast access in real-time cloud.
  • HDCache introduces a distributed caching mechanism into the entire system and integrates them in a loose-fitting mode for management, deployment, replacement, and upgrade without posing any hazards to HDFS itself.
  • HDCache is designed according to the traditional C/S architecture.
  • a dynamic connection library is provided on the client. All HDCache-enabled applications need to integrate dynamic connection libraries on their own clients.
  • the drawbacks are: The need to integrate the cache framework dynamic link library on the client, and the internal integration of the cache code library, making the client larger and more susceptible to software coordination failures, which will affect the customer experience; Adding a caching proxy server to the outer layer of HDFS does not improve HDFS itself, but rather a caching service built on it. This does not solve the bottleneck of HDFS's own disk read speed, but only uses the cache as a protection. From a practical point of view, this system gives a solution from an application perspective and does not improve the access performance of HDFS itself.
  • SCC Scalable and Cooperative
  • Caching Caching
  • the SCC algorithm is divided into two aspects: one is the scheduling layer algorithm, which designs a set of value models to evaluate the processing mode of the server; the other is the implementation of the caching technology.
  • SCC Scalable and Cooperative
  • This method is still several problems with this method: In a distributed storage system, when the number of clusters is large, SCC does not propose an effective strategy in terms of cache coherency; secondly, when the number is large, each node needs to be stored. All file metadata information of other nodes, a large amount of internal data exchange, will have a great impact on the system itself.
  • the technical problem to be solved by the present invention is to provide a data cache for a distributed storage system with a simple structure and small internal data exchange, which is complicated by the above-mentioned structure and may have many internal data exchange defects.
  • the technical solution adopted by the present invention to solve the technical problem thereof is: constructing a system for distributed storage a data caching method, the distributed storage system comprising a plurality of data nodes for storing data and a name node connected to the plurality of data nodes and managing the plurality of data nodes, the method comprising The following steps:
  • A) the name node uploads the configuration file into its memory and parses the configuration file
  • the name node transmits the cache information involved in the data node to the data node when shaking hands with each data node
  • the data node fetches the cache data involved and stores it in the memory of the data node according to the cache information it receives; after the data cache is completed, the data node notifies the name node at the next handshake.
  • the method further includes the following steps:
  • the client issues a read request to the name node, the name node finds that the requested data is cached, and if so, returns the cache location to the client; if not, processes according to the normal read request;
  • the client sends a data read request to the data node, and the data node searches for the local cache list after receiving the data read request, and if so, directly sends data to the client by its memory; if not, reads the disk The data is retrieved and sent to the client, and the name node cache exception is notified.
  • the configuration file is defined by the client and transmitted to the name node; the configuration file is converted into a cache policy file on the name node, and the cache policy file includes multiple representations.
  • step B) further includes:
  • step B2) determining whether the path pointed to by the object is a directory or a directory, if it is a file, performing step B3); if it is a directory, parsing it into multiple files and executing step B3);
  • B3) constructing a metadata representing the cache file, the metadata including a file description, all data block descriptions included in the file, a number of cache shares, and a cache period; wherein the data block description includes a cache path thereof, a description of the data node at the name node, a block number, a block length, and a data block status flag thereof; B4) Repeat steps B1) - B3 above until all objects in the cache policy file have been processed.
  • step B) further includes the following steps:
  • the data block cache paths in all the data block descriptions in the metadata obtained by processing each of the objects are collected together to obtain a list of cached data blocks that need to be cached for this scan.
  • step C) further includes:
  • step D) further includes:
  • D1 Get all the data block cache paths obtained in the current handshake, and sequentially read the data block according to each data block cache path, and cache it in the memory of the data node; if no data block or memory space is found Limited cannot be cached, then mark the data block cache failure and process the next data block cache path;
  • the present invention also relates to an apparatus for implementing the above method, the distributed storage system comprising a plurality of data nodes for storing data and a name connected to the plurality of data nodes via a network and managing the plurality of data nodes Node, the device includes:
  • a profile parsing module for uploading a configuration file to its memory at a name node and parsing the configuration file;
  • the cache information obtaining module is configured to obtain information about the cache in the configuration file, where the information includes a cache path, a cache mode, a number of copies, and a condition for canceling the cache;
  • a cache information sending module configured to enable a name node to transmit cache information related to the data node to the data node when shaking hands with each data node;
  • a cache implementation module configured to: cause the data node to take out cache data involved by the data node and store the cache information received in the data node in the memory of the data node; after completing the data cache, the data node notifies the name node when the next handshake .
  • the read request module is configured to enable the client to issue a read request to the name node, and the name node finds that the requested data is cached, and if yes, returns the cache location to the client; if not, processes according to the normal read request ;
  • Cache search module configured to enable a client to send a data read request to the data node, and the data node searches for a local cache list after receiving the data read request, and if yes, directly sends data to the client by using the memory; , reading its disk to obtain data and sending it to the client, and notifying the name node of the cache exception.
  • the cache information obtaining module further includes:
  • An object obtaining unit configured to obtain an object in the cache policy file
  • the path judging unit is configured to determine whether the path pointed to by the object is a directory or a directory, and if it is a file, call the metadata forming unit; if it is a directory, parse the file into a plurality of files and call the metadata forming unit;
  • a metadata forming unit configured to construct a metadata representing the cache file, where the metadata includes a file description, all data block descriptions included in the file, a number of cache shares, and a cache period; wherein the data block description includes a cache path, a description of the data node on which the node is located, a block number, a block length, and a data block status flag thereof;
  • An object judging unit configured to determine whether all objects in the cache policy file are processed; a data block list forming unit: a data block buffer path in all data block descriptions in the metadata obtained by processing each of the objects Collect together, get a list of cached data blocks for this scan.
  • the data caching method and apparatus for a distributed storage system embodying the present invention have the following beneficial effects: Since the utility configuration file determines the parameters of the file to be cached, and parses the configuration file at the name node, the element indicating the cache file is obtained. Data; when the name node and the data node handshake, the relevant parameters representing the data block in the metadata are transmitted to the data node, and the data node reads the data block indicated by the parameter from the disk and caches it in the memory of the data node. In this way, neither the modification of the structure of the HDFS itself nor the problem of related data caching is solved. Therefore, its structure is simple and internal data exchange is less.
  • FIG. 1 is a cache method of a data caching method and apparatus for a distributed storage system according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a logical structure of a portion of a processing node on a name node in the embodiment
  • FIG. 3 is a schematic diagram of a state transition of a cached data block in the embodiment
  • Figure 4 is a schematic view showing the structure of the apparatus in the embodiment.
  • the method includes the following steps:
  • Step S11 uploading the configuration file to its memory and parsing:
  • the distributed storage system includes a plurality of data nodes (DNs) for storing data and connecting with the plurality of data nodes through the network.
  • a name node (Name Node, NN) of the plurality of data nodes is managed, and the client obtains data stored on the data node by using the name node.
  • the client makes a read request to the name node to inform the name node of the file to be read; the name node finds the storage location of the file, and returns the location to the read request.
  • the client after obtaining the information, the client makes a read request to the data node storing the file (or the data block constituting the file), and the data node receiving the request reads the file or the data block, and returns Give the client to complete the data or file acquisition.
  • the steps of reading the file are substantially the same. Only when the file is cached, the name node returns to the client not the storage location of the file but the cache location. The data node does not directly read the file but directly caches the directory if it finds the cache directory. The file is sent to the client. In this way, the file cache is realized without increasing the internal data transmission to the maximum extent, which improves the speed of obtaining the file and improves the user experience.
  • the cache of the files is first implemented, and the cached files are specified by a configuration file written by the client.
  • the memory of all data nodes (DNs) is integrated into a memory pool, which is exposed to the client through configuration, so that the client can cache the data stored in the HDFS through the configuration file.
  • HDFS itself is a Master/Slave structure. All requests require NN (Namenode name node) to handle the processing. This provides convenience for the unified processing of data. It can specify whether to cache while storing. For reading data. Reading from DN's memory is obviously much faster than reading from disk, making the entire system more efficient.
  • the client compiles on the client according to the requirements.
  • the configuration file is written in xml.
  • the parameters that can be specified include: cache path, cache period, number of caches (adjustable according to the frequency of use of the file), cache replacement policy, cache cleanup strategy, and so on.
  • the prepared configuration file can be transferred to the name node or read by the name node. Since the HDFS configuration information is not large, reading the memory completely will not affect the system performance. Therefore, in this implementation, a simple DOM (document) is used.
  • the object model parses the configuration information, then constructs a reasonable data structure to hold the information, and constructs a series of worker threads to ensure that the entire mechanism can work smoothly.
  • Step S12 obtains the metadata, and represents a description list of the data block:
  • the data node parses the configuration file in its memory, constructs a reasonable data structure, and supplies it to the next process for processing.
  • an object that is, CachePolicy
  • CachePolicy is defined by the HDFS API set on the data node, and the file path, the number of cache shares, the replacement policy, the declaration period, and the like read from the configuration information are saved in the object.
  • the HDFS API call or define a periodic scan thread ConfigMonitor, read the scan cycle from the HDFS's own configuration file hdfs-site.xml (the scan cycle is customized), according to the above cycle settings, The configuration information is read once per cycle.
  • a new CachePolicy needs to be generated.
  • the files stored on them may be added or deleted. The change, so even if all the parameters of a path have not changed, the CachePolicy object is still constructed.
  • the cache is managed by the CacheMangaer on the data node.
  • CacheMangaer runs in a Facade mode, which aggregates all relevant data structures and threads and handles all cache-related transactions.
  • each of the files that need to be cached and the data blocks that each file stores on each data node are separately described. These descriptions represent the cache parameters for a file or block of data. These descriptions are saved on the name node to form a list.
  • the name node and the related data node shake hands they are sent to the data node.
  • Each file that needs to be cached has a corresponding metadata representation CacheFile, which contains the INodeFile of the file (the description of the file metadata), all cached data blocks, and the number of caches, lifetimes, etc. obtained from the CachePolicy.
  • CacheFile contains the INodeFile of the file (the description of the file metadata), all cached data blocks, and the number of caches, lifetimes, etc. obtained from the CachePolicy.
  • a file is divided into multiple data blocks in HDFS. Wherein, each data block also corresponds to a description object CachedBlock, which contains the data block where the data block is located.
  • the description object of the data block includes four status flags: isSend, isCached, willDelete, isDeleted, These flags indicate that the state of the data block is the four states of already sent, cached, waiting to be deleted, and deleted. These states represent the entire activity period of a cache block. See Figure 3 for the state transitions of the buffered data blocks.
  • the processing process of the name node for the configuration file in its memory is: obtaining an object in the cache policy file (or a parameter or a parameter set described in the configuration file for a cache file); Determine whether the path pointed to by the object is a file or a directory (ie, determine whether the path is a file or a directory or folder), if it is a file, build metadata indicating the file; if it is a directory , parse it into multiple files and build metadata representing each file.
  • the metadata includes a file description, all data block descriptions included in the file, a cache number, and a cache period.
  • the data block description includes a cache path, and the data node where the data node is located on the name node. Description, block number, block length and its data block status flag; that is, the metadata includes not only the description of the file, but also the description of all the data blocks that make up the file. Since a file is composed of multiple data blocks in HDFS, and these data blocks may not be stored in the same data node, for metadata, the data block description is a very important part of the metadata. Or a key part.
  • a configuration file may include cache parameters for a plurality of files, and therefore, a plurality of objects may be generated after one configuration file is processed.
  • the steps described above are the processing of an object. When there are multiple objects, each object is processed in turn according to the above steps, until all the objects in the cache policy file are processed.
  • the internal logical structure of the portion of the name node that processes the configuration file is as shown in FIG. 2.
  • the TriggerMonitor thread is periodically read from the ConfigMonitor thread. Take the CachePolicy object, and then parse the path specified by a CachePolicy. If the specified path is a file, then a CachePolicy corresponds to a CacheFile; if the specified path is a directory, then a CachePolicy resolves to multiple CacheFiles.
  • the TriggerMonitor thread After the TriggerMonitor thread reads the object CachePolicy, it creates a series of CacheFiles. By comparing with the previous history, the new CacheFile that has not appeared is added to the two file collections at the same time; the updated CacheFile (that is, the cached module has been recorded). , but the strategy has changed) to update the state in the entire cache file collection, and thus update the state of all relevant cachedBlocks, and add to the current cache list; there will be no changes to the file (because all reads from CachePolicy are all Files under the path must be duplicated) ignored.
  • the generated cache block CachedBlock is added to the CacheFile, and on the other hand is added to a proprietary data set waitingPool.
  • This data structure is used exclusively. To save all the data blocks that need to be cached, it is actually a priority queue; in this embodiment, it is considered that the number of cache shares is successively decreased from 1 to 3, that is, the smaller the number of cache shares, the higher the priority.
  • Step S13 Extract the set number of descriptions in the table and send them to the data node during the handshake:
  • TriggerMonitor reads all the files on the cache path and processes them into CacheFile and CachedBlock, the next step.
  • the work is handled by CacheMonitor.
  • the main function of this thread is to add the uncached data block tag in the waitingPool to the DND, and wait for the next time the name node passes the command to the data node, and send the cache command of these blocks to the corresponding data node.
  • This thread (CacheMonitor) periodically reads the specified number of blocks (maxCachedNum), calls the DND add method, and adds it to its corresponding queue.
  • the block information that has been sent is deleted from the DND. That is, the data blocks actually exist in the waitingPool and cachedPool, are sent and stored in the DND. Just mark it. DND is not managed regardless of whether the data node successfully caches these data blocks.
  • Step S14 performs caching on the specified data block in its memory:
  • the data node scans the local FSDataSet to find The corresponding block, create its cache backup in memory. If the block is not found, the created RPC (Remote Procedure Call) method reportBadCache() is called directly to tell the name node that the block is not found.
  • the name node checks the number of caches. If there is only 1 copy, then look for other DNDs of the block and Continue to try to cache, and call HDFS other native threads to do data Repair work; the above 1 refers to the number of copies of the cache.
  • the original HDFS data block is saved by 3 copies by default, and each copy is written on a different DN disk, so there are 3 DNDs corresponding to the NN. That is, if the purpose is to cache a data block once, and the first time the NN finds a DND, but the corresponding DN cannot be cached, then another DND of the data block is searched, and then sent to the corresponding DN for buffer processing. Until 3 DNDs have been tried and no cache is successful, it indicates that the data block has been corrupted in the cache system.
  • the NN receives three reports that cannot cache a data block, it means that the data block is completely damaged, and the file where the data block is located is damaged, so delete it directly. If the block is found, there is not enough disk space to be cached, then it is reported to the name node, and the next DND of the block is selected for trial; if the cache is successfully cached, the name node success flag is reported, and the name node modifies the status of the block and the corresponding management work.
  • Step S15 records the execution cache: In this step, the data node retrieves the data block buffer by the method described above.
  • Step S16 returns the execution condition when the handshake is again:
  • the data node shakes hands with the name node again, the data node sends the execution result of the stored data block cache instruction received by the last handshake back to the name node, if one If the data block is successfully cached, it is necessary to determine whether other data blocks of the file in which it is located are successfully cached. Only when all the data blocks constituting a file are successfully cached can the file cache be successfully determined and the state of the file be modified. If one data block is not successfully cached, the data needs to be processed or repaired according to the method in step S14. Piece.
  • the data buffering further includes the step of reading it.
  • the client requests to read the file, it first sends a read request to the name node.
  • the name node first checks whether the cache list contains the file. If it contains, directly wraps its internal cachedBlock[] and returns Give the client a set of data block location information (this set of data blocks constitutes the file to be read out), this process is transparent to the client; if the cache file does not exist, then according to the normal data reading process (ie The process of reading files in a cached HDFS system is not used in the prior art).
  • the client obtains the specific location of the data block, it directly sends a read request to the data node DN where the location is located, requesting to read the data.
  • the DN After receiving the request, the DN checks whether the data block exists in the cache list. If it exists, it directly returns to the memory file to implement data reading. Otherwise, the normal read process is called to read from the disk, and the whole process is transparent to the client. of.
  • the cache data block is described on both the NN and the DN side, so a certain mechanism is needed to ensure that the entire process proceeds smoothly.
  • the core CacheMananer on the NN side a large number of methods for processing the feedback information of the DN end are included, and the data block is successfully cached, the failed cache, the memory is insufficient, and the block cannot be found. At the same time, two threads are used.
  • One ClearMonitor is used to periodically clean up expired cache files; a HandleMonitor is used to periodically check whether a file is successfully cached. Only when a file is successfully cached, it starts to count down the cache; and if it is determined whether a file is successfully cached, based on the fact that all the data blocks of its subordinates are successfully cached, it can be considered that the file is successfully cached.
  • a data cache apparatus for a distributed storage system, where the distributed storage system includes a plurality of data nodes for storing data and a plurality of data nodes connected through a network Managing the name nodes of the plurality of data nodes; as shown in FIG. 4, the apparatus includes a configuration file parsing module 41, a cache information obtaining module 42, a cache information transmitting module 43, a cache implementing module 44, a read request module 45, and a cache lookup module.
  • the configuration file parsing module 41 is configured to upload a configuration file to the memory in the name node and parse the configuration file.
  • the cache information obtaining module 42 is configured to obtain information about the cache in the configuration file, where the information includes a cache path.
  • the cache information sending module 43 is configured to enable the name node to transmit the cache information involved in the data node to the data node when shaking hands with the data nodes;
  • the cache implementation module 44 is configured to: Causing the data node to take the cached data it involves and receive it according to it The cache information is stored in the memory of the data node; after the data cache is completed, the data node notifies the name node at the next handshake;
  • the read request module 45 is configured to cause the client to issue a read request to the name node, the name The node finds that the requested data is cached, if any, returns the cache location to the client; if not, processes according to the normal read request;
  • the cache lookup module 46 is configured to enable the client to send a data read request to the data node, the data node is After receiving the data read request, searching for a local cache list, if any, directly sending data to the client by its memory; if not, reading its disk to obtain data concurrently
  • the cache information obtaining module 42 further includes an object obtaining unit 421, a path determining unit 422, a metadata forming unit 423, an object determining unit 424, and a data block list forming unit 425.
  • the path determining unit 422 is configured to determine whether the path pointed to by the object is one or a directory, and if it is a file, call a metadata forming unit; if it is a directory, parse it into The metadata forming unit is called after the plurality of files; the metadata forming unit 423 is configured to construct a metadata representing the cache file, where the metadata includes a file description, all data block descriptions included in the file, the number of caches, and the cache.
  • the data block description includes a cache path, a description of the data node where the data node is located on the name node, a block number, a block length, and a data block status flag.
  • the object determining unit 424 is configured to determine whether the process is completed. All objects in the cache policy file; data block Table forming unit 425 for the data blocks for all data blocks of cache ways described metadata processing each of the object obtained in diameter together, to present scan data to cache block list.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明涉及一种用于分布式存储系统的数据缓存方法,包括如下步骤:名称节点上载配置文件到其内存中并解析所述配置文件;得到配置文件中关于缓存的信息,所述信息包括缓存路径、缓存方式、副本数量以及取消缓存的条件;名称节点在与各个数据节点握手时将该数据节点涉及的缓存信息传输给所述数据节点;所述数据节点取出其涉及的缓存数据并按照其接收到的缓存信息存储在该数据节点的内存中;完成数据缓存后,数据节点在下一次握手时通知所述名称节点。本发明还涉及一种实现上述方法的装置。实施本发明的用于分布式存储系统的数据缓存方法及装置,具有以下有益效果:其结构简单、内部的数据交换较少。

Description

一种用于分布式存储系统的数据緩存方法及装置
技术领域
本发明涉及分布式存储系统, 更具体地说, 涉及一种用于分布式存储系统 的数据緩存方法及装置。
背景技术
当前, 对于信息的存储和处理方式在不断演变。 海量数据的存储和计算无 法在单个计算机上完成, 分布式存储和计算系统逐渐成为主流。 在使用分布式 存储系统时, 往往需要一款优秀的分布式文件系统来对存储进行管理。 分布式 文件系统( Distributed File System )是指文件系统管理的物理存储资源不一定直 接连接在本地节点上, 而是通过计算机网络与节点相连。 分布式文件系统的设 计基于客户机 /服务器模式。一个典型的网络可能包括多个供多用户访问的服务 器。 另外, 对等特性允许一些系统扮演客户机和服务器的双重角色。 近年来诞 生了许多优秀的分布式文件系统, 诸如 Google的 GFS、 openStack的 swift以及 Hadoop 的 HDFS等等, 都是优秀的分布式文件系统实现方式。 例如, Hadoop 的分布式文件系统。 HDFS在最开始是作为 Apache Nutch搜索引擎项目的基础 架构而开发的。 HDFS是 Apache Hadoop Core项目的一部分。 它和现有的分布 式文件系统有很多共同点。 但同时, 它和其他的分布式文件系统的区别也是很 明显的。 HDFS是一个高度容错性的系统, 适合部署在廉价的机器上。 HDFS能 提供高吞吐量的数据访问,非常适合大规模数据集上的应用。 HDFS放宽了一部 分 P0SIX约束, 来实现流式读取文件系统数据的目的。 作为一个日趋成熟的分 布式文件系统, HDFS是构建海量数据存储平台最佳选择之一。 例如, 在视频存 储领域, 使用 H DFS作为存储平台, 有显著优点。
一般来讲, 在分布式存储系统中, 使用緩存来对系统各个环节的加速随处 可见。 从广义角度来说, 任何数据流经过的地方都可以添加緩存, 因此可以在 客户端添加緩存、 使用 CDN緩存、 代理服务器緩存以及分布式存储数据节点 的緩存。 在分布式文件系统内部添加緩存, 又可以根据不同的需要分为不同类 型的緩存设计。 针对位置不同, 可以将緩存加入到元数据服务器、 数据节点服 务器; 根据物理材质不同, 可以使用磁盘、 闪存、 内存作为不同级别的緩存工 具; 根据作用不同, 可以对元数据緩存、 检索记录緩存、 文件列表緩存、 数据 内容緩存等等。
例如,有人提出了一种带有分布式緩存结构的 HDFS系统,叫做 HDCache。
HDCache基于 HDFS添加了一套緩存系统, 在 HDFS上层设计和实现一套緩存体 系, 针对实时云端大规模的快速存取提供更好的服务。 HDCache将一套分布式 緩存机制引入整个系统, 以松輛合的模式整合在一起, 便于管理、 部署、 替换 和升级, 而不会给 HDFS本身带来任何隐患。 HDCache的设计按照传统的 C/S架 构, 在客户端提供了一个动态连接库, 所有使用 HDCache的应用程序需要在自 己的客户端集成动态连接库; 在服务器端, 每一台部署 HDCache System的服 务器都会运行一个守护进程。 在 HDCache中, 其缺陷为: 需要在客户端集成緩 存框架动态连接库, 内部集成緩存代码库, 使得客户端更庞大, 也更容易出现 软件协调故障, 对客户体验会造成影响; 此外, 该系统在 HDFS外层添加緩存 代理服务器, 对 HDFS本身并没有改进, 而是构建于其上的緩存服务。 这并不 能解决 HDFS本身磁盘读取速度低的瓶颈, 只是在外层用緩存作为保护。 从实 现角度来说, 这套系统是从应用角度来给出一个解决方案, 并没有改善 HDFS 本身的存取性能。
又如, 有人提出了一种在不需要管理节点的情况下, 在松輛合的 VOD系统 中有效的使用分布式緩存的方法, 并提出了一种新的緩存算法, 叫做 SCC ( Scalable and Cooperative Caching ) 。 SCC算法分为两个方面: 一个是调度层 次的算法, 它设计了一套价值模型来评估服务器的处理模式; 另一个是緩存技 术的实现。 但是, 这种方法依然存在几个问题: 在分布式存储系统里, 当集群 数量很大的时候, SCC并没有在緩存一致性方面提出有效策略; 其次, 数量很 大时, 每一个节点需要存储其他节点的全部文件元数据信息, 大量的内部数据 交换, 对系统本身的会造成很大影响。
发明内容
本发明要解决的技术问题在于, 针对现有技术的上述结构复杂、 可能存在 许多内部数据交换的缺陷, 提供一种结构简单、 内部数据交换较小的一种用于 分布式存储系统的数据緩存方法及装置。
本发明解决其技术问题所釆用的技术方案是: 构造一种用于分布式存储系 统的数据緩存方法, 所述分布式存储系统包括多个用于存储数据的数据节点和 与所述多个数据节点通过网络连接的并管理所述多个数据节点的名称节点, 所 述方法包括如下步骤:
A )名称节点上载配置文件到其内存中并解析所述配置文件;
B )得到配置文件中关于緩存的信息, 所述信息包括緩存路径、 緩存 方式、 副本数量以及取消緩存的条件;
C )名称节点在与各个数据节点握手时将该数据节点涉及的緩存信息 传输给所述数据节点;
D ) 所述数据节点取出其涉及的緩存数据并按照其接收到的緩存信息 存储在该数据节点的内存中; 完成数据緩存后, 数据节点在下一次握手时通知 所述名称节点。
更进一步地, 还包括如下步骤:
E )客户端发出读请求到所述名称节点, 所述名称节点查找其要求的 数据是有緩存,如有,返回緩存位置到客户端;如无,按照正常的读请求处理;
F )客户端向数据节点发送数据读请求, 数据节点在收到所述数据读 请求后查找本地緩存列表,如有,直接由其内存发送数据给所述客户端;如无, 读取其磁盘取得数据并发送给所述客户端, 同时通知所述名称节点緩存异常。
更进一步地, 所述配置文件是由客户端定义并传输给所述名称节点的; 所 述配置文件在所述名称节点上被转换为一个緩存策略文件, 所述緩存策略文件 中包括多个表示緩存文件的对象; 所述名称节点通过周期性的扫描线程在每个 周期上取得并替换其内存中的緩存策略文件。
更进一步地, 所述步骤 B )进一步包括:
B1 )取得所述緩存策略文件中的一个对象;
B2 )判断所述对象指向的路径是一个还是一个目录,如果是一个文件, 执行步骤 B3 ); 如果是一个目录, 将其解析为多个文件后执行步骤 B3 );
B3 )构建一个表示所述緩存文件的元数据,所述元数据包括文件描述、 文件所包括的所有数据块描述、 緩存份数及緩存周期; 其中, 所述数据块描述 包括其緩存路径、 其所在数据节点在所述名称节点上的描述、 块序号、 块长度 及其数据块状态标志; B4 )重复上述步骤 Bl ) -B3 )直到处理完所述緩存策略文件中的所有 对象。
更进一步地, 所述步骤 B ) 中还包括如下步骤:
将处理每个所述对象得到的元数据中所有数据块描述中的数据块緩存 路径集合在一起, 得到本次扫描需要緩存数据块列表。
更进一步地, 所述步骤 C ) 中进一步包括:
C1 )有所述本次扫描需要緩存数据块列表中取出设定个数的数据块緩 存路径;
C2 )按照所述緩存路径指向的数据节点, 在与该数据节点握手时将所 述数据块緩存路径发送到该数据节点。
更进一步地, 所述步骤 D )进一步包括:
D1 )取得本次握手时得到的所有数据块緩存路径, 并依次按照每个数 据块緩存路径读取该数据块, 并将其在该数据节点的内存中緩存; 如未找到数 据块或内存空间有限不能緩存, 则标记该数据块緩存失败并处理下一个数据块 緩存路径;
D2 )在下一次握手时返回所述名称节点所有数据块的緩存结果。
本发明还涉及一种实现上述方法的装置, 所述分布式存储系统包括多个用 于存储数据的数据节点和与所述多个数据节点通过网络连接的并管理所述多 个数据节点的名称节点, 所述装置包括:
配置文件解析模块: 用于在名称节点上载配置文件到其内存中并解析 所述配置文件;
緩存信息取得模块: 用于得到配置文件中关于緩存的信息, 所述信息 包括緩存路径、 緩存方式、 副本数量以及取消緩存的条件;
緩存信息发送模块: 用于使名称节点在与各个数据节点握手时将该数 据节点涉及的緩存信息传输给所述数据节点;
緩存实现模块: 用于使所述数据节点取出其涉及的緩存数据并按照其 接收到的緩存信息存储在该数据节点的内存中; 完成数据緩存后, 数据节点在 下一次握手时通知所述名称节点。
更进一步地, 还包括: 读请求模块: 用于使客户端发出读请求到所述名称节点, 所述名称节 点查找其要求的数据是有緩存, 如有, 返回緩存位置到客户端; 如无, 按照正 常的读请求处理;
緩存查找模块: 用于使客户端向数据节点发送数据读请求, 数据节点 在收到所述数据读请求后查找本地緩存列表, 如有, 直接由其内存发送数据给 所述客户端; 如无, 读取其磁盘取得数据并发送给所述客户端, 同时通知所述 名称节点緩存异常。
更进一步地, 所述緩存信息取得模块还包括:
对象取得单元: 用于取得所述緩存策略文件中的一个对象;
路径判断单元: 用于判断所述对象指向的路径是一个还是一个目录, 如果是一个文件, 调用元数据形成单元; 如果是一个目录, 将其解析为多个文 件后调用元数据形成单元;
元数据形成单元: 用于构建一个表示所述緩存文件的元数据, 所述元 数据包括文件描述、 文件所包括的所有数据块描述、 緩存份数及緩存周期; 其 中, 所述数据块描述包括其緩存路径、 其所在数据节点在所述名称节点上的描 述、 块序号、 块长度及其数据块状态标志;
对象判断单元: 用于判断是否处理完所述緩存策略文件中的所有对象; 数据块列表形成单元: 用于将处理每个所述对象得到的元数据中所有 数据块描述中的数据块緩存路径集合在一起, 得到本次扫描需要緩存数据块列 表。
实施本发明的用于分布式存储系统的数据緩存方法及装置, 具有以下有益 效果: 由于实用配置文件确定了需要緩存的文件的参数, 并在名称节点将配置 文件解析, 得到表示緩存文件的元数据; 在名称节点和数据节点握手时, 将上 述元数据中表示数据块的相关参数传输到数据节点, 数据节点将这些参数指示 的数据块由磁盘读出并緩存在该数据节点的内存中。 这样, 既没有对 HDFS本 身的结构做出修改, 又解决了相关数据緩存的问题。 因此其结构简单、 内部的 数据交换较少。
附图说明
图 1是本发明用于分布式存储系统的数据緩存方法及装置实施例中緩存方 法的流程图;
图 2是所述实施例中名称节点上处理配置文件部分的逻辑结构示意图; 图 3是所述实施例中緩存数据块的状态转换示意图;
图 4是所述实施例中的装置结构示意图。
具体实施方式
下面将结合附图对本发明实施例作进一步说明。
如图 1 所示, 在本发明分布式存储系统的数据緩存方法及装置实施例中, 其方法包括如下步骤:
步骤 S11 上载配置文件到其内存并解析: 在本实施例中, 分布式存储系统 包括多个用于存储数据的数据节点 (Data Node,DN )和与所述多个数据节点 通过网络连接的并管理所述多个数据节点的名称节点(Name Node,NN ) , 客 户端通过上述名称节点取得上述数据节点上存储的数据。 在现有技术中, 在没 有緩存的情况下, 客户端向名称节点提出读请求, 告知该名称节点需要读出的 文件; 名称节点查找到该文件的存储位置, 并将该位置返回提出读请求的客户 端; 该客户端得到这些信息后, 再向存储有该文件 (或组成该文件的数据块) 的数据节点提出读请求, 这些收到请求的数据节点读出文件或数据块, 并返回 给该客户端, 以完成数据或文件的取得。 在本实施例中, 当完成指定文件的緩 存后, 读取该文件的步骤大致上还是相同的。 只不过在文件被緩存的情况下, 名称节点返回给客户端的不是文件的存储位置而是緩存的位置, 数据节点也不 是直接去读取文件而是在查找到緩存目录的情况下直接将緩存的文件发送给 客户端。这样,在最大程度不增加内部数据传输的情况下,实现了文件的緩存, 提高了取得文件的速度, 改善了用户的体验。 当然, 在本实施例中, 首先还是 要实现文件的緩存, 这些緩存的文件是由客户编写的配置文件指定的。 具体说 来, 就是把所有数据节点 (DN ) 的内存整合成为一个内存池, 通过配置的方 式暴露给客户端, 使得客户端可以通过配置文件对 HDFS存储的数据进行緩存 定制化。 HDFS本身是一个 Master/Slave结构, 所有的请求都需要 NN(Namenode 名称节点)来负责处理,这样就给数据的统一处理提供了方便,可以在存储的同 时指定是否緩存, 对于读取数据而言, 从 DN的内存读取显然比从磁盘读取要 快捷的多, 使得整个系统更加高效。 在本实施例中, 客户在客户端根据需求编 写配置文件, 配置文件使用 xml来编写, 可以指定的参数包括: 緩存路径、 緩 存周期、 緩存份数(根据文件的使用频度可调节) 、 緩存替换策略、 緩存清理 策略等。 编写好的配置文件可以传输给名称节点或由名称节点读取配置文件, 由于 HDFS的配置信息并不大, 完全读入内存不会影响系统性能, 因此, 在本 实施釆用简单的 DOM (文档对象模型)来解析配置信息, 之后构造合理的数据 结构保存信息, 并构造一系列工作线程, 保证整个机制可以顺利工作。
步骤 S12得到元数据, 并将其中表示数据块的描述列表: 在本步骤中,数 据节点将其内存中的配置文件解析,并构建合理的数据结构保存,并供给下一个 流程使用处理。 在实现上, 通过设置在数据节点上的 HDFS的 API定义一个对 象,即 CachePolicy,在该对象中保存从配置信息里读取的文件路径、緩存份数、 替换策略、 声明周期等内容。 同样地, 通过 HDFS的 API调用或定义一个周期 性的扫描线程 ConfigMonitor,从 HDFS 自身的配置文件 hdfs-site.xml读取扫描 周期 (该扫描周期是自定义的), 按照上述周期的设定, 每周期读取一次配置 信息。 无论是新增的路径、 修改了生命周期、 緩存个数或者替换策略等, 都需 要生成新的 CachePolicy; 另外, 考虑到某些路径本身可能没有改变, 但其上存 放的文件可能有增加或者删除的变化, 因此即使某个路径的所有参数没有发生 改变, 也依然构造 CachePolicy对象。
在本步骤中, 在数据节点上, 通过 CacheMangaer对緩存进行管理。 CacheMangaer运行于一个 Facade模式, 集合了所有相关的数据结构和线程, 处 理所有和緩存相关的事务。 在本实施例中, 对每个需要緩存的文件以及每个文 件存储在各数据节点上的数据块分别进行描述。 这些描述表示了文件或数据块 的緩存参数。 这些描述被保存在名称节点上形成列表, 同时, 在名称节点和相 关的数据节点握手时发送到数据节点, 即使不进行緩存, 名称节点和数据节点 的握手也是要进行的, 所以, 这些对文件或数据块的描述的发送并没有增加该 HDFS系统内部的数据传输量或增加得不多。 每一个需要被緩存的文件都有对 应的一个元数据表示 CacheFile,它包含文件的 INodeFile(文件元数据的描述 )、 所有的緩存数据块以及从 CachePolicy得到的緩存份数、 生命周期等。 作为一个 常识, 一个文件在 HDFS中是被分割为多个数据块的。 其中, 每一个数据块也 对应 着一个描述对 象 CachedBlock, 它 包含该数据块所在 的 DND(DatanodeDescriptor数据节点在名称节点的描述), 从 block ( HDFS自带的 数据块对象)得到的块序号、 块长度、 块代号等信息; 此外, 数据块的描述对 象还包括四个状态标志: isSend, isCached, willDelete, isDeleted, 这些标志位分 别表示该数据块的状态分别是已经发送、 已经緩存、 等待删除和已经删除四个 状态。 这些状态代表了一个緩存块的整个活动周期。 关于被緩存的数据块的状 态转换, 请参见图 3。
总之, 在本步骤中, 名称节点对于其内存中的配置文件的处理过程为: 取 得所述緩存策略文件中的一个对象(或配置文件中对于一个緩存文件描述的参 数或参数集); 之后, 判断该对象指向的路径是一个文件还是一个目录(即判 断该路径指向的位置上是一个文件还是一个目录或文件夹), 如果是一个文件, 则构建表示该文件的元数据; 如果是一个目录, 将其解析为多个文件后再分别 构建表示各文件的元数据。
而构建一个表示文件的元数据的方法大致是相同的。 对于不同文件而言, 仅仅是构建出来的元数据的参数不同而已。 在本实施例中, 元数据包括文件描 述、 文件所包括的所有数据块描述、 緩存份数及緩存周期; 其中, 所述数据块 描述包括其緩存路径、 其所在数据节点在所述名称节点上的描述、 块序号、 块 长度及其数据块状态标志; 也就是说, 元数据中不仅仅包括对文件的描述, 还 包括对组成文件的所有数据块的描述。 由于一个文件在 HDFS中又多个数据块 组成, 且这些数据块可能不是存储在同一个数据节点中的, 所以, 对于元数据 而言, 其中的数据块描述是元数据中非常重要的一个部分或是关键的一个部分。
在本实施例中, 一个配置文件中可能包括对多个文件的緩存参数, 因此, 一个配置文件被处理后可能产生多个对象。 上面所述的步骤是对一个对象的处 理, 当有多个对象时, 依次分别按照上述步骤对每个对象进行处理, 直到处理 完所述緩存策略文件中的所有对象。
在本实施例中, 名称节点中处理上述配置文件的部分的内部逻辑结构如图 2所示, 由图 2可以看出, 在緩存的构建过程中, 使用 TriggerMonitor线程周期性 的从 ConfigMonitor线程中读取 CachePolicy对象,然后将一个 CachePolicy指定的 路径解析,如果指定路径是一个文件,那么一个 CachePolicy对应一个 CacheFile; 如果指定路径是一个目录, 那么一个 CachePolicy就解析为多个 CacheFile。 在 CacheMangaer中有两个关于 CacheFile的列表,一个保存着当前全部处于緩存状 态的文件集合, 另一个则保存着本次扫描需要处理的文件集合。 TriggerMonitor 线程读取对象 CachePolicy后会创建一系列的 CacheFile, 通过和之前 history的对 比, 把未出现过的新的 CacheFile同时添加到两个文件集合; 把更新过的 CacheFile (也就是已经被緩存模块记录, 但策略有所改变)在全部緩存文件集 合中更新状态,并由此更新全部相关的 CachedBlock的状态, 同时添加到本次緩 存列表; 将没有任何改动的文件(因为从 CachePolicy读取的是全部路径下的文 件,必然有重复的)忽略掉。另外需要提及的是,在生成緩存文件对象 CacheFile 的时候, 所生成的緩存数据块 CachedBlock—方面添加到了 CacheFile里, 另一 方面也添加到了一个专有的数据集合 waitingPool里面, 这个数据结构专门用来 保存所有需要緩存的数据块, 它实际上是一个优先级队列; 在本实施例中, 认 为緩存份数从 1到 3优先级依次递减, 也就是緩存份数越少, 优先级越高。
步骤 S13 取出表中设定数量个描述并在握手时发给数据节点:在本步骤中, 由于在上述步骤中, TriggerMonitor将緩存路径上的文件全部读出, 并处理 成为 CacheFile和 CachedBlock, 下一步的工作就交由 CacheMonitor处理。 这 个线程的主要作用是将 waitingPool里面的尚未緩存的数据块标记发送添加到 DND里面,等待下次名称节点向数据节点传递命令的时候,将这些块的緩存命 令发送到相应的数据节点。 这个线程(CacheMonitor )会周期性的读取指定个 数(maxCachedNum )的数据块, 调用 DND的添加方法, 添加到其相应的队列 里。 在 DND里面, 每次构建命令发送到相应的数据节点以后, 就从 DND里删 除这些已经发送的块信息, 也就是说, 这些数据块实际上存在于 waitingPool 和 cachedPool, 送入并存储在 DND里面只是标记。 无论数据节点端否成功緩 存这些数据块, DND是不去管理的。
步骤 S14对指定的数据块在其内存中执行緩存: 在本步骤中,在数据节点 中, 通过 heartBeat (握手程序或心跳连接)收到名称节点的命令后, 该数据节 点会扫描本地的 FSDataSet找到对应的块, 在内存中创建其緩存备份。 如果未 找到这个块, 则直接调用创建的 RPC (远程过程调用)方法 reportBadCache() 来告诉名称节点未找到这个块, 名称节点检查緩存份数, 如果只有 1份, 那么 查找该块的其他 DND并继续尝试緩存, 同时调用 HDFS其他原生线程做数据 修复工作; 上述 1份指的是緩存的份数。 而原有 HDFS每个数据块默认是保存 3份的, 每一份都写在不同的 DN磁盘上, 所以对应在 NN里面的 DND有 3 个。 即如果目的是要緩存某个数据块 1次, 而第一次 NN找到一个 DND, 但对 应的 DN无法进行緩存,那么查找该数据块的另外一个 DND,再发送给对应的 DN进行緩存处理, 直到 3个 DND都尝试过, 还没有緩存成功, 则表示该数据 块在緩存系统中已经损坏。
如果 NN收到三份不能緩存一个数据块的报告, 则表示该数据块块彻底损 坏, 则这个数据块所在文件也就损坏了, 那么直接删除之。 如果找到这个块, 磁盘空间不足无法緩存, 那么同样报告给名称节点, 选择该块的下一个 DND 进行尝试; 如果成功緩存, 上报名称节点成功标志, 名称节点修改这个块的状 态及相应管理工作。
步骤 S15 记录执行緩存的情况: 在本步骤中,数据节点釆取如上所述的方 法保存数据块緩存的情况。
步骤 S16再次握手时将执行情况返回: 在本步骤中,数据节点在其与名称 节点再次握手的时候, 将存储的上次握手收到的数据块緩存指令的执行结果发 送回名称节点, 如果一个数据块緩存成功, 则需要判断其所在文件的其他数据 块是否緩存成功。 只有在构成一个文件的所有数据块緩存成功时, 才能确定其 文件緩存成功, 并开始修改该文件的状态; 如果 1个数据块没有緩存成功, 则 需要按照步骤 S14中的方法处理或修复该数据块。
在本实施例中, 数据緩存后还包括将其读出的步骤。 当客户端申请读取文 件时, 其首先向名称节点发送读请求, 名称节点收到这个请求后, 首先检查緩 存列表是否包含此文件, 若包含, 直接对其内部的 CachedBlock[]进行包装, 返 回给客户端一组数据块位置信息 (这一组数据块组成了请求读出的文件), 这 个过程对客户端是透明的; 如果不存在这个緩存文件, 那么按照正常的数据读 取流程(即现有技术中不使用緩存的 HDFS 系统中读取文件的流程)。 在客户 端获得数据块的具体位置后, 直接向该位置所在的数据节点 DN发送读请求, 要求读取数据。 DN收到请求后, 会检查该数据块是否存在于緩存列表中, 如 果存在, 则直接返回内存文件实现数据读取; 否则调用正常读取流程从磁盘读 取, 整个过程对于客户端同样是透明的。 在本实施例中, 在 NN和 DN端都对緩存数据块进行了描述, 因此需要一 定的机制来保证整个流程顺畅的进行。 在 NN端的核心 CacheMananer中, 包 含了大量的处理 DN端反馈信息的方法, 对于数据块成功緩存、 失败緩存、 内 存不足、 找不到块等都进行了相应的处理。 同时还使用了两个线程, 一个 ClearMonitor用来定时清理过期的緩存文件;一个 HandleMonitor用来定时的检 查一个文件是否緩存成功。 只有当一个文件緩存成功, 才开始对其进行緩存倒 计时; 而判断一个文件是否緩存成功, 依据就是其下属的所有数据块都緩存成 功, 则可以认定这个文件緩存成功。
值得一提的是, 在本实施例中, 上述所有的线程或进程或实现某种功能的 函数或功能模块, 都是通过 HDFS的 API调用或定义的, 因此对于本实施例而 言, 并没有对现有的 HDFS结构做出改变, 相反, 仅仅是在现有 HDFS的基础 上增加了一些功能模块即实现了数据的緩存, 利用了闲置的数据节点的内存, 改善了数据读出的速度。
此外, 在本实施例中, 还涉及一种用于分布式存储系统的数据緩存装置, 其中, 分布式存储系统包括多个用于存储数据的数据节点和与多个数据节点通 过网络连接的并管理这些多个数据节点的名称节点; 如图 4所示, 该装置包括 配置文件解析模块 41、 緩存信息取得模块 42、 緩存信息发送模块 43、 緩存实 现模块 44、 读请求模块 45和緩存查找模块 46; 其中, 配置文件解析模块 41 用于在名称节点上载配置文件到其内存中并解析所述配置文件; 緩存信息取得 模块 42用于得到配置文件中关于緩存的信息, 所述信息包括緩存路径、 緩存 方式、 副本数量以及取消緩存的条件; 緩存信息发送模块 43 用于使名称节点 在与各个数据节点握手时将该数据节点涉及的緩存信息传输给所述数据节点; 緩存实现模块 44用于使所述数据节点取出其涉及的緩存数据并按照其接收到 的緩存信息存储在该数据节点的内存中; 完成数据緩存后, 数据节点在下一次 握手时通知所述名称节点; 读请求模块 45用于使客户端发出读请求到所述名 称节点, 所述名称节点查找其要求的数据是有緩存, 如有, 返回緩存位置到客 户端; 如无, 按照正常的读请求处理; 緩存查找模块 46用于使客户端向数据 节点发送数据读请求, 数据节点在收到所述数据读请求后查找本地緩存列表, 如有, 直接由其内存发送数据给所述客户端; 如无, 读取其磁盘取得数据并发 送给所述客户端, 同时通知所述名称节点緩存异常。
在本实施例中, 上述緩存信息取得模块 42还包括对象取得单元 421、路径 判断单元 422、 元数据形成单元 423、 对象判断单元 424和数据块列表形成单 元 425; 其中, 对象取得单元 421用于取得所述緩存策略文件中的一个对象; 路径判断单元 422用于判断所述对象指向的路径是一个还是一个目录, 如果是 一个文件, 调用元数据形成单元; 如果是一个目录, 将其解析为多个文件后调 用元数据形成单元; 元数据形成单元 423用于构建一个表示所述緩存文件的元 数据, 所述元数据包括文件描述、 文件所包括的所有数据块描述、 緩存份数及 緩存周期; 其中, 所述数据块描述包括其緩存路径、 其所在数据节点在所述名 称节点上的描述、 块序号、 块长度及其数据块状态标志; 对象判断单元 424用 于判断是否处理完所述緩存策略文件中的所有对象; 数据块列表形成单元 425 用于将处理每个所述对象得到的元数据中所有数据块描述中的数据块緩存路 径集合在一起, 得到本次扫描需要緩存数据块列表。
但并不能因此而理解为对本发明专利范围的限制。 应当指出的是, 对于本领域 的普通技术人员来说, 在不脱离本发明构思的前提下, 还可以做出若干变形和 改进, 这些都属于本发明的保护范围。 因此, 本发明专利的保护范围应以所附 权利要求为准。

Claims

权利要求书
1、 一种用于分布式存储系统的数据緩存方法, 所述分布式存储系统包括 多个用于存储数据的数据节点和与所述多个数据节点通过网络连接的并管理 所述多个数据节点的名称节点, 其特征在于, 所述方法包括如下步骤:
A )名称节点上载配置文件到其内存中并解析所述配置文件;
B )得到配置文件中关于緩存的信息, 所述信息包括緩存路径、 緩存 方式、 副本数量以及取消緩存的条件;
C )名称节点在与各个数据节点握手时将该数据节点涉及的緩存信息 传输给所述数据节点;
D ) 所述数据节点取出其涉及的緩存数据并按照其接收到的緩存信息 存储在该数据节点的内存中; 完成数据緩存后, 数据节点在下一次握手时通知 所述名称节点。
2、 根据权利要求 1 所述的用于分布式存储系统的数据緩存方法, 其特征 在于, 还包括如下步骤:
E )客户端发出读请求到所述名称节点, 所述名称节点查找其要求的 数据是有緩存,如有,返回緩存位置到客户端;如无,按照正常的读请求处理;
F )客户端向数据节点发送数据读请求, 数据节点在收到所述数据读 请求后查找本地緩存列表,如有,直接由其内存发送数据给所述客户端;如无, 读取其磁盘取得数据并发送给所述客户端, 同时通知所述名称节点緩存异常。
3、 根据权利要求 2所述的用于分布式存储系统的数据緩存方法, 其特征 在于, 所述配置文件是由客户端定义并传输给所述名称节点的; 所述配置文件 在所述名称节点上被转换为一个緩存策略文件, 所述緩存策略文件中包括多个 表示緩存文件的对象; 所述名称节点通过周期性的扫描线程在每个周期上取得 并替换其内存中的緩存策略文件。
4、 根据权利要求 3所述的用于分布式存储系统的数据緩存方法, 其特征 在于, 所述步骤 B )进一步包括:
B1 )取得所述緩存策略文件中的一个对象;
B2 )判断所述对象指向的路径是一个还是一个目录,如果是一个文件, 执行步骤 B3 ); 如果是一个目录, 将其解析为多个文件后执行步骤 B3 ); B3 )构建一个表示所述緩存文件的元数据,所述元数据包括文件描述、 文件所包括的所有数据块描述、 緩存份数及緩存周期; 其中, 所述数据块描述 包括其緩存路径、 其所在数据节点在所述名称节点上的描述、 块序号、 块长度 及其数据块状态标志;
B4 )重复上述步骤 Bl ) -B3 )直到处理完所述緩存策略文件中的所有 对象。
5、 根据权利要求 4所述的用于分布式存储系统的数据緩存方法, 其特征 在于, 所述步骤 B ) 中还包括如下步骤:
将处理每个所述对象得到的元数据中所有数据块描述中的数据块緩存 路径集合在一起, 得到本次扫描需要緩存数据块列表。
6、 根据权利要求 5所述的用于分布式存储系统的数据緩存方法, 其特征 在于, 所述步骤 C ) 中进一步包括:
C1 )有所述本次扫描需要緩存数据块列表中取出设定个数的数据块緩 存路径;
C2 )按照所述緩存路径指向的数据节点, 在与该数据节点握手时将所 述数据块緩存路径发送到该数据节点。
7、 根据权利要求 6所述的用于分布式存储系统的数据緩存方法, 其特征 在于, 所述步骤 D )进一步包括:
D1 )取得本次握手时得到的所有数据块緩存路径, 并依次按照每个数 据块緩存路径读取该数据块, 并将其在该数据节点的内存中緩存; 如未找到数 据块或内存空间有限不能緩存, 则标记该数据块緩存失败并处理下一个数据块 緩存路径;
D2 )在下一次握手时返回所述名称节点所有数据块的緩存结果。
8、 一种用于分布式存储系统的数据緩存装置, 所述分布式存储系统包括 多个用于存储数据的数据节点和与所述多个数据节点通过网络连接的并管理 所述多个数据节点的名称节点, 其特征在于, 所述装置包括:
配置文件解析模块: 用于在名称节点上载配置文件到其内存中并解析 所述配置文件;
緩存信息取得模块: 用于得到配置文件中关于緩存的信息, 所述信息 包括緩存路径、 緩存方式、 副本数量以及取消緩存的条件;
緩存信息发送模块: 用于使名称节点在与各个数据节点握手时将该数 据节点涉及的緩存信息传输给所述数据节点;
緩存实现模块: 用于使所述数据节点取出其涉及的緩存数据并按照其 接收到的緩存信息存储在该数据节点的内存中; 完成数据緩存后, 数据节点在 下一次握手时通知所述名称节点。
9、 根据权利要求 8所述的装置, 其特征在于, 还包括:
读请求模块: 用于使客户端发出读请求到所述名称节点, 所述名称节 点查找其要求的数据是有緩存, 如有, 返回緩存位置到客户端; 如无, 按照正 常的读请求处理;
緩存查找模块: 用于使客户端向数据节点发送数据读请求, 数据节点 在收到所述数据读请求后查找本地緩存列表, 如有, 直接由其内存发送数据给 所述客户端; 如无, 读取其磁盘取得数据并发送给所述客户端, 同时通知所述 名称节点緩存异常。
10、 根据权利要求 8所述的装置, 其特征在于, 所述緩存信息取得模块还 包括:
对象取得单元: 用于取得所述緩存策略文件中的一个对象;
路径判断单元: 用于判断所述对象指向的路径是一个还是一个目录, 如果是一个文件, 调用元数据形成单元; 如果是一个目录, 将其解析为多个文 件后调用元数据形成单元;
元数据形成单元: 用于构建一个表示所述緩存文件的元数据, 所述元 数据包括文件描述、 文件所包括的所有数据块描述、 緩存份数及緩存周期; 其 中, 所述数据块描述包括其緩存路径、 其所在数据节点在所述名称节点上的描 述、 块序号、 块长度及其数据块状态标志;
对象判断单元: 用于判断是否处理完所述緩存策略文件中的所有对象; 数据块列表形成单元: 用于将处理每个所述对象得到的元数据中所有数据 块描述中的数据块緩存路径集合在一起, 得到本次扫描需要緩存数据块列表。
PCT/CN2014/078656 2014-05-28 2014-05-28 一种用于分布式存储系统的数据缓存方法及装置 WO2015180070A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2014/078656 WO2015180070A1 (zh) 2014-05-28 2014-05-28 一种用于分布式存储系统的数据缓存方法及装置
CN201480078749.6A CN107111615A (zh) 2014-05-28 2014-05-28 一种用于分布式存储系统的数据缓存方法及装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2014/078656 WO2015180070A1 (zh) 2014-05-28 2014-05-28 一种用于分布式存储系统的数据缓存方法及装置

Publications (1)

Publication Number Publication Date
WO2015180070A1 true WO2015180070A1 (zh) 2015-12-03

Family

ID=54697852

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/078656 WO2015180070A1 (zh) 2014-05-28 2014-05-28 一种用于分布式存储系统的数据缓存方法及装置

Country Status (2)

Country Link
CN (1) CN107111615A (zh)
WO (1) WO2015180070A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109542347B (zh) * 2018-11-19 2022-02-18 浪潮电子信息产业股份有限公司 一种数据迁移方法、装置、设备及可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004068469A2 (en) * 2003-01-17 2004-08-12 Tacit Networks, Inc. Method and system for use of storage caching with a distributed file system
CN101901275A (zh) * 2010-08-23 2010-12-01 华中科技大学 一种分布式存储系统及其方法
WO2013019913A1 (en) * 2011-08-02 2013-02-07 Jadhav Ajay Cloud-based distributed persistence and cache data model
CN103699660A (zh) * 2013-12-26 2014-04-02 清华大学 一种大规模网络流式数据缓存写入的方法

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101499095B (zh) * 2009-03-11 2011-04-27 南京联创科技集团股份有限公司 用于数据共享平台的构建缓冲的方法
EP2290562A1 (en) * 2009-08-24 2011-03-02 Amadeus S.A.S. Segmented main-memory stored relational database table system with improved collaborative scan algorithm
CN103034617B (zh) * 2012-12-13 2015-09-30 深圳市同创国芯电子有限公司 用于实现可重构系统配置信息存储的缓存结构和管理方法
CN103595776A (zh) * 2013-11-05 2014-02-19 福建网龙计算机网络信息技术有限公司 分布式缓存方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004068469A2 (en) * 2003-01-17 2004-08-12 Tacit Networks, Inc. Method and system for use of storage caching with a distributed file system
CN101901275A (zh) * 2010-08-23 2010-12-01 华中科技大学 一种分布式存储系统及其方法
WO2013019913A1 (en) * 2011-08-02 2013-02-07 Jadhav Ajay Cloud-based distributed persistence and cache data model
CN103699660A (zh) * 2013-12-26 2014-04-02 清华大学 一种大规模网络流式数据缓存写入的方法

Also Published As

Publication number Publication date
CN107111615A (zh) 2017-08-29

Similar Documents

Publication Publication Date Title
US10218584B2 (en) Forward-based resource delivery network management techniques
CA2621756C (en) System and method to maintain coherence of cache contents in a multi-tier software system aimed at interfacing large databases
US9613048B2 (en) Sending interim notifications to a client of a distributed filesystem
US9990372B2 (en) Managing the level of consistency for a file in a distributed filesystem
US9442936B2 (en) Cooperative grid based picture archiving and communication system
US8484259B1 (en) Metadata subsystem for a distributed object store in a network storage system
RU2453911C2 (ru) Автономное выполнение веб-приложений
CN102855239B (zh) 一种分布式地理文件系统
US11514000B2 (en) Data mesh parallel file system replication
WO2013120382A1 (zh) 一种离线下载资源的系统、方法、装置以及计算机存储介质
CN111177159B (zh) 一种数据处理的系统、方法和数据更新设备
CN114201446B (zh) 实现hdfs远端存储挂载的方法及系统
WO2015180070A1 (zh) 一种用于分布式存储系统的数据缓存方法及装置
JP2004118482A (ja) 記憶装置、および、キャッシュ方法
Afonso Mechanisms for providing causal consistency on edge computing
Monti An Integrated End-User Data Service for HPC Centers
JP2009282719A (ja) データベースシステム及びデータベースサーバ装置
VanDyk et al. Optimizing Drupal
Tomlinson et al. Optimizing Drupal
Feng et al. BREAK: A Holistic Approach for Efficient Container Deployment among Edge Clouds

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14893241

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14893241

Country of ref document: EP

Kind code of ref document: A1