Data processing and data query method, device, system, electronic equipment and medium

By storing HDFS directory metadata locally in the data query engine and synchronizing Journalnode update information, the response time problem when the data query engine accesses HDFS is solved, achieving more efficient data processing.

CN115357547BActive Publication Date: 2026-11-20LAKALA PAYMENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210864260.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-21
Publication Date
2026-11-20
Estimated Expiration
2042-07-21

AI Technical Summary

Technical Problem

In existing technologies, when a data query engine accesses HDFS, it needs to remotely access the NameNode and Datanode nodes, which increases the response time for data querying, analysis, and processing, and reduces data processing efficiency.

Method used

The data query engine pre-retrieves metadata for the specified directory from the Namenode and stores it on local storage. It periodically checks for updates from the Journalnode and synchronizes the metadata on the local storage to retrieve data directly from the Datanode, reducing remote access.

Benefits of technology

By reducing the number of remote accesses, the response time and processing efficiency of data queries were improved, and the data query process was optimized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115357547B_ABST
    Figure CN115357547B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure disclose a data processing and data query method, device, system, electronic equipment and medium. The method comprises: obtaining metadata of a specified directory from a Namenode node of a distributed file system and saving the metadata on a local storage medium; periodically detecting update information of a Journalnode node of the distributed file system; and based on the update information, determining that the metadata of the specified directory is updated, and synchronizing the updated metadata of the specified directory to the local storage medium. The technical solution can reduce the process of one remote access, reduce the response time of data query, and improve the data processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of big data processing technology, specifically to a data processing and data query method, apparatus, system, electronic device, and medium. Background Technology

[0002] In the era of big data, with the rapid rise and popularization of internet technology, the amount of data collected by people in different fields has reached an unprecedented level. At the same time, the ways in which data is generated, stored, and processed have undergone revolutionary changes. People's work and life can basically be represented digitally, and data usage and retrieval are very frequent.

[0003] The Hadoop Distributed File System (HDFS), with its high reliability, efficiency, and scalability, is widely used in large-scale computing. It consists of one or more NameNodes and multiple DataNodes, forming a crucial component of the cluster architecture. The NameNode manages the namespace of the HDFS, maintaining the HDFS tree and all files and directories within it. This information is permanently stored on the local disk in two files: a namespace image file and an edit log file. The NameNode also records the DataNode information for each block within a file; however, it does not permanently store the block locations, as this information is reconstructed based on the DataNode information during system startup.

[0004] Data stored in a distributed file system can be accessed through a data query engine. For example, data stored in HDFS can be queried using the Presto computing engine. Presto is an open-source distributed SQL query engine from Facebook, suitable for interactive analytical queries, supporting data volumes from GB to PB. Presto's architecture evolved from relational database architecture. As an alternative to Hive and Pig (both of which use MapReduce pipelines to query HDFS data), Presto can not only access HDFS but also manipulate different data sources, including RDBMS and other data sources (e.g., Cassandra). Presto is designed for data warehousing and data analytics products: data analysis, large-scale data aggregation, and report generation.

[0005] When using data query engines like Presto to manipulate data stored on HDFS, the process involves at least two remote accesses to HDFS (one to the NameNode and one to the DataNodes) to retrieve data. This increases response time for data querying, analysis, and processing, thus reducing data processing efficiency. Therefore, a solution is needed to reduce waiting time and improve data processing efficiency when data query engines access data on distributed file systems like HDFS. Summary of the Invention

[0006] This disclosure provides a data processing and data query method, apparatus, system, electronic device, and medium.

[0007] In a first aspect, this disclosure provides a data processing method, including:

[0008] Retrieve metadata for the specified directory from the Namenode node of the distributed file system and store it on local storage media;

[0009] Periodically check the update information of the Journalnode node of the distributed file system;

[0010] After determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium.

[0011] Furthermore, the update information of the Journalnode node of the distributed file system is periodically detected, including:

[0012] The journal node periodically retrieves the edit log file from the Journalnode node of the distributed file system; the edit log file is obtained by the Journalnode node from the Namenode node.

[0013] The currently acquired edit log file is compared with the previously acquired edit log file to determine the updated information.

[0014] Furthermore, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; periodically detecting updates on the Journalnode nodes of the distributed file system includes:

[0015] Periodically obtain update information from the 2n+1 Journalnode nodes;

[0016] When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined to be the update information from the Journalnode nodes of the distributed file.

[0017] Further, after determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium, including:

[0018] The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and stored on the local storage medium; the checkpoint file stores the metadata of the specified directory after the last update.

[0019] Furthermore, the specified directory is the directory targeted by the local data query engine.

[0020] Secondly, this disclosure provides a data query method, including:

[0021] Receive a data query request for a distributed file system; the data query request includes the directory to be queried in the distributed file system.

[0022] Retrieve metadata corresponding to the directory to be queried from the local storage medium;

[0023] After finding the metadata of the directory to be queried in the local storage medium, the Datanode node where the data to be queried in the directory to be queried in the distributed file system is located is determined based on the metadata.

[0024] The system requests the data to be queried from the directory to be queried from the Datanode node.

[0025] Furthermore, the metadata of the directory to be queried is obtained in advance from the Journalnode node of the distributed file system and stored in the local storage medium.

[0026] Furthermore, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0027] Thirdly, this disclosure provides a data query method, including:

[0028] Retrieve metadata for the specified directory from the Namenode node of the distributed file system and store it on local storage media;

[0029] Periodically check the update information of the Journalnode node of the distributed file system;

[0030] After determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium.

[0031] Receive a data query request for the distributed file system; the data query request includes the directory to be queried in the distributed file system;

[0032] When the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory, the metadata of the directory to be queried is determined based on the metadata of the specified directory;

[0033] Based on the metadata of the directory to be queried, determine the Datanode node where the data to be queried under the directory to be queried is located in the distributed file system;

[0034] Request the data to be queried from the directory to be queried from the Datanode node.

[0035] Furthermore, the update information of the Journalnode node of the distributed file system is periodically detected, including:

[0036] The journal node periodically retrieves the edit log file from the Journalnode node of the distributed file system; the edit log file is obtained by the Journalnode node from the Namenode node.

[0037] The currently acquired edit log file is compared with the previously acquired edit log file to determine the update information.

[0038] Furthermore, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; periodically detecting updates on the Journalnode nodes of the distributed file system includes:

[0039] Periodically obtain update information from the 2n+1 Journalnode nodes;

[0040] When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined to be the update information from the Journalnode nodes of the distributed file.

[0041] Further, after determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium, including:

[0042] The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and then stored on the local storage medium.

[0043] Furthermore, the specified directory is the directory targeted by the local data query engine.

[0044] Furthermore, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0045] Fourthly, this disclosure provides a data query system, including: a data query engine and a distributed file system;

[0046] The data query engine obtains the metadata of the specified directory from the Namenode node of the distributed file system and saves it on the local storage medium.

[0047] The data query engine periodically detects the update information of the Journalnode node of the distributed file system;

[0048] After the data query engine determines that the metadata of the specified directory has been updated based on the update information, it synchronizes the updated metadata of the specified directory to the local storage medium.

[0049] The data query engine receives a data query request for the distributed file system; the data query request includes the directory to be queried in the distributed file system.

[0050] When the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory, the data query engine determines the metadata of the directory to be queried based on the metadata of the specified directory.

[0051] The data query engine determines the Datanode node where the directory to be queried is located in the distributed file system based on the metadata of the directory to be queried.

[0052] The data query engine requests the data to be queried from the Datanode node.

[0053] Furthermore, the data query engine periodically detects the update information of the Journalnode nodes of the distributed file system, including:

[0054] The data query engine periodically retrieves edit log files from the Journalnode node of the distributed file system; the edit log files are obtained by the Journalnode node from the Namenode node.

[0055] The data query engine compares the currently obtained edit log file with the previously obtained edit log file to determine the update information.

[0056] Furthermore, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; the data query engine periodically detects the update information on the Journalnode nodes of the distributed file system, including:

[0057] The data query engine periodically obtains updated information from the 2n+1 Journalnode nodes;

[0058] When the update information of any n+1 Journalnode nodes is the same, the data query engine determines the update information of the any n+1 Journalnode nodes as the update information from the Journalnode nodes of the distributed file.

[0059] Furthermore, after the data query engine determines that the metadata of the specified directory has been updated based on the update information, it synchronizes the updated metadata of the specified directory to the local storage medium, including:

[0060] The data query engine merges the edit log file obtained from the Journalnode with the checkpoint file on the local storage medium to form updated metadata for the specified directory, and stores it on the local storage medium.

[0061] Furthermore, the specified directory is the directory targeted by the local data query engine.

[0062] Furthermore, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0063] Fifthly, this disclosure provides a data processing apparatus, including:

[0064] The first acquisition module is configured to retrieve metadata of the specified directory from the Namenode node of the distributed file system and store it on the local storage medium.

[0065] The first detection module is configured to periodically detect the update information of the Journalnode node of the distributed file system;

[0066] The first determining module is configured to, after determining that the metadata of the specified directory has been updated based on the update information, synchronize the updated metadata of the specified directory to the local storage medium.

[0067] Sixthly, this disclosure provides a data query device, comprising:

[0068] The first receiving module is configured to receive data query requests for a distributed file system; the data query request includes a directory to be queried in the distributed file system.

[0069] The lookup module is configured to search for metadata corresponding to the directory to be queried from the local storage medium;

[0070] The second determining module is configured to find the metadata of the directory to be queried in the local storage medium, and then determine the Datanode node where the data to be queried in the directory to be queried in the distributed file system is located based on the metadata.

[0071] The second acquisition module is configured to request the data to be queried from the Datanode node under the directory to be queried.

[0072] Seventhly, this disclosure provides a data query device, including:

[0073] The third acquisition module is configured to retrieve metadata of the specified directory from the Namenode node of the distributed file system and store it on the local storage medium.

[0074] The second detection module is configured to periodically detect the update information of the Journalnode node of the distributed file system;

[0075] The third determining module is configured to, after determining that the metadata of the specified directory has been updated based on the update information, synchronize the updated metadata of the specified directory to the local storage medium.

[0076] The second receiving module is configured to receive a data query request for the distributed file system; the data query request includes a directory to be queried in the distributed file system.

[0077] The fourth determining module is configured to determine the metadata of the directory to be queried based on the metadata of the specified directory when the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory;

[0078] The fifth determining module is configured to determine the Datanode node where the data to be queried is located in the directory to be queried in the distributed file system based on the metadata of the directory to be queried.

[0079] The fourth acquisition module is configured to request the data to be queried from the Datanode node under the directory to be queried.

[0080] The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above function.

[0081] In one possible design, the above-described device includes a memory and a processor. The memory stores one or more computer instructions that support the device in performing the corresponding methods described above, and the processor is configured to execute the computer instructions stored in the memory. The device may also include a communication interface for communicating with other devices or communication networks.

[0082] Eighthly, embodiments of this disclosure provide an electronic device including a memory and a processor. The memory stores one or more computer instructions that enable any of the aforementioned devices to execute the corresponding methods described above. The processor is configured to execute the computer instructions stored in the memory. Any of the aforementioned devices may further include a communication interface for communicating with other devices or communication networks.

[0083] Ninthly, embodiments of this disclosure provide a computer-readable storage medium for storing computer instructions used by any of the above-described devices, including computer instructions for performing any of the above-described methods.

[0084] In a tenth aspect, embodiments of this disclosure provide a computer program product comprising computer instructions which, when executed by a processor, are used to implement the steps of the methods described in any of the preceding aspects.

[0085] The technical solutions provided in this disclosure may have the following beneficial effects:

[0086] In this data query method, a data query engine, such as the Presto engine, pre-retrieves metadata related to a specified directory from the Namenode node of the distributed file system. This metadata is then stored on local storage. It's important to note that this local storage is the storage medium on the local device where the data query engine resides. After receiving a data query request from the user for files in the distributed file system, the data query engine searches the local storage for the metadata corresponding to the requested directory. If the metadata for the directory is found locally, the engine directly requests the queried data from the Datanode node based on this metadata. In this way, when querying data in a directory where the metadata is stored locally, the data query engine can directly retrieve the queried data from the Datanode node based on the local metadata, eliminating the need for remote access to the Namenode to obtain the metadata and then retrieving the data from the Datanode. This reduces one remote access step, decreases query response time, and improves data processing efficiency.

[0087] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the embodiments of this disclosure. Attached Figure Description

[0088] Other features, objects, and advantages of embodiments of this disclosure will become more apparent from the following detailed description of non-limiting implementations, taken in conjunction with the accompanying drawings. In the drawings:

[0089] Figure 1 A flowchart illustrating a data processing method according to an embodiment of the present disclosure is shown.

[0090] Figure 2 A flowchart of a data query method according to an embodiment of the present disclosure is shown.

[0091] Figure 3 A flowchart illustrating a data query method according to another embodiment of the present disclosure is shown.

[0092] Figure 4 A flowchart illustrating the overall process of a data query method according to an embodiment of this disclosure is shown.

[0093] Figure 5 A structural block diagram of a data processing apparatus according to an embodiment of the present disclosure is shown.

[0094] Figure 6A structural block diagram of a data query apparatus according to an embodiment of the present disclosure is shown.

[0095] Figure 7 A structural block diagram of a data query apparatus according to another embodiment of the present disclosure is shown.

[0096] Figure 8 A structural block diagram of a data query system according to an embodiment of the present disclosure is shown.

[0097] Figure 9 This is a schematic diagram of the structure of a computer system suitable for implementing a data processing method and / or data query method according to an embodiment of the present disclosure. Detailed Implementation

[0098] Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings to enable those skilled in the art to readily implement them. Furthermore, for clarity, portions unrelated to the description of the exemplary embodiments have been omitted from the drawings.

[0099] In embodiments disclosed herein, it should be understood that terms such as “comprising” or “having” are intended to indicate the presence of features, numbers, steps, behaviors, components, portions or combinations thereof disclosed herein, and are not intended to exclude the possibility that one or more other features, numbers, steps, behaviors, components, portions or combinations thereof are present or added.

[0100] It should also be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings and examples.

[0101] Figure 1 A flowchart illustrating a data processing method according to an embodiment of the present disclosure is shown, such as... Figure 1 As shown, the data processing method includes the following steps:

[0102] In step S101, the metadata of the specified directory is obtained from the Namenode node of the distributed file system and stored on the local storage medium.

[0103] In step S102, the update information of the Journalnode node of the distributed file system is periodically detected;

[0104] In step S103, after determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium.

[0105] As mentioned above, in the era of big data, with the rapid rise and popularization of internet technology, the amount of data collected by people in different fields has reached an unprecedented level. At the same time, the ways in which data is generated, stored, and processed have undergone revolutionary changes. People's work and life can basically be represented digitally, and data usage and queries are very frequent.

[0106] The Hadoop Distributed File System (HDFS), with its high reliability, efficiency, and scalability, is widely used in large-scale computing. It consists of one or more NameNodes and multiple DataNodes, forming a crucial component of the cluster architecture. The NameNode manages the namespace of the HDFS, maintaining the HDFS tree and all files and directories within it. This information is permanently stored on the local disk in two files: a namespace image file and an edit log file. The NameNode also records the DataNode information for each block within a file; however, it does not permanently store the block locations, as this information is reconstructed based on the DataNode information during system startup.

[0107] Data stored in a distributed file system can be accessed through a data query engine. For example, data stored in HDFS can be queried using the Presto computing engine. Presto is an open-source distributed SQL query engine from Facebook, suitable for interactive analytical queries, supporting data volumes from GB to PB. Presto's architecture evolved from relational database architecture. As an alternative to Hive and Pig (both of which use MapReduce pipelines to query HDFS data), Presto can not only access HDFS but also manipulate different data sources, including RDBMS and other data sources (e.g., Cassandra). Presto is designed for data warehousing and data analytics products: data analysis, large-scale data aggregation, and report generation.

[0108] When using data query engines like Presto to manipulate data stored on HDFS, the process involves at least two remote accesses to HDFS (one to the NameNode and one to the DataNodes) to retrieve data. This increases response time for data querying, analysis, and processing, thus reducing data processing efficiency. Therefore, a solution is needed to reduce waiting time and improve data processing efficiency when data query engines access data on distributed file systems like HDFS.

[0109] To address the aforementioned issues, this embodiment proposes a data processing method. In this method, a data query engine, such as the Presto engine, pre-retrieves metadata related to a specified directory from the Namenode node of the distributed file system. This metadata is then stored on a local storage medium. Specifically, this local storage medium is the storage medium on the local device where the data query engine resides. Subsequently, the local device can periodically detect updates on the Journalnode nodes in the distributed file system. Based on these updates, if the metadata corresponding to the specified directory is updated, the local storage medium is updated to maintain synchronization with the metadata of the specified directory in the distributed file system. In this way, the metadata corresponding to the specified directory on the Namenode can be synchronously stored locally on the data query engine. This allows the data query engine to directly retrieve the corresponding metadata from the local storage medium when querying data for a specified directory, without remotely accessing the Namenode node. This saves one remote access step, reduces data query response time, and improves data processing efficiency.

[0110] In one embodiment of this disclosure, the data processing method can be applied to execute on the device where the data query engine resides. In some embodiments, the data query engine can be a big data query engine, such as Presto, Hive, etc.

[0111] In a Hadoop HA cluster, two NameNodes (NNs) are typically configured: an Active NameNode (ANN) and a Standby NameNode (SBNN). The ANN and SBNN are used primarily to achieve hot standby of the NameNode within the cluster, thus mitigating single points of failure. If the ANN fails, such as due to a machine crash or the need for upgrades or maintenance, it can be quickly switched to another machine, namely the SBNN. Data synchronization between the ANN and SBNN is achieved through Journalnode nodes.

[0112] After the metadata of files and directories on the ANN is updated, the ANN writes the updated information to the Journalnode node. The SBNN then retrieves the updated information from the Journalnode node and updates its own stored metadata information, thereby maintaining data synchronization with the ANN.

[0113] In one embodiment of this disclosure, a communication connection can be established between the data query engine and the Journalnode node. Initially, the data query engine retrieves metadata corresponding to a specified directory from the Namenode node. It should be noted that the specified directory can be a directory of interest to the data query engine. For example, the Presto query engine typically only focuses on a subset of directories in the distributed file system. This subset can be identified as the specified directory, and the metadata corresponding to that specified directory can be retrieved from the Namenode node and stored in the local storage medium. That is, the specified directory can be the directory targeted by the data query, not all directories on the Namenode node. Furthermore, the journalnode node of the distributed file system can be periodically checked to ensure that when the metadata corresponding to the specified directory is updated, it is promptly synchronized to the local storage medium, keeping the metadata on the local storage medium of the data storage engine synchronized with the metadata in the distributed file system. During data querying and other processing, the data query engine can retrieve the metadata of the data to be queried from the local storage medium and then directly retrieve the data to be queried from the Datanode node of the distributed file system based on the metadata. It should be noted that the metadata recorded by the namenode node includes the location information of each block in each file. This location information corresponds to the datanode nodes in the distributed file system. However, it does not permanently store the block location information; this information is reconstructed based on the datanode information when the namenode node starts. Therefore, the data engine also needs to periodically check whether the namenode has restarted. Upon detecting a namenode restart, it can retrieve the metadata corresponding to the specified directory from the namenode again. Understandably, to reduce data waiting and transmission, this embodiment retrieves the updated metadata information for the specified directory from the journalnode node, rather than retrieving the full metadata for the specified directory from the namenode node each time.

[0114] In an optional implementation of this disclosure, step S102, namely, periodically detecting the update information of the Journalnode node of the distributed file system, includes:

[0115] The journal node periodically retrieves the edit log file from the Journalnode node of the distributed file system; the edit log file is obtained by the Journalnode node from the Namenode node.

[0116] The currently acquired edit log file is compared with the previously acquired edit log file to determine the update information.

[0117] In this optional implementation, when the Namenode node (acting as the active node) has updated metadata, it writes the corresponding log information of the update operation to an edit log file and sends the edit log file to the journalnode node, which stores the edit log file. The data query engine can periodically retrieve the edit log file from the journalnode and compare it with the previously retrieved edit log file stored on the local storage medium. If they do not match, it can be assumed that the edit log file on the journalnode node has been updated. Based on the updated edit log file, it can determine whether the metadata corresponding to the specified directory has been updated. If it has been updated, the metadata corresponding to the specified directory is updated to the local storage medium, and the edit log file can be stored locally for comparison with the next retrieved edit log file. If it has not been updated, the edit log file can be stored directly without updating the metadata corresponding to the specified directory stored on the local storage medium.

[0118] In an optional implementation of this disclosure, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; step S102, namely, periodically detecting the update information of the Journalnode nodes of the distributed file system, includes:

[0119] Periodically obtain update information from the 2n+1 Journalnode nodes;

[0120] When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined to be the update information from the Journalnode nodes of the distributed file.

[0121] In this optional implementation, to ensure that the updated metadata on the Active Namenode is synchronized to the Journalnodes, 2n+1 Journalnodes can be set, where n is a natural number greater than or equal to 1. The Active Namenode will simultaneously send the edit log file to the 2n+1 Journalnodes. Once n+1 of the 2n+1 Journalnodes successfully receive and save the edit log file, the edit log file can be considered successfully synchronized. At this point, the Standby Namenode can retrieve the edit log file from the Journalnodes and synchronize and update its local metadata to keep the Active Namenode synchronized. Otherwise, the edit log file can be considered not successfully written, and the Active Namenode can resend the edit log file to the Journalnodes or perform other synchronization operations such as data rollback.

[0122] Similarly, to ensure that the edit log files on the Journalnode nodes are synchronized with the metadata on the Active Namenode nodes, the data query engine can obtain edit log files from 2n+1 Journalnode nodes. By comparing these 2n+1 edit log files, if the content of any n+1 edit log files is the same, the edit log file is considered the latest edit log file. Based on this edit log file, the update information of the metadata corresponding to the specified directory is determined. Otherwise, the edit log file obtained this time can be discarded, and the above process will be repeated after the edit log file is obtained from the Journalnode nodes again.

[0123] In an optional implementation of this disclosure, step S103, namely, after determining that the metadata of the specified directory has been updated based on the update information, synchronizing the updated metadata of the specified directory to the local storage medium, includes:

[0124] The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and stored on the local storage medium; the checkpoint file stores the metadata of the specified directory after the last update.

[0125] In this optional implementation, when the edit log file obtained from the Journalnode node includes update information corresponding to the metadata of the specified directory, the information of the file data corresponding to the specified directory in the edit log file can be merged with the checkpoint file. The checkpoint file contains the metadata of the specified directory stored in local storage after the last update. By merging the latest update information of the metadata of the specified directory with the original metadata of the specified directory, the latest metadata of the specified directory can be obtained. In some embodiments, the checkpoint file can be the metadata of the specified directory in the namespace image file stored on the Namenode node.

[0126] Figure 2 A flowchart illustrating a data query method according to an embodiment of the present disclosure is shown, such as... Figure 2 As shown, the data processing method includes the following steps:

[0127] In step S201, a data query request for a distributed file system is received; the data query request includes the directory to be queried in the distributed file system.

[0128] In step S202, metadata corresponding to the directory to be queried is retrieved from the local storage medium;

[0129] In step S203, after finding the metadata of the directory to be queried in the local storage medium, the Datanode node where the data to be queried in the directory to be queried in the distributed file system is located is determined based on the metadata.

[0130] In step S204, the query data under the query directory is requested from the Datanode node.

[0131] As mentioned above, in the era of big data, with the rapid rise and popularization of internet technology, the amount of data collected by people in different fields has reached an unprecedented level. At the same time, the ways in which data is generated, stored, and processed have undergone revolutionary changes. People's work and life can basically be represented digitally, and data usage and queries are very frequent.

[0132] The Hadoop Distributed File System (HDFS), with its high reliability, efficiency, and scalability, is widely used in large-scale computing. It consists of one or more NameNodes and multiple DataNodes, forming a crucial component of the cluster architecture. The NameNode manages the namespace of the HDFS, maintaining the HDFS tree and all files and directories within it. This information is permanently stored on the local disk in two files: a namespace image file and an edit log file. The NameNode also records the DataNode information for each block within a file; however, it does not permanently store the block locations, as this information is reconstructed based on the DataNode information during system startup.

[0133] Data stored in a distributed file system can be accessed through a data query engine. For example, data stored in HDFS can be queried using the Presto computing engine. Presto is an open-source distributed SQL query engine from Facebook, suitable for interactive analytical queries, supporting data volumes from GB to PB. Presto's architecture evolved from relational database architecture. As an alternative to Hive and Pig (both of which use MapReduce pipelines to query HDFS data), Presto can not only access HDFS but also manipulate different data sources, including RDBMS and other data sources (e.g., Cassandra). Presto is designed for data warehousing and data analytics products: data analysis, large-scale data aggregation, and report generation.

[0134] When using data query engines like Presto to manipulate data stored on HDFS, the process involves at least two remote accesses to HDFS (one to the NameNode and one to the DataNodes) to retrieve data. This increases response time for data querying, analysis, and processing, thus reducing data processing efficiency. Therefore, a solution is needed to reduce waiting time and improve data processing efficiency when data query engines access data on distributed file systems like HDFS.

[0135] To address the aforementioned issues, this implementation proposes a data query method. In this method, a data query engine, such as the Presto engine, pre-retrieves metadata related to a specified directory from the Namenode node of the distributed file system. This metadata is then stored on local storage media. It should be noted that this local storage media is the storage media on the local device where the data query engine resides. Subsequently, after receiving a data query request from the user for a file in the distributed file system, the data query engine searches the local storage media for the metadata corresponding to the directory to be queried. If the metadata corresponding to the directory to be queried can be found on the local storage media, the engine directly requests the data to be queried from the Datanode node based on the metadata of the directory to be queried. In this way, when the data query engine queries data under a directory to be queried, and the metadata corresponding to the directory to be queried is stored on the local storage medium, it can directly obtain the data to be queried from the Datanode node of the distributed file system based on the metadata corresponding to the directory to be queried stored on the local storage medium. This eliminates the need to remotely access the Namenode node to obtain the metadata of the directory to be queried, and then obtain the data to be queried from the Datanode node. This reduces one remote access process, reduces the response time of data queries, and improves data processing efficiency.

[0136] In one embodiment of this disclosure, the data query method can be applied to execute on the device where the data query engine resides. In some embodiments, the data query engine can be a big data query engine, such as Presto, Hive, etc.

[0137] In one embodiment of this disclosure, a user can request data from a distributed file system via a client to a data query engine. The received data query request may include a directory containing the user's query data. This directory may be a file directory within the distributed file system, and the data query request may also include the data to be queried within that directory. The data query request searches the local storage medium based on this directory to determine if the metadata of the directory is pre-stored on the local storage medium. If it is pre-stored, the location information of the data to be queried can be directly determined using the metadata of the directory stored on the local storage medium. This location information can be understood as the Datanode node where the data to be queried is located in the distributed file system. In other words, after the data query engine determines the information of the Datanode node where the data to be queried is located based on the metadata stored on the local storage medium, it can directly communicate with that Datanode node to obtain the data to be queried without remotely accessing the Namenode node.

[0138] In one embodiment of this disclosure, the metadata of the directory to be queried is obtained in advance from the Journalnode node of the distributed file system and stored in the local storage medium.

[0139] In one embodiment of this disclosure, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0140] Figure 2 The technical terms and technical features involved in the illustrated and related embodiments are consistent with Figure 1 The technical terms and technical features mentioned in the illustrated and related embodiments are the same or similar, for Figure 2 The explanations and descriptions of the technical terms and features involved in the illustrated and related embodiments can be found in the above-mentioned... Figure 1 The explanations of the illustrated and related embodiments are not repeated here.

[0141] Figure 3 A flowchart illustrating a data query method according to another embodiment of the present disclosure is shown, such as... Figure 3 As shown, the data query method includes the following steps:

[0142] In step S301, the metadata of the specified directory is obtained from the Namenode node of the distributed file system and stored on the local storage medium.

[0143] In step S302, the update information of the Journalnode node of the distributed file system is periodically detected;

[0144] In step S303, after determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium.

[0145] In step S304, a data query request for the distributed file system is received; the data query request includes the directory to be queried in the distributed file system.

[0146] In step S305, when the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory, the metadata of the directory to be queried is determined based on the metadata of the specified directory;

[0147] In step S306, the Datanode node where the data to be queried under the directory to be queried is located in the distributed file system is determined based on the metadata of the directory to be queried.

[0148] In step S307, the query data under the query directory is requested from the Datanode node.

[0149] As mentioned above, in the era of big data, with the rapid rise and popularization of internet technology, the amount of data collected by people in different fields has reached an unprecedented level. At the same time, the ways in which data is generated, stored, and processed have undergone revolutionary changes. People's work and life can basically be represented digitally, and data usage and queries are very frequent.

[0150] The Hadoop Distributed File System (HDFS), with its high reliability, efficiency, and scalability, is widely used in large-scale computing. It consists of one or more NameNodes and multiple DataNodes, forming a crucial component of the cluster architecture. The NameNode manages the namespace of the HDFS, maintaining the HDFS tree and all files and directories within it. This information is permanently stored on the local disk in two files: a namespace image file and an edit log file. The NameNode also records the DataNode information for each block within a file; however, it does not permanently store the block locations, as this information is reconstructed based on the DataNode information during system startup.

[0151] Data stored in a distributed file system can be accessed through a data query engine. For example, data stored in HDFS can be queried using the Presto computing engine. Presto is an open-source distributed SQL query engine from Facebook, suitable for interactive analytical queries, supporting data volumes from GB to PB. Presto's architecture evolved from relational database architecture. As an alternative to Hive and Pig (both of which use MapReduce pipelines to query HDFS data), Presto can not only access HDFS but also manipulate different data sources, including RDBMS and other data sources (e.g., Cassandra). Presto is designed for data warehousing and data analytics products: data analysis, large-scale data aggregation, and report generation.

[0152] When using data query engines like Presto to manipulate data stored on HDFS, the process involves at least two remote accesses to HDFS (one to the NameNode and one to the DataNodes) to retrieve data. This increases response time for data querying, analysis, and processing, thus reducing data processing efficiency. Therefore, a solution is needed to reduce waiting time and improve data processing efficiency when data query engines access data on distributed file systems like HDFS.

[0153] To address the aforementioned issues, this implementation proposes a data query method. In this method, a data query engine, such as the Presto engine, pre-retrieves metadata related to a specified directory from the Namenode node of the distributed file system. This metadata is then stored on a local storage medium. It should be noted that this local storage medium is the storage medium on the local device where the data query engine resides. Subsequently, the local device where the data query engine resides can periodically detect update information on the Journalnode nodes in the distributed file system. Based on the update information, if it determines that the metadata corresponding to the specified directory has been updated, it updates the metadata stored on the local storage medium to maintain synchronization with the metadata of the specified directory in the distributed file system. After receiving a data query request from the user for a file in the distributed file system, the data query engine searches the local storage medium for the metadata corresponding to the directory to be queried. If the metadata corresponding to the directory to be queried can be found on the local storage medium, the engine directly requests the data to be queried from the Datanode node based on the metadata of the directory to be queried. In this way, when the data query engine queries data under a directory to be queried, and the metadata corresponding to the directory to be queried is stored on the local storage medium, it can directly obtain the data to be queried from the Datanode node of the distributed file system based on the metadata corresponding to the directory to be queried stored on the local storage medium. This eliminates the need to remotely access the Namenode node to obtain the metadata of the directory to be queried, and then obtain the data to be queried from the Datanode node. This reduces one remote access process, reduces the response time of data queries, and improves data processing efficiency.

[0154] In one embodiment of this disclosure, the data processing method can be applied to execute on the device where the data query engine resides. In some embodiments, the data query engine can be a big data query engine, such as Presto, Hive, etc.

[0155] In one embodiment of this disclosure, a communication connection can be established between the data query engine and the Journalnode node. Initially, the data query engine retrieves metadata corresponding to a specified directory from the Namenode node. It should be noted that the specified directory can be a directory of interest to the data query engine. For example, the Presto query engine typically only focuses on a subset of directories in the distributed file system. This subset can be identified as the specified directory, and the metadata corresponding to that specified directory can be retrieved from the Namenode node and stored in the local storage medium. That is, the specified directory can be the directory targeted by the data query, not all directories on the Namenode node. Furthermore, the journalnode node of the distributed file system can be periodically checked to ensure that when the metadata corresponding to the specified directory is updated, it is promptly synchronized to the local storage medium, keeping the metadata on the local storage medium of the data storage engine synchronized with the metadata in the distributed file system. During data querying and other processing, the data query engine can retrieve the metadata of the data to be queried from the local storage medium and then directly retrieve the data to be queried from the Datanode node of the distributed file system based on the metadata. It should be noted that the metadata recorded by the namenode node includes the location information of each block in each file. This location information corresponds to the datanode nodes in the distributed file system. However, it does not permanently store the block location information; this information is reconstructed based on the datanode information when the namenode node starts. Therefore, the data engine also needs to periodically check whether the namenode has restarted. Upon detecting a namenode restart, it can retrieve the metadata corresponding to the specified directory from the namenode again. Understandably, to reduce data waiting and transmission, this embodiment retrieves the updated metadata information for the specified directory from the journalnode node, rather than retrieving the full metadata for the specified directory from the namenode node each time.

[0156] In one embodiment of this disclosure, a user can request data from a distributed file system via a client to a data query engine. The received data query request may include a directory containing the user's query data. This directory may be a file directory within the distributed file system, and the data query request may also include the data to be queried within that directory. The data query request searches the local storage medium based on this directory to determine if the metadata of the directory is pre-stored on the local storage medium. If it is pre-stored, the location information of the data to be queried can be directly determined using the metadata of the directory stored on the local storage medium. This location information can be understood as the Datanode node where the data to be queried is located in the distributed file system. In other words, after the data query engine determines the information of the Datanode node where the data to be queried is located based on the metadata stored on the local storage medium, it can directly communicate with that Datanode node to obtain the data to be queried without remotely accessing the Namenode node.

[0157] In an optional implementation of this disclosure, step S302, namely, periodically detecting the update information of the Journalnode node of the distributed file system, includes:

[0158] The journal node periodically retrieves the edit log file from the Journalnode node of the distributed file system; the edit log file is obtained by the Journalnode node from the Namenode node.

[0159] The currently acquired edit log file is compared with the previously acquired edit log file to determine the update information.

[0160] In this optional implementation, when the Namenode node (acting as the active node) has updated metadata, it writes the corresponding log information of the update operation to an edit log file and sends the edit log file to the journalnode node, which stores the edit log file. The data query engine can periodically retrieve the edit log file from the journalnode and compare it with the previously retrieved edit log file stored on the local storage medium. If they do not match, it can be assumed that the edit log file on the journalnode node has been updated. Based on the updated edit log file, it can determine whether the metadata corresponding to the specified directory has been updated. If it has been updated, the metadata corresponding to the specified directory is updated to the local storage medium, and the edit log file can be stored locally for comparison with the next retrieved edit log file. If it has not been updated, the edit log file can be stored directly without updating the metadata corresponding to the specified directory stored on the local storage medium.

[0161] In an optional implementation of this disclosure, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; step S302, namely, periodically detecting the update information of the Journalnode nodes of the distributed file system, includes:

[0162] Periodically obtain update information from the 2n+1 Journalnode nodes;

[0163] When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined to be the update information from the Journalnode nodes of the distributed file.

[0164] In this optional implementation, to ensure that the updated metadata on the Active Namenode is synchronized to the Journalnodes, 2n+1 Journalnodes can be set, where n is a natural number greater than or equal to 1. The Active Namenode will simultaneously send the edit log file to the 2n+1 Journalnodes. Once n+1 of the 2n+1 Journalnodes successfully receive and save the edit log file, the edit log file can be considered successfully synchronized. At this point, the Standby Namenode can retrieve the edit log file from the Journalnodes and synchronize and update its local metadata to keep the Active Namenode synchronized. Otherwise, the edit log file can be considered not successfully written, and the Active Namenode can resend the edit log file to the Journalnodes or perform other synchronization operations such as data rollback.

[0165] Similarly, to ensure that the edit log files on the Journalnode nodes are synchronized with the metadata on the Active Namenode nodes, the data query engine can obtain edit log files from 2n+1 Journalnode nodes. By comparing these 2n+1 edit log files, if the content of any n+1 edit log files is the same, the edit log file is considered the latest edit log file. Based on this edit log file, the update information of the metadata corresponding to the specified directory is determined. Otherwise, the edit log file obtained this time can be discarded, and the above process will be repeated after the edit log file is obtained from the Journalnode nodes again.

[0166] In an optional implementation of this disclosure, step S303, namely, after determining that the metadata of the specified directory has been updated based on the update information, synchronizing the updated metadata of the specified directory to the local storage medium, includes:

[0167] The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and stored on the local storage medium; the checkpoint file stores the metadata of the specified directory after the last update.

[0168] In this optional implementation, when the edit log file obtained from the Journalnode node includes update information corresponding to the metadata of the specified directory, the information of the file data corresponding to the specified directory in the edit log file can be merged with the checkpoint file. The checkpoint file contains the metadata of the specified directory stored in local storage after the last update. By merging the latest update information of the metadata of the specified directory with the original metadata of the specified directory, the latest metadata of the specified directory can be obtained. In some embodiments, the checkpoint file can be the metadata of the specified directory in the namespace image file stored on the Namenode node.

[0169] In one optional implementation of this disclosure, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0170] Figure 3 The technical terms and technical features involved in the illustrated and related embodiments are consistent with Figures 1-2 The technical terms and technical features mentioned in the illustrated and related embodiments are the same or similar, for Figure 2 The explanations and descriptions of the technical terms and features involved in the illustrated and related embodiments can be found in the above-mentioned... Figures 1-2 The explanations of the illustrated and related embodiments are not repeated here.

[0171] Figure 4 A flowchart illustrating the overall process of a data query method according to an embodiment of this disclosure is shown. Figure 4 As shown, the data query engine retrieves the metadata corresponding to the specified directory from the Namenode node of the distributed file system and stores it on local storage. Then, it periodically retrieves the updated metadata information for the specified directory from the journalnode node and updates the metadata on the local storage medium, ensuring that the metadata of the specified directory stored on the local storage medium is synchronized with the metadata of the specified directory on the Namenode node. Upon receiving a query request from a user client, the data query engine first checks whether the metadata on the local storage medium includes the metadata corresponding to the directory to be queried. If it does, it directly determines the Datanode node where the queried data resides based on the metadata stored on the local storage medium and then retrieves the queried data from that Datanode node.

[0172] The following are embodiments of the apparatus disclosed herein, which can be used to execute embodiments of the method disclosed herein.

[0173] Figure 5This diagram illustrates a structural block diagram of a data processing apparatus according to an embodiment of the present disclosure. This apparatus can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 5 As shown, the data processing device includes:

[0174] The first acquisition module 501 is configured to acquire metadata of a specified directory from the Namenode node of the distributed file system and store it on the local storage medium.

[0175] The first detection module 502 is configured to periodically detect the update information of the Journalnode node of the distributed file system;

[0176] The first determining module 503 is configured to, after determining that the metadata of the specified directory has been updated based on the update information, synchronize the updated metadata of the specified directory to the local storage medium.

[0177] In one embodiment of this disclosure, the data processing apparatus can be adapted to be executed on the device where the data query engine resides.

[0178] In one embodiment of this disclosure, the first detection module includes:

[0179] The first acquisition submodule is configured to periodically acquire edit log files from the Journalnode node of the distributed file system; the edit log files are acquired by the Journalnode node from the Namenode node;

[0180] The first comparison submodule is configured to compare the currently acquired edit log file with the previously acquired edit log file to determine the update information.

[0181] In one embodiment of this disclosure, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; the first detection module includes:

[0182] The second acquisition submodule is configured to periodically acquire update information from the 2n+1 Journalnode nodes;

[0183] The first determining submodule is configured to determine the update information of any n+1 Journalnode nodes as the update information from the Journalnode nodes of the distributed file when the update information of any n+1 Journalnode nodes is the same.

[0184] In one embodiment of this disclosure, the first determining module includes:

[0185] The first merging submodule is configured to merge the edit log file obtained from the Journalnode node with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and store it on the local storage medium; the checkpoint file stores the metadata of the specified directory after the last update.

[0186] In one embodiment of this disclosure, the specified directory is the directory targeted by a local data query engine.

[0187] Figure 6 The diagram illustrates a structural block diagram of a data query device according to an embodiment of the present disclosure. This device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 6 As shown, the data query device includes:

[0188] The first receiving module 601 is configured to receive a data query request for a distributed file system; the data query request includes a directory to be queried in the distributed file system.

[0189] The lookup module 602 is configured to look up metadata corresponding to the directory to be queried from the local storage medium;

[0190] The second determining module 603 is configured to, after finding the metadata of the directory to be queried in the local storage medium, determine the Datanode node where the data to be queried in the directory to be queried in the distributed file system is located based on the metadata.

[0191] The second acquisition module 604 is configured to request the data to be queried from the Datanode node under the directory to be queried.

[0192] In one embodiment of this disclosure, the data query device can be adapted to be executed on the device where the data query engine is located.

[0193] In one embodiment of this disclosure, the metadata of the directory to be queried is obtained in advance from the Journalnode node of the distributed file system and stored in the local storage medium.

[0194] In one embodiment of this disclosure, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0195] Figure 7 This diagram illustrates a structural block diagram of a data query apparatus according to another embodiment of the present disclosure. This apparatus can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 7 As shown, the data query device includes:

[0196] The third acquisition module 701 is configured to acquire metadata of a specified directory from the Namenode node of the distributed file system and store it on the local storage medium.

[0197] The second detection module 702 is configured to periodically detect the update information of the Journalnode node of the distributed file system;

[0198] The third determining module 703 is configured to, after determining that the metadata of the specified directory has been updated based on the update information, synchronize the updated metadata of the specified directory to the local storage medium.

[0199] The second receiving module 704 is configured to receive a data query request for the distributed file system; the data query request includes a directory to be queried in the distributed file system.

[0200] The fourth determining module 705 is configured to determine the metadata of the directory to be queried based on the metadata of the specified directory when the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory;

[0201] The fifth determining module 706 is configured to determine the Datanode node where the data to be queried is located in the directory to be queried in the distributed file system based on the metadata of the directory to be queried.

[0202] The fourth acquisition module 707 is configured to request and retrieve the data to be queried from the Datanode node under the directory to be queried.

[0203] In one embodiment of this disclosure, the data query device can be adapted to be executed on the device where the data query engine is located.

[0204] The second detection module includes:

[0205] The third acquisition submodule is configured to periodically acquire edit log files from the Journalnode node of the distributed file system; the edit log files are acquired by the Journalnode node from the Namenode node;

[0206] The second comparison submodule is configured to compare the currently acquired edit log file with the previously acquired edit log file to determine the update information.

[0207] In one embodiment of this disclosure, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; the second detection module includes:

[0208] The fourth acquisition submodule is configured to periodically acquire update information from the 2n+1 Journalnode nodes;

[0209] The second determining submodule is configured to determine the update information of any n+1 Journalnode nodes as the update information from the Journalnode nodes of the distributed file when the update information of any n+1 Journalnode nodes is the same.

[0210] In one embodiment of this disclosure, the third determining module includes:

[0211] The second merging submodule is configured to merge the edit log file obtained from the Journalnode with the checkpoint file on the local storage medium to form updated metadata for the specified directory, and store it on the local storage medium.

[0212] In one embodiment of this disclosure, the specified directory is the directory targeted by a local data query engine.

[0213] In one embodiment of this disclosure, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0214] Figure 8 The diagram illustrates a structural block diagram of a data query system according to an embodiment of the present disclosure. This system can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 8 As shown, the data query system includes: a data query engine 801 and a distributed file system 802;

[0215] The data query engine obtains the metadata of the specified directory from the Namenode node of the distributed file system and saves it on the local storage medium.

[0216] The data query engine periodically detects the update information of the Journalnode node of the distributed file system;

[0217] After the data query engine determines that the metadata of the specified directory has been updated based on the update information, it synchronizes the updated metadata of the specified directory to the local storage medium.

[0218] The data query engine receives a data query request for the distributed file system; the data query request includes the directory to be queried in the distributed file system.

[0219] When the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory, the data query engine determines the metadata of the directory to be queried based on the metadata of the specified directory.

[0220] The data query engine determines the Datanode node where the directory to be queried is located in the distributed file system based on the metadata of the directory to be queried.

[0221] The data query engine requests the data to be queried from the Datanode node.

[0222] In one embodiment of this disclosure, the data query system is applicable to the process of a user querying data on a distributed storage system through a client of a data query engine.

[0223] In one embodiment of this disclosure, the data query engine periodically detects the update information of the Journalnode nodes of the distributed file system, including:

[0224] The data query engine periodically retrieves edit log files from the Journalnode node of the distributed file system; the edit log files are obtained by the Journalnode node from the Namenode node.

[0225] The data query engine compares the currently obtained edit log file with the previously obtained edit log file to determine the update information.

[0226] In one embodiment of this disclosure, the distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; the data query engine periodically detects update information on the Journalnode nodes of the distributed file system, including:

[0227] The data query engine periodically obtains updated information from the 2n+1 Journalnode nodes;

[0228] When the update information of any n+1 Journalnode nodes is the same, the data query engine determines the update information of the any n+1 Journalnode nodes as the update information from the Journalnode nodes of the distributed file.

[0229] In one embodiment of this disclosure, after the data query engine determines that the metadata of the specified directory has been updated based on the update information, it synchronizes the updated metadata of the specified directory to the local storage medium, including:

[0230] The data query engine merges the edit log file obtained from the Journalnode with the checkpoint file on the local storage medium to form updated metadata for the specified directory, and stores it on the local storage medium.

[0231] In one embodiment of this disclosure, the specified directory is the directory targeted by a local data query engine.

[0232] In one embodiment of this disclosure, the metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

[0233] The technical features and their corresponding explanations and descriptions involved in the above-described device embodiments and system embodiments are the same as, corresponding to, or similar to the technical features and their corresponding explanations and descriptions involved in the above-described method embodiments. For the technical features and their corresponding explanations and descriptions involved in the above-described device embodiments and system embodiments, please refer to the technical features and their corresponding explanations and descriptions involved in the above-described method embodiments. This disclosure will not repeat them here.

[0234] This disclosure also discloses an electronic device, which includes a memory and a processor; wherein...

[0235] The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement any of the above method steps.

[0236] Figure 9 This is a schematic diagram of the structure of a computer system suitable for implementing a data processing method and / or data query method according to an embodiment of the present disclosure.

[0237] like Figure 9 As shown, the computer system 900 includes a processing unit 901, which can execute various processes described above based on a program stored in a read-only memory (ROM) 902 or a program loaded from a storage section 908 into a random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the computer system 900. The processing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0238] The following components are connected to I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 910 as needed so that computer programs read from it can be installed into storage section 908 as needed. The processing unit 901 can be implemented as a CPU, GPU, TPU, FPGA, NPU, etc.

[0239] In particular, according to embodiments of this disclosure, the methods described above can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program tangibly embodied on a readable medium thereof, the computer program containing program code for performing the data transmission method. In such embodiments, the computer program can be downloaded and installed from a network via communication section 909, and / or installed from removable medium 911.

[0240] This disclosure also discloses a computer program product, which includes a computer program / instructions that, when executed by a processor, implement any of the above-described method steps.

[0241] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0242] The units or modules described in the embodiments of this disclosure can be implemented in software or hardware. The described units or modules can also be located in a processor, and the names of these units or modules do not necessarily constitute a limitation on the unit or module itself.

[0243] In another aspect, embodiments of this disclosure also provide a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus described in the above embodiments; or it may be a standalone computer-readable storage medium not assembled into a device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to perform the methods described in embodiments of this disclosure.

[0244] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in the embodiments of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in the embodiments of this disclosure.

Claims

1. A data processing method, wherein the method runs on a data query engine, the data query engine queries data from a distributed file system; the distributed file system includes Datanode nodes, Journalnode nodes, and Namenode nodes, the Datanode nodes are used to store files in the distributed file system, the Namenode nodes are used to store metadata of directories corresponding to the files, and after the metadata of files and directories in the distributed file system is updated, the update information is written to the Journalnode nodes; the method includes: Obtain the metadata of the specified directory from the Namenode node and save it on the local storage medium; The local storage medium is the storage medium on the local device where the data query engine is located; Establish a communication connection with the Journalnode node; Periodically check the update information of the Journalnode node; After determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium. The distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; periodically detecting updates on the Journalnode nodes of the distributed file system includes: Periodically obtain update information from the 2n+1 Journalnode nodes; When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined as the update information from the Journalnode nodes of the distributed file; Specifically, after determining that the metadata of the specified directory has been updated based on the update information, synchronizing the updated metadata of the specified directory to the local storage medium includes: The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and stored on the local storage medium; the checkpoint file stores the metadata of the specified directory after the last update; Specifically, when the data query engine queries data under the directory to be queried, and the metadata corresponding to the directory to be queried is stored in the local storage medium, it directly obtains the data to be queried from the Datanode node of the distributed file system based on the metadata corresponding to the directory to be queried stored in the local storage medium, without having to remotely access the Namenode node to obtain the metadata of the directory to be queried and then obtain the data to be queried from the Datanode node.

2. The method according to claim 1, wherein, The specified directory is the directory targeted by the local data query engine.

3. A data query method, wherein the method runs on a data query engine, the data query engine queries data from a distributed file system; the distributed file system includes Datanode nodes, Journalnode nodes, and Namenode nodes, the Datanode nodes are used to store files in the distributed file system, the Namenode nodes are used to store metadata of directories corresponding to the files, and after the metadata of files and directories in the distributed file system is updated, the update information is written to the Journalnode nodes; the method includes: Obtain the metadata of the specified directory from the Namenode node and save it on the local storage medium; The local storage medium is the storage medium on the local device where the data query engine is located; Establish a communication connection with the Journalnode node; Periodically check the update information of the Journalnode node; After determining that the metadata of the specified directory has been updated based on the update information, the updated metadata of the specified directory is synchronized to the local storage medium. Receive data query requests for the distributed file system; The data query request includes the directory to be queried in the distributed file system; When the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory, the metadata of the directory to be queried is determined based on the metadata of the specified directory; Based on the metadata of the directory to be queried, determine the Datanode node where the data to be queried under the directory to be queried is located in the distributed file system; Request the data to be queried from the directory to be queried from the Datanode node; The distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; periodically detecting updates on the Journalnode nodes of the distributed file system includes: Periodically obtain update information from the 2n+1 Journalnode nodes; When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined as the update information from the Journalnode nodes of the distributed file; Specifically, after determining that the metadata of the specified directory has been updated based on the update information, synchronizing the updated metadata of the specified directory to the local storage medium includes: The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and then stored on the local storage medium. Specifically, when the data query engine queries data under the directory to be queried, and the metadata corresponding to the directory to be queried is stored in the local storage medium, it directly obtains the data to be queried from the Datanode node of the distributed file system based on the metadata corresponding to the directory to be queried stored in the local storage medium, without having to remotely access the Namenode node to obtain the metadata of the directory to be queried and then obtain the data to be queried from the Datanode node.

4. The method according to claim 3, wherein, The specified directory is the directory targeted by the local data query engine.

5. The method according to claim 3, wherein, The metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

6. A data query system, comprising: A data query engine and a distributed file system; the data query engine queries data from the distributed file system; The distributed file system includes Datanode nodes, Journalnode nodes, and Namenode nodes. The Datanode nodes are used to store files in the distributed file system, and the Namenode nodes are used to store metadata corresponding to the directories of the files. When the metadata of the files and directories in the distributed file system is updated, the update information is written to the Journalnode nodes. The data query engine obtains the metadata of the specified directory from the Namenode node of the distributed file system and saves it on the local storage medium; the local storage medium is the storage medium on the local device where the data query engine is located. The data query engine periodically detects the update information of the Journalnode node of the distributed file system; After the data query engine determines that the metadata of the specified directory has been updated based on the update information, it synchronizes the updated metadata of the specified directory to the local storage medium. The data query engine receives data query requests for the distributed file system; The data query request includes the directory to be queried in the distributed file system; When the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory, the data query engine determines the metadata of the directory to be queried based on the metadata of the specified directory. The data query engine determines the Datanode node where the directory to be queried is located in the distributed file system based on the metadata of the directory to be queried. The data query engine requests and retrieves the data to be queried from the Datanode node in the directory to be queried. The distributed file system comprises 2n+1 Journalnode nodes, where n is a natural number; the data query engine periodically detects updates on the Journalnode nodes of the distributed file system, including: The data query engine periodically obtains updated information from the 2n+1 Journalnode nodes; When the update information of any n+1 Journalnode nodes is the same, the data query engine determines the update information of the any n+1 Journalnode nodes as the update information from the Journalnode nodes of the distributed file; Wherein, after the data query engine determines that the metadata of the specified directory has been updated based on the update information, it synchronizes the updated metadata of the specified directory to the local storage medium, including: The data query engine merges the edit log file obtained from the Journalnode with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and stores it on the local storage medium. Specifically, when the data query engine queries data under the directory to be queried, and the metadata corresponding to the directory to be queried is stored in the local storage medium, it directly obtains the data to be queried from the Datanode node of the distributed file system based on the metadata corresponding to the directory to be queried stored in the local storage medium, without having to remotely access the Namenode node to obtain the metadata of the directory to be queried and then obtain the data to be queried from the Datanode node.

7. The system according to claim 6, wherein, The specified directory is the directory targeted by the local data query engine.

8. The system according to claim 6, wherein, The metadata of the directory to be queried in the local storage medium is kept synchronized with the data on the Namenode node in the distributed file system.

9. A data processing apparatus, wherein the apparatus is located in a data query engine, the data query engine queries data from a distributed file system; the distributed file system includes Datanode nodes, Journalnode nodes, and Namenode nodes, the Datanode nodes are used to store files in the distributed file system, the Namenode nodes are used to store metadata of directories corresponding to the files, and after the metadata of the files and directories in the distributed file system is updated, the update information is written to the Journalnode nodes; The device includes: The first acquisition module is configured to acquire metadata of a specified directory from the Namenode node and store it on a local storage medium; the local storage medium is the storage medium on the local device where the data query engine is located. The first detection module is configured to periodically detect the update information of the Journalnode node; The first determining module is configured to, after determining that the metadata of the specified directory has been updated based on the update information, synchronize the updated metadata of the specified directory to the local storage medium. The distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; the first detection module is implemented as follows: Periodically obtain update information from the 2n+1 Journalnode nodes; When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined as the update information from the Journalnode nodes of the distributed file; The first determining module is implemented as follows: The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and then stored on the local storage medium. Specifically, when the data query engine queries data under the directory to be queried, and the metadata corresponding to the directory to be queried is stored in the local storage medium, it directly obtains the data to be queried from the Datanode node of the distributed file system based on the metadata corresponding to the directory to be queried stored in the local storage medium, without having to remotely access the Namenode node to obtain the metadata of the directory to be queried and then obtain the data to be queried from the Datanode node.

10. A data query device, wherein the device is located in a data query engine, the data query engine queries data from a distributed file system; the distributed file system includes Datanode nodes, Journalnode nodes, and Namenode nodes, the Datanode nodes are used to store files in the distributed file system, the Namenode nodes are used to store metadata of directories corresponding to the files, and after the metadata of files and directories in the distributed file system is updated, the update information is written to the Journalnode nodes; The device includes: The third acquisition module is configured to acquire metadata of a specified directory from the Namenode node and store it on a local storage medium; the local storage medium is the storage medium on the local device where the data query engine is located. The connection establishment module is configured to establish a communication connection with the Journalnode node; The second detection module is configured to periodically detect the update information of the Journalnode node; The third determining module is configured to, after determining that the metadata of the specified directory has been updated based on the update information, synchronize the updated metadata of the specified directory to the local storage medium. The second receiving module is configured to receive a data query request for the distributed file system; the data query request includes a directory to be queried in the distributed file system. The fourth determining module is configured to determine the metadata of the directory to be queried based on the metadata of the specified directory when the directory to be queried is the same as the specified directory or belongs to a subdirectory of the specified directory; The fifth determining module is configured to determine the Datanode node where the data to be queried is located in the directory to be queried in the distributed file system based on the metadata of the directory to be queried. The fourth acquisition module is configured to request and retrieve the data to be queried from the Datanode node under the directory to be queried; The distributed file system includes 2n+1 Journalnode nodes, where n is a natural number; the second detection module is implemented as follows: Periodically obtain update information from the 2n+1 Journalnode nodes; When the update information of any n+1 Journalnode nodes is the same, the update information of the any n+1 Journalnode nodes is determined as the update information from the Journalnode nodes of the distributed file; The third determining module is implemented as follows: The edit log file obtained from the Journalnode node is merged with the checkpoint file on the local storage medium to form the updated metadata of the specified directory, and then stored on the local storage medium. Specifically, when the data query engine queries data under the directory to be queried, and the metadata corresponding to the directory to be queried is stored in the local storage medium, it directly obtains the data to be queried from the Datanode node of the distributed file system based on the metadata corresponding to the directory to be queried stored in the local storage medium, without having to remotely access the Namenode node to obtain the metadata of the directory to be queried and then obtain the data to be queried from the Datanode node.

11. An electronic device comprising a memory and a processor; wherein, The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the steps of the method according to any one of claims 1-5.

12. A computer-readable storage medium having stored thereon computer instructions, wherein, When executed by a processor, the computer instructions implement the steps of the method according to any one of claims 1-5.

13. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Metadata synchronization method and system

    CN110535907A

  • Data management method and device, storage medium and electronic equipment

    CN113761294A