Configuration file analysis method and electronic equipment
By using a shared memory mechanism, the first storage process parses and stores the configuration file data, and subsequent processes quickly map and verify it, which solves the problem of slow configuration file parsing speed in a multi-process environment and improves the startup speed of business software and system availability.
Patent Information
- Application Number
- CN202511497038.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-10-20
AI Technical Summary
When the business software starts up, multiple storage processes need to spend a lot of time parsing configuration files, resulting in a slow startup speed.
Through the shared memory mechanism, the first storage process parses the configuration file and stores the data in shared memory. Subsequent processes quickly find and map the memory segment by the file identifier to obtain the data and perform verification processing, avoiding repeated parsing and disk reads.
This reduces the overall time spent by multiple storage processes parsing configuration files during startup, improving the startup speed of business software and the overall availability of the system.
Smart Images

Figure CN120994624A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and particularly relates to a configuration file parsing method and an electronic device. BACKGROUND
[0002] For a multi-control storage system, a business software needs to read and parse a configuration file in a starting process, and configure the storage system according to the content in the configuration file. Since the content of the configuration file is relatively large, when the business software needs to read the content of the configuration file in a running process, the reading speed is relatively slow, and the efficiency is low. In particular, when the business software starts, multiple storage processes need to spend a lot of time to parse the configuration file, resulting in a relatively low starting speed of the business software.
[0003] Therefore, how to improve the parsing speed of the storage process on the configuration file when the business software starts, and further improve the starting speed of the business software is a problem to be solved at present. SUMMARY
[0004] The present application provides a configuration file parsing method and an electronic device to at least solve the problem of how to improve the parsing speed of the storage process on the configuration file when the business software starts, and further improve the starting speed of the business software in the related art.
[0005] The present application provides a configuration file parsing method, comprising: obtaining a file identifier of a target configuration file that needs to be read by a storage process, wherein the file identifier is constructed based on identification information of the target configuration file and a file path for accessing a shared memory, and the shared memory is used to store file data obtained by a historical storage process by parsing the target configuration file, and the historical storage process is a process that needs to read the target configuration file for the first time before the storage process; in response to being able to find a target memory segment identifier containing the file identifier in the shared memory, mapping a target memory segment corresponding to the target memory segment identifier to the storage process to extract the file data from the target memory segment, wherein the target memory segment is a memory area in the shared memory that stores the file data; in response to a verification result of the verification processing on the file data satisfying a preset verification condition, determining the file data as target data read by the storage process.
[0006] The present application also provides a configuration file parsing device, comprising: an obtaining unit, configured to obtain a file identifier of a target configuration file that needs to be read by a storage process, wherein the file identifier is constructed based on identification information of the target configuration file and a file path for accessing a shared memory, and the shared memory is used to store file data obtained by a historical storage process by parsing the target configuration file, and the historical storage process is a process that needs to read the target configuration file for the first time before the storage process; mapping, in response to being able to find the target memory segment identifier containing the file identifier in the shared memory, a target memory segment corresponding to the target memory segment identifier to the storage process to extract file data from the target memory segment, wherein the target memory segment is a memory area in the shared memory storing the file data; determining, in response to the verification result of the verification processing on the file data satisfying a preset verification condition, the file data as target data read by the storage process.
[0007] The application further provides an electronic device, comprising a memory for storing a computer program and a processor for executing the computer program to implement the steps of the configuration file parsing method.
[0008] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the configuration file parsing method.
[0009] The application further provides a computer program product, comprising a computer program, and the computer program is executed by a processor to implement the steps of the configuration file parsing method.
[0010] The configuration file parsing method and the electronic device provided by the application store the parsed file data in the shared memory by the first storage process needing to read the configuration file, and provide a quick search, memory mapping and data verification mechanism based on the file identifier for subsequent storage processes, so that the subsequent storage processes do not need to repeatedly perform the time-consuming operation of reading and parsing the configuration file from the disk, thereby reducing the overall time of parsing the configuration file in the startup stage of multiple storage processes, and effectively improving the startup speed of the business software. Therefore, the technical problem of how to improve the parsing speed of the configuration file by the storage process during the startup of the business software, and thereby improve the startup speed of the business software, can be solved, and the technical effect of improving the parsing speed of the configuration file by the storage process, and thereby improving the startup speed of the business software, is achieved. BRIEF DESCRIPTION OF DRAWINGS
[0011] In order to more clearly illustrate the embodiments of the application, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0012] Figure 1 A flowchart of a configuration file parsing method provided by an embodiment of the application; Figure 2A flowchart of reading configuration file data provided by an embodiment of the present application is shown in FIG. 1. Figure 3 A structural diagram of a configuration file analysis device provided by an embodiment of the present application is shown in FIG. 2. Figure 4 A structural diagram of another configuration file analysis device provided by an embodiment of the present application is shown in FIG. 3. DETAILED DESCRIPTION
[0013] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, any other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.
[0014] It should be noted that, in the description of the present application, the terms “comprise”, “contain” or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. The terms “first”, “second” and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0015] In order for those skilled in the art to better understand the technical solutions of the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments.
[0016] The configuration file analysis method and electronic device of the present application are at least applicable to the scenario where multiple storage processes in a multi-control storage system need to repeatedly read the same configuration file. The storage process refers to a software process that executes specific business logic in the storage system. This process needs to obtain configuration information to complete system initialization or function adjustment during startup or running. In the related art, each storage process needs to independently read and analyze the configuration file from the disk, resulting in high system Input / Output (I / O) load and low startup efficiency.
[0017] Figure 1 A flowchart of a configuration file analysis method provided by an embodiment of the present application is shown in FIG. 4. The method will be described in detail in combination with the execution flow of the configuration file analysis method.
[0018] As shown in FIG. 5, the configuration file analysis method comprises the following steps. Figure 1 At step 101, a file identifier of a target configuration file required to be read by the storage process is acquired, wherein the file identifier is constructed based on identification information of the target configuration file and a file path for accessing a shared memory, and the shared memory is used to store file data obtained by a historical storage process by parsing the target configuration file, and the historical storage process is a process that initially requires to read the target configuration file before the storage process.
[0019] In the embodiments of the present application, the target configuration file refers to a setting file required for the operation of a storage system, and the content thereof includes but is not limited to: key parameters such as CPU binding strategy, hardware support characteristics, or interrupt processing configuration. The file identifier is a unique identification symbol, which is constructed by combining the identification information of the target configuration file with a predefined file path. The identification information can be characteristic data such as the name, version number, or content hash value of the target configuration file; and the file path is an access path to the shared memory space of the storage system, which is used to locate the public memory area storing the historical parsing result.
[0020] The shared memory is a cross-process data sharing memory provided by the storage system, which has an efficient inter-process communication mechanism. Unlike the process private memory, it allows multiple storage processes to share the same memory area, and multiple storage processes can directly read and write data in the memory area without the need for data transmission through other intermediate media (such as disk or network), thereby greatly improving the efficiency of inter-process data sharing. Importantly, the data in the shared memory will not be released or tampered with due to the end, restart, or failure of a single storage process, and can be kept effective between multiple storage processes for a long time.
[0021] The historical storage process refers to the first process that requires to read the target configuration file before the current storage process is running. The historical storage process is responsible for completing the initial parsing of the target configuration file and writing the parsing result to the shared memory, thereby providing data support for all subsequent storage processes that need to access the target configuration file, and avoiding the process of reading and parsing the target configuration file from the system disk by all storage processes.
[0022] It should be noted that the target configuration file is a specific configuration file required to be read and parsed by the current storage process in a specific business scenario, for example, when a storage process needs to enable the NAS (Network Attached Storage) feature, the corresponding NAS feature configuration file is the target configuration file of the storage process. The target configuration files required by different storage processes or the same storage process in different business stages may be different.
[0023] In response to finding the target memory segment identifier containing the file identifier in the shared memory, the target memory segment corresponding to the target memory segment identifier is mapped to the storage process to extract the file data from the target memory segment, where the target memory segment is a memory region in the shared memory storing the file data.
[0024] In the embodiments of the present application, the target memory segment identifier is information for uniquely identifying a certain specific memory region in the shared memory, and is used to identify the memory region storing the file data of the target configuration file. Each memory region storing specific data (such as the file data of a certain target configuration file) in the shared memory corresponds to a memory segment identifier, and through the memory segment identifier, the corresponding memory region can be accurately found, and mapping, reading and writing operations can be performed on the memory region.
[0025] The target memory segment refers to a continuous address space in the shared memory actually storing the file data, and the content inside is organized according to a preset data structure. Through the memory mapping technology, the storage process can directly read the data in the target memory segment without going through the disk I / O operation. The file data is a structured data set obtained by parsing the target configuration file by the historical storage process, and the format of the file data includes but is not limited to key-value pairs, tree structures or binary sequences, etc. machine-readable forms.
[0026] The target memory segment identifier is the memory segment identifier corresponding to the target configuration file required by the current storage process. When the storage process finds the corresponding target memory segment identifier in the shared memory through the file identifier, it means that the file data obtained by parsing the target configuration file by the historical storage process has been stored in the shared memory, and the current storage process does not need to read and parse the target configuration file from the system disk.
[0027] When it is determined that the target memory segment identifier exists, the storage process will map the target memory segment corresponding to the target memory segment identifier to its own address space. After the mapping is completed, the current storage process can directly extract the file data from the target memory segment like accessing its own private memory, without the need for disk I / O operation and repeated file parsing process.
[0028] In response to the verification result of the verification process on the file data satisfying the preset verification condition, the file data is determined as the target data read by the storage process.
[0029] In the embodiments of the present application, the verification process includes but is not limited to checksum verification, version number comparison, data structure integrity check and other security mechanisms, which are used to ensure that the data in the shared memory is not damaged or tampered with. The preset verification condition is a predefined verification pass threshold, which is a pre-set standard for judging whether the file data is valid, such as cyclic redundancy check code matching, digital signature validity or data length meeting the expected range, etc. judgment standard.
[0030] The target data is valid data of a target configuration file that the current storage process eventually needs to obtain to complete its business function. When the result of the verification processing meets the preset verification condition, it means that the file data extracted from the target memory segment is complete, accurate and reliable. At this time, the storage process determines the file data as the target data, and performs subsequent business operations based on the target data, for example: according to the CPU core binding information in the target data, the binding of the business module and the specific CPU core is completed to ensure the efficiency of business processing; or according to the advanced feature support information in the target data, the NAS, automatic layering and other functions supported by the current model are enabled to meet the business needs of the system.
[0031] The application realizes cross-process reuse of configuration data through the shared memory mechanism. The disk reading and parsing operations that each process in the related technology needs to perform are optimized to be complete parsing performed only once by the first process, and the subsequent processes directly obtain the verified data through memory. This reduces repeated I / O operations and computing resource consumption, and in the scene of frequent system restart or fault recovery, it can effectively speed up the startup speed of the business process and improve the overall availability of the system. At the same time, by introducing a data verification link, efficient data sharing is realized on the premise of ensuring data reliability, and the consistency problem of configuration synchronization in a multi-process environment is solved.
[0032] In one implementation manner of the embodiment of the application, after obtaining the file identifier of the target configuration file that the storage process needs to read, the corresponding target memory segment identifier can not be directly found in the shared memory in all cases. When the target memory segment identifier cannot be found, the target configuration file needs to be read and parsed from the system disk, and the initial storage of the target configuration file data and the construction of the associated identifier are completed to provide a basis for subsequent storage processes to access the target configuration file.
[0033] Specifically, the following methods can be used, but are not limited to: in response to the target memory segment identifier not being found in the shared memory, the storage process reads the target configuration file from a preset database, wherein the preset database stores a plurality of configuration files; the target configuration file is subjected to file parsing processing to obtain file data, and the file data is stored in a first memory segment of the shared memory, wherein the first memory segment is any blank memory segment in the plurality of memory segments included in the shared memory; a first check code is generated based on the file data in the first memory segment, and the first check code is stored in the first memory segment; and a first memory segment identifier corresponding to the first memory segment is constructed according to the file identifier and the first memory segment information of the first memory segment.
[0034] In the embodiments of the present application, when the storage process cannot find the target memory segment identifier corresponding to the target configuration file in the shared memory, it indicates that the analysis result of the configuration file does not exist in the shared memory, at which time the complete configuration file reading and analysis process needs to be performed, which guides the storage process to obtain the original configuration file from the preset database. The preset database is a storage medium used by the storage system to centrally manage all configuration files, and is usually located in the system disk or non-volatile memory, and is internally organized to store multiple configuration files according to a specific directory structure or database table structure. The configuration file includes but is not limited to system hardware configuration parameters, function feature switch settings, or performance tuning parameters, and other key information.
[0035] After successfully reading the target configuration file from the preset database, the storage process will perform file parsing processing on the file content. File parsing processing refers to the process of converting a configuration file in text format or a specific encoding format into structured data available to a machine. The file parsing processing process includes but is not limited to syntax analysis, semantic analysis, data type conversion, and data integrity checking, and other processing stages. The file data obtained through parsing processing will be stored in a specific area of the shared memory, i.e., the first memory segment. The first memory segment refers to a blank memory area in the shared memory that is currently not occupied, and its capacity needs to be dynamically allocated or pre-set according to the size of the data amount after configuration file parsing. The shared memory is usually divided into multiple memory segments of the same size or different sizes to support the simultaneous storage of the analysis results of multiple configuration files.
[0036] To ensure that subsequent processes can verify the correctness of the read data, a first check code will be generated based on the file data stored in the first memory segment. The first check code is a digital fingerprint calculated by a preset check algorithm, and its generation principle is to perform mathematical operations on all bytes or specific fields of the file data to produce a unique code that can represent the characteristics of the data. Common check algorithms include but are not limited to cyclic redundancy check algorithm, hash function algorithm, or message digest algorithm, etc. The generated first check code will be stored in a designated location of the same first memory segment, forming a corresponding relationship with the file data, and constituting a complete data storage unit.
[0037] Finally, the first memory segment identifier will be constructed. The first memory segment information includes but is not limited to memory segment start address, segment size, access permission, and other management metadata, while the first memory segment identifier is a unique identifier formed by binding the management metadata with the file identifier. The first memory segment identifier will be registered in the global management table of the shared memory, so that subsequent other storage processes can quickly locate the first memory segment through the same file identifier when reading the same configuration file, thereby realizing effective reuse of the analysis result.
[0038] The present application explicitly indicates that when there is no required configuration data in the shared memory, the current process can autonomously complete the operation from reading, parsing to building the shared cache, at the same time, by persistently saving the parsing result in the shared memory, a reliable data sharing basis is established for the subsequent storage process, at the same time, the introduction of the check code provides a guarantee mechanism for data integrity, ensures that even if the shared memory is accidentally modified, data anomalies can be discovered in time through the check mechanism, and on the premise of ensuring data reliability, the minimization of configuration parsing workload is realized.
[0039] In an implementable manner of an embodiment of the present application, after completing the operation of mapping the target memory segment corresponding to the target memory segment identifier to the storage process and extracting the file data from the target memory segment, in order to ensure that the extracted file data is not damaged, tampered or data lost in the shared memory storage process, and to avoid the use of invalid data by the storage process leading to business initialization failure or storage system abnormal operation, the file data also needs to be reliably verified by the target check code.
[0040] Regarding the verification of the file data, the following methods can also be used, but are not limited to: extracting the target check code corresponding to the file data from the target memory segment, wherein the target check code is a cyclic check code generated based on the historical storage process after storing the file data to the target memory segment; performing data verification processing on the file data based on the target check code to obtain a verification result.
[0041] In an embodiment of the present application, the target check code is a verification identifier generated by the historical storage process when the file data is successfully stored into the target memory segment through a cyclic redundancy check algorithm. The cyclic redundancy check algorithm is an error detection method that calculates the data characteristic code through polynomial division, which can effectively identify bit errors, data tampering or storage medium abnormalities that may occur in the data transmission or storage process.
[0042] The storage location of the target check code is usually in the header or tail of the target memory segment, and it constitutes a complete data storage structure together with the file data. Its generation process is to calculate all the bytes of the file data bit by bit, and finally obtain a check value of fixed length, which is extremely sensitive to any slight change of the data and can be regarded as the digital fingerprint of the file data.
[0043] After obtaining the target check code, the data verification processing flow is started, and the data verification processing refers to the operation process of verifying the integrity of the current file data by using the extracted target check code. In specific implementation, the same cyclic redundancy check algorithm as the historical storage process is used to recalculate the file data read from the target memory segment to generate a new temporary check code, i.e. the check code to be verified. Then the newly calculated temporary check code is accurately compared with the previously extracted target check code, and the verification result is generated according to whether the two are consistent.
[0044] The verification result is a state identifier representing data integrity, and the judgment logic thereof follows a preset matching rule. If the two check codes are completely consistent, it indicates that the file data has not been changed since the historical storage process, and the verification result is marked as a pass state. If there is any difference, it indicates that the file data may be damaged due to memory errors, illegal access, or hardware failure, and the verification result is marked as a failure state.
[0045] The application provides protection for data reliability in shared memory through a verification mechanism based on cyclic redundancy check. Meanwhile, the verification process has small computational overhead and high detection efficiency, and does not affect the startup speed of the storage process, thereby maintaining the system performance advantage while ensuring data security.
[0046] In one implementation manner of the embodiment of the application, in a case where the data verification processing based on the target check code is completed on the file data, and it is determined that the verification result does not satisfy the preset verification condition, it means that the file data stored in the current target memory segment has lost reliability. For example, data damage or tampering occurs in the long-term storage process of the shared memory due to system abnormalities, memory access errors, or other problems, or the historical storage process has incomplete writing when initially storing data. At this time, if the file data is continued to be used, it will cause deviation of the business initialization of the storage process, and even cause business interruption of the multi-control storage system. Therefore, the data in the target memory segment needs to be repaired and updated to ensure that all subsequent storage processes that need to access the target configuration file can obtain complete and accurate file data.
[0047] Specifically, the following methods can also be used, but are not limited to: in response to the verification result not satisfying the preset verification condition, the storage process reads the target configuration file from the preset database, and performs file parsing processing on the target configuration file to obtain file data; the data in the target memory segment is deleted, and the file data is stored in the target memory segment; a second check code is generated based on the file data in the target memory segment, and the second check code is stored in the target memory segment.
[0048] In the embodiment of the application, when the verification result confirms that the preset verification condition is not satisfied, the storage process needs to be guided to read the target configuration file from the preset database again. After successfully reading the target configuration file, the storage process will start a complete file parsing processing flow. The file parsing processing process includes but is not limited to multiple stages such as syntax analysis, semantic parsing, and data structure conversion, to ensure that the configuration file in text format or a specific encoding format is converted into structured file data that can be directly used by the system. Unlike the initial parsing, this time the parsing is performed on the premise that the data may be damaged, so a stricter syntax checking rule or a more complete exception handling mechanism is enabled to exclude any factors that may cause data abnormalities.
[0049] After obtaining reliable file data through file parsing, a memory data update operation is performed to completely delete all existing data in the target memory segment. The deletion operation not only empties the data content, but also resets the memory segment index and metadata to ensure that no invalid information that may affect new data is left. Subsequently, the obtained file data is completely written into the emptied target memory segment. The writing process follows a preset memory writing protocol to ensure that the storage format of the data in the shared memory conforms to the data structure specification.
[0050] After the file data is successfully written into the target memory segment, a second check code is generated based on the new data. The second check code is a verification code recalculated using the same cyclic redundancy check algorithm as before, and its generation process covers the complete content of all file data in the target memory segment. The second check code has a strict correspondence with the file data, and any subsequent data modification will cause the check code to mismatch. The newly generated second check code is stored in a designated location of the target memory segment, and together with the file data, it constitutes the updated complete data unit.
[0051] The data recovery mechanism of the present application ensures the reliability of the configuration file data in the shared memory. When data anomalies are detected, instead of simply abandoning the use of shared memory, the normal state of the shared memory is restored by actively rebuilding the data, which not only solves the data needs of the current process, but also eliminates data obstacles for subsequent other processes. In the scenario of continuous operation and high availability requirement of the multi-control storage system, the system failure caused by a single data error can be effectively avoided, and the long-time stable operation of the storage business is guaranteed.
[0052] In one implementation manner of the embodiment of the present application, when the file data is verified based on the target check code, the following implementation manners can be used, but are not limited to: generating a to-be-verified check code based on the file data according to the storage process; performing check code matching processing on the target check code and the to-be-verified check code to obtain a check code matching result; in response to the check code matching result being that the target check code and the to-be-verified check code do not match, obtaining a first verification result, wherein the first verification result does not satisfy a preset verification condition; and in response to the check code matching result being that the target check code and the to-be-verified check code match, obtaining a second verification result, wherein the verification result includes the first verification result and the second verification result, and the second verification result satisfies the preset verification condition.
[0053] In the embodiments of the present application, the to-be-verified check code is a temporary verification identifier calculated in real time by the current storage process according to the file data extracted from the target memory segment through a specified check algorithm. The algorithm used to generate the to-be-verified check code is completely consistent with the algorithm used by the historical storage process to generate the target check code, for example, a cyclic redundancy check algorithm, to ensure that the two check codes are comparable under the same data conditions. The calculation process covers all byte contents of the file data, and any slight data change will cause the to-be-verified check code generated finally to change significantly.
[0054] Subsequently, a check code matching process is performed, which is an analysis process of accurately comparing the target check code with the to-be-verified check code. The comparison operation usually adopts a bit-by-bit comparison or a hash value comparison mechanism to ensure that any difference between the two check codes can be identified sensitively. The final check code matching result is a binary state identifier, which explicitly records whether the two check codes are completely consistent.
[0055] When the check code matching result shows that the target check code does not match the to-be-verified check code, a first verification result is generated. The first verification result indicates that the file data read from the shared memory does not match the original file data stored, which may be caused by memory bit flipping, unauthorized modification operation or data transmission error, etc. The first verification result is compiled into a verification failure state signal, which explicitly does not meet the preset verification condition, at this time, the current file data read from the shared memory will not be used, and a corresponding data recovery or reconstruction process will be triggered.
[0056] On the contrary, when the check code matching result confirms that the target check code completely matches the to-be-verified check code, a second verification result is generated. The second verification result indicates that the file data in the shared memory has maintained the complete original state since being stored, and has not been damaged or tampered in any form. The second verification result is compiled into a verification pass state signal, which completely meets the preset verification condition, at this time, the file data read from the shared memory is regarded as reliable and valid data, which can be directly used by the storage process.
[0057] The verification result generation process of the present application constitutes a complete data reliability evaluation system. The verification result serves as a decision basis to determine whether to accept the data in the shared memory or to start an alternative data acquisition scheme. Through the fine verification result distinction, different processing strategies can be adopted for file data in different quality states, which not only ensures the reliability of the file data, but also avoids unnecessary repeated parsing operations.
[0058] In an implementable manner of an embodiment of the present application, when performing file parsing processing on the target configuration file, the following manner can be adopted, but is not limited to: identifying the text encoding format and the structured syntax rule of the target configuration file; performing byte stream decoding on the target configuration file based on the text encoding format to obtain a standard character stream, performing syntax analysis on the standard character stream according to the structured syntax rule, and constructing a configuration option tree for representing the hierarchical relationship of configuration items in the target configuration file; serializing the configuration option tree into a serialized data stream satisfying a preset data format, wherein the preset data format is a data format decoupled from the structured syntax rule; and determining the serialized data stream as file data, wherein the file data can be directly parsed and used by any process supporting the preset data format.
[0059] In an embodiment of the present application, the purpose of file parsing processing is to convert the original target configuration file into a structured data form that can be directly used by multiple storage processes. When performing file parsing processing, the text encoding format and the structured syntax rule of the target configuration file need to be identified. The text encoding format refers to the character encoding scheme adopted by the target configuration file when stored, for example: Unicode Transformation Format - 8-bit (UTF-8), American Standard Code for Information Interchange (ASCII), or GBK, etc., and the text encoding format determines the way of converting byte sequences in the file into readable text characters. The structured syntax rule defines the organization structure and semantic specification of the configuration file, for example: the key-value pair hierarchy of JavaScript Object Notation (JSON) format, the tag nesting of eXtensible Markup Language (XML) format, or the section attribute of Initialization File (INI) format, and the structured syntax rule ensures that the configuration file content has a clear logical relationship and parseability.
[0060] After identifying the text encoding format, byte stream decoding operation is performed on the target configuration file based on the text encoding format. Byte stream decoding is the process of converting the original data in the target configuration file into a standard character stream according to a specific encoding rule, which eliminates the problem of garbled characters or parsing errors caused by encoding differences. The standard character stream is a continuous data stream composed of uniformly encoded characters, and its content completely retains the original information of the configuration file, but presents in a standardized form, laying a foundation for subsequent syntax analysis.
[0061] The standard character stream is parsed according to the identified structured syntax rule. Syntax parsing is a process of analyzing the structure of the standard character stream layer by layer and extracting semantic information, and through lexical analysis and syntax analysis techniques, configuration items, attribute values and their association relationships are identified. The parsing result is constructed as a configuration option tree, which is a tree data structure, and the nodes represent the configuration items in the configuration file, and the parent-child relationship represents the hierarchical containment or dependency relationship between the configuration items. This tree structure directly reflects the logical organization of the configuration content, making the query and maintenance of complex configuration relationships more efficient.
[0062] In order to further improve the universality and access efficiency of data, the configuration option tree is serialized into a serialized data stream that meets a preset data format. Serialization is the process of converting a tree data structure in memory into a continuous byte sequence for storage or transmission. The preset data format is a general data representation form that is decoupled from the original structured syntax rule, for example: a custom binary format that can be directly read without relying on a specific syntax parser. The serialized data stream is a byte sequence generated after serialization, which retains all the information of the configuration option tree.
[0063] The application determines the serialized data stream as file data for use by the storage process, and the file data has high portability due to the use of the preset data format, and can be directly parsed and used by any process that supports the preset data format without repeated syntax parsing or encoding conversion. This significantly improves data sharing efficiency, and in a multi-process environment of a multi-control storage system, different processes only need to have the same deserialization logic to quickly obtain configuration information, avoiding the overhead of repeated parsing, while ensuring consistency of configuration data between different components.
[0064] In one implementation manner of the embodiment of the application, when mapping the target memory segment corresponding to the target memory segment identifier to the storage process, the following implementation manners can be used, but are not limited to: mapping the target memory segment to the address space of the storage process in read-only mode to obtain a read-only pointer pointing to the starting address of the target memory segment; accessing the file data in the target memory segment through the read-only pointer and copying the file data to the memory of the storage process.
[0065] In the embodiment of the application, the read-only mode is a memory protection mechanism that allows the storage process to read memory data but prohibits any modification operation, and this mode is implemented through the memory protection flag provided by the system to ensure that the correct read-only permission attribute is set during mapping. The address space is a virtual memory range allocated for each storage process, and the storage process can access the mapped physical memory region through the address space.
[0066] After the mapping operation is completed, a read-only pointer pointing to the start address of the target memory segment is obtained. The read-only pointer is a special memory address reference, whose type is limited to the read-only attribute, and any operation attempting to modify the memory content through the read-only pointer will be blocked and trigger a memory protection exception. The start address is the first byte position of the target memory segment in the shared memory region, through which the complete memory segment content can be located.
[0067] After obtaining the read-only pointer, the storage process accesses the file data in the target memory segment through the read-only pointer. At this time, the storage process is allowed to directly read the content in the shared memory, but due to the limitation of the read-only permission, it is ensured that the original data will not be accidentally modified or destroyed. During the access process, a complete data reading operation is performed to transfer the file data from the shared memory region to the temporary buffer of the storage process.
[0068] Finally, the read file data is copied to the private memory of the storage process, which is a memory region independently owned by the storage process and isolated from other storage processes. The storage process can freely read and write data in this memory region without affecting the original content of the shared memory. The copy operation creates an independent copy of the file data, so that the storage process can perform any operation on the copy without worrying about destroying the integrity of the shared data source.
[0069] The present application prevents concurrent write conflicts that may occur in a multi-process environment by combining read-only mapping and data copying, ensuring the stability and consistency of the configuration file data in the shared memory. At the same time, by copying the data to the private memory of the process, the storage process can freely use and modify the configuration data locally, meeting the individual processing needs, without affecting the access of other storage processes to the original shared data.
[0070] In one implementation manner of the embodiment of the present application, in the process of realizing efficient reuse of file data based on shared memory, the shared memory is a system-level public memory resource, and its total capacity is fixed and limited. As the storage system runs for a long time, more and more file data will be stored in different memory segments of the shared memory. If the use state of the shared memory is not managed, the available space of the shared memory will gradually decrease, and even the memory will be exhausted. At this time, when a new storage process needs to store the parsed target configuration file data, it will not be able to find a blank memory segment, and can only repeatedly perform the operation of reading and parsing the configuration file from the preset database. Therefore, it is necessary to dynamically monitor and clean the memory segments of the shared memory to maintain a reasonable usage rate of the shared memory and ensure that it always has enough blank memory segments for new data storage.
[0071] Specifically, the following methods can be used, but are not limited to: monitoring the memory usage of the shared memory, and the access frequency and last access time of each of the plurality of memory segments in the shared memory; in response to the memory usage being greater than a preset usage threshold, determining a candidate memory segment to be data-cleared among the plurality of memory segments based on the access frequency and the last access time; performing a data clearing operation on the candidate memory segment, and determining the candidate memory segment after data clearing as a blank memory segment of the shared memory.
[0072] In the embodiments of the present application, the memory usage refers to the proportion of the currently occupied shared memory capacity to the total shared memory capacity, reflecting the degree of tension of the shared memory resources. The access frequency refers to the number of times a memory segment is accessed by a storage process in a unit of time, reflecting the activity level of the data stored in the memory segment. The last access time records the time stamp of the last access of each memory segment by a storage process, for identifying idle memory segments that have not been used for a long time.
[0073] The preset usage threshold is a critical value preset according to the actual memory capacity and usage demand, for example, any value between 70% and 90%, for triggering the memory cleaning operation. Based on the access frequency and the last access time of each memory segment, a candidate memory segment to be data-cleared is determined among the plurality of memory segments. The selection logic is to give priority to memory segments with lower access frequency and earlier last access time. This type of memory segment usually stores historical configuration data that is no longer frequently used, and determining it as a cleaning object has the least impact on system operation.
[0074] After determining the candidate memory segment, a data clearing operation is performed on the candidate memory segment. The data clearing operation not only includes clearing the file data and the corresponding check code stored in the memory segment, but also includes resetting the management metadata and the state identifier of the memory segment, to ensure that the memory segment returns to the initial state that can be reallocated. The clearing process can use a secure data erasing method to prevent the residual of sensitive configuration information.
[0075] After completing the data clearing, the processed candidate memory segment is re-determined as a blank memory segment of the shared memory. The blank memory segment refers to a memory region whose content has been emptied and is in a usable state, which can be re-occupied by new configuration file parsing data. The recycling of the blank memory segment alleviates the storage pressure of the shared memory and creates necessary conditions for the storage of new configuration data.
[0076] The dynamic memory management of the present application ensures the sustainable use of shared memory resources. Through continuous monitoring and intelligent cleaning, efficient turnover of storage space is achieved under the condition of limited memory resources, avoiding failures caused by memory depletion, and ensuring that high-frequency access configuration data can be long-term resident in the shared memory.
[0077] In an implementation manner of the embodiment of the present application, when the storage process needs to access the target configuration file through the shared memory quickly, the premise is that the file data corresponding to the target configuration file and the associated file identifier exist in the shared memory, and the generation of the file identifier is not completed by the storage process that needs to access currently, but is completed by the historical storage process that contacts the target configuration file earlier. The original reading of the target configuration file and the generation of the file identifier are completed by the historical storage process in advance, which provides a unique index for all subsequent storage processes to locate the file data in the shared memory, and avoids the repeated execution of the original configuration file reading and identifier construction operation by each storage process.
[0078] Specifically, the following methods can be used, but are not limited to: in response to the need of the historical storage process to read the target configuration file, reading the target configuration file and the identifier information corresponding to the target configuration file from the preset database based on the historical storage process; obtaining the file path of the shared memory, and performing data combination processing on the identifier information and the file path to obtain the file identifier.
[0079] In the embodiment of the present application, the historical storage process, as the first process to access the target configuration file, undertakes the role of initializing the shared memory data. When it is detected that the historical storage process needs to read the target configuration file, the historical storage process is guided to obtain the required target configuration file from the preset database.
[0080] The historical storage process not only reads the content data of the target configuration file from the preset database, but also obtains the identifier information corresponding to the target configuration file. The identifier information is characteristic data used to distinguish different configuration files, and can include the name, version number, content hash value or other unique identifier of the configuration file. The identifier information and the configuration file content are associated with each other, and together constitute a complete metadata set of the configuration file.
[0081] After successfully obtaining the target configuration file and its identifier information, the access path of the shared memory needs to be determined. The file path is a path to the shared memory area, which is determined when the shared memory is initialized, and usually appears as a virtual file system path or a special path reserved by the system. The file path remains unique and consistent in the entire multi-control storage system, ensuring that all storage processes can access the same shared memory area through the same path.
[0082] After obtaining the file path, the identifier information and the file path are combined for data processing. Data combination processing is an operation process of combining multiple data elements into a single identifier, and the specific implementation manners include but are not limited to string splicing, hash calculation or encoding conversion processing methods.
[0083] In addition to the above, the file identifier can also be generated in the following manner: when the first historical storage process (e.g., process1) that needs to access the target configuration file (e.g., config_file1) starts to execute, a unique file identifier (e.g., shm_key) is generated according to the existing file path and the identifier information of the target configuration file, which is used to identify the shared memory, and the file data obtained by parsing the configuration file is saved in the shared memory.
[0084] The file identifier can be constructed in the following manner: shm_key1 = ftok(“ / compass”, 1); wherein “ / compass” represents the file path, 1 represents the identifier information, and ftok represents a data combination processing instruction or algorithm.
[0085] Similarly, when the process process1 needs to access other configuration files (e.g., config_file2), a unique file identifier shm_key2 can be generated for the config_file2 file in the following manner:
[0086] shm_key2 = ftok(“ / compass”, 2).
[0087] The file identifier obtained through data combination processing in the present application is an identifier with sufficient uniqueness and stability, which establishes a definite association between the target configuration file and the corresponding storage location in the shared memory. In the subsequent storage process access, the file identifier can quickly locate the stored configuration file data in the shared memory, avoiding the overhead of repeated parsing, and laying a solid foundation for the efficient operation of the entire multi-control storage system.
[0088] In one implementation manner of the embodiment of the present application, after the historical storage process obtains the file identifier corresponding to the target configuration file through data combination processing, a dedicated memory area needs to be allocated in the shared memory for the target configuration file to store the parsed file data, and a unique identifier bound to the memory area is constructed to ensure that the subsequent storage process can accurately locate the memory area through the file identifier.
[0089] Specifically, the following method can also be used, but is not limited thereto: determining a second memory segment in the shared memory according to a preset region size, wherein the second memory segment is any blank memory segment in the plurality of memory segments included in the shared memory, and the region size of the second memory segment is the preset region size; determining the second memory segment as a target memory segment, and combining data according to the file identifier and target memory segment information of the target memory segment to construct a target memory segment identifier corresponding to the target memory segment, wherein the target memory segment information at least includes the region size and attribute information corresponding to the target memory segment.
[0090] In the embodiments of the present application, the preset region size is a predefined fixed memory allocation unit, the value of which is generally determined according to the average size of the configuration file and the expected data volume, so as to ensure that most configuration files can be completely stored, while avoiding excessive waste of memory space.
[0091] By sharing the memory management allocation, a second memory segment is selected from a plurality of available memory segments as a storage container for configuration data. The second memory segment refers to a continuous storage area in the shared memory address space, which has a capacity strictly meeting the requirement of the preset region size and is currently in an unallocated state of a blank memory segment. The second memory segment has complete read and write permissions and an initialized storage state, and can be directly used to receive configuration file data.
[0092] After determining the second memory segment, it is formally determined as a target memory segment, that is, a specific memory area used for storing file data parsed from the current configuration file. In order to establish the mapping relationship between the file identifier and the physical storage location, a corresponding target memory segment identifier needs to be constructed. The construction process is based on data combination of the file identifier and the target memory segment information of the target memory segment. The target memory segment information is a set of metadata describing the characteristics of the memory segment, at least including the region size and the attribute information corresponding to the target memory segment. The attribute information covers the access permission, creation time, and recent modification time of the memory segment, and other management attributes, which together constitute the complete description of the memory segment.
[0093] By a specific data combination algorithm, the file identifier and the target memory segment information are fused to generate the target memory segment identifier. The target memory segment identifier is indexed and recorded in the global management table of the shared memory, so that any subsequent storage process that needs to access the configuration file can quickly locate the corresponding target memory segment through the same file identifier.
[0094] Specifically, the form of the target memory segment identifier can be represented by, but not limited to, the following way: shm_id = shmget(shm_key, 4096, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); Wherein, shm_id represents the target memory segment identifier, shmget is a data combination instruction or a preset data combination algorithm, 4096 represents the region size, and S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP represents the attribute information.
[0095] The application solves the mapping relationship maintenance problem between the configuration file and the storage location by constructing the target memory segment identifier, and provides a solid foundation guarantee for efficient data sharing in a multi-process environment. The whole memory allocation and identifier construction process ensures the standardization and scalability of shared memory management, and creates favorable conditions for long-term stable operation of the multi-control storage system.
[0096] In an implementable manner of the embodiment of the application, after the historical storage process completes the construction of the target memory segment identifier corresponding to the target memory segment, although a dedicated storage area (i.e., the target memory segment) has been determined for the current target configuration file in the shared memory, the target memory segment is still in a blank state without effective data, and cannot provide data support for subsequent storage processes that need to access the target configuration file. Therefore, the historical storage process must further complete the storage operation of the file data and the target check code, and convert the effective information of the original configuration file into reliable data that can be directly reused in the shared memory. Specifically, the following methods can be used, but are not limited to: storing the file data into the target memory segment; generating the target check code based on the file data in the target memory segment, and storing the target check code into the target memory segment.
[0097] In the embodiment of the application, the file data that has undergone complete parsing processing is stored into the allocated target memory segment. The storage process follows a specific memory writing protocol to ensure that the data is stored in order according to the preset structure. The file data is stored in the memory in a serialized format, and its storage location is arranged continuously from the starting address of the target memory segment, fully utilizing the storage space of the preset area size, while reserving the necessary header area for storing management information.
[0098] After completing the file data storage, the target check code is generated based on the file data in the target memory segment. The generation process uses a cyclic redundancy check algorithm to calculate the file data stored in the target memory segment byte by byte. This calculation process covers all the contents from the starting position to the ending position of the file data, ensuring that any change in any bit of data will cause significant changes in the final generated check value.
[0099] After generating the target check code, it is stored in a specified location of the target memory segment, which is usually located after the file data storage area or in the reserved header structure, and together with the file data forms a complete data storage unit. When storing, it is necessary to ensure that the target check code is physically adjacent to the corresponding file data, but logically separated, so as to facilitate quick positioning and extraction of the check information during subsequent reading.
[0100] Specifically, regarding the data structure of the file data and the target check code stored in the target memory segment, the following methods can be used, but are not limited to: struct shm_data_info { uint32 content_crc; char config_file_info
[4096] ; } Wherein, the uint32 content_crc represents the target check code, and the char config_file_info represents the file data.
[0101] The application establishes a complete data credibility guarantee system by storing the file data and the target check code in the same target memory segment, so that any subsequent storage process can obtain the original data and the check code when accessing the configuration data, and then perform fast and effective data integrity verification. The reliability of data reading is improved, and frequent access to the preset database is avoided, thereby improving the overall performance of the multi-control storage system.
[0102] In an implementation manner of the embodiment of the application, in order to realize fast access to the target configuration file, the storage process first needs to obtain the file identifier corresponding to the target configuration file. However, the file identifier cannot be obtained every time. If the file identifier has been generated by a previous storage process for the target configuration file, the file identifier is directly reused. If the file identifier has not been generated, the file identifier needs to be reconstructed.
[0103] Specifically, the following methods can be used, but are not limited to: in response to the need of the storage process to obtain the target configuration file, data searching is performed in the preset identifier library based on the identifier information corresponding to the target configuration file, and a searching result is obtained; in response to the searching result being the file identifier corresponding to the identifier information, the file identifier is extracted; in response to the searching result being that the file identifier corresponding to the identifier information is not found, the file path of the shared memory is obtained, the identifier information and the file path are combined and processed to obtain the file identifier, and the file identifier is stored in the preset identifier library.
[0104] In the embodiment of the application, when the storage process needs to obtain the target configuration file, data searching is first performed in the preset identifier library based on the identifier information corresponding to the target configuration file. The preset identifier library is a database for managing file identifiers, which can be a memory database, a hash table or an index structure in persistent storage. The core function thereof is to maintain the mapping relationship between the identifier information and the file identifier, so as to quickly retrieve and reuse the existing identifier.
[0105] The record matched with the identification information is searched in the preset identification library through a query algorithm (such as a hash search or a binary search) to obtain a search result, the search result is a state identification, and it is explicitly indicated whether the corresponding file identification is found in the preset identification library. If the search result is that the file identification corresponding to the identification information is successfully found, the file identification is directly extracted.
[0106] If the search result is that the file identification corresponding to the identification information is not found, it is indicated that the target configuration file is accessed for the first time or is not recorded in the identification library, and the generation process of the file identification needs to be performed. At this time, the file path of the shared memory is acquired, and then the identification information is combined with the file path to generate the file identification, and the generated file identification is immediately stored in the preset identification library.
[0107] The application reduces the calculation overhead of identification generation through efficient management and reuse of the file identification. At the same time, the global consistency of the file identification is ensured, and the identification conflict or repetition problem that may occur in the multi-process environment is avoided, thereby laying a solid foundation for stable access to the shared memory.
[0108] In an implementable manner of the embodiment of the application, in order to facilitate understanding of the process of reading the file data of the configuration file by the multi-storage process of the application, the application provides a flowchart of reading the configuration file data, as shown in Figure 2 As shown in the figure, when the storage process needs to read the configuration file, the storage process first acquires the shm_key corresponding to the configuration file, that is, the file identification, then searches the shared memory segment shm_id corresponding to the configuration file, that is, the target memory segment identification, through the shmget, and then maps the target memory segment corresponding to the shm_id to the address space of the current storage process. The storage process directly accesses the file data in the target memory segment, and if the target check code matches the file data content at this time, it is indicated that the file data in the shared memory is valid configuration file data, and the configuration file data can be directly acquired. If the target check code does not match the file data content at this time, it is indicated that the file data in the target memory segment corresponding to the shm_id is not credible, and at this time, the configuration file needs to be read from the system disk, parsed, and then written into the target memory segment, and the target check code is updated to the target memory segment again according to the calculation.
[0109] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and a general hardware platform as required, and of course, it can also be realized by hardware, but in many cases, the former is a better implementation manner.
[0110] The embodiment of the application also provides a configuration file parsing device, Figure 3 The structure diagram of the configuration file parsing device provided by the application is as shown in Figure 3As shown, comprising: The acquisition unit 31 is configured to acquire a file identifier of a target configuration file required to be read by the storage process, wherein the file identifier is constructed based on identification information of the target configuration file and a file path for accessing the shared memory, and the shared memory is used to store file data obtained by a historical storage process by parsing the target configuration file, and the historical storage process is a process that initially requires to read the target configuration file before the storage process; The mapping unit 32 is configured to, in response to being able to find the target memory segment identifier containing the file identifier in the shared memory, map a target memory segment corresponding to the target memory segment identifier to the storage process, so as to extract the file data from the target memory segment, wherein the target memory segment is a memory area in the shared memory for storing the file data. The determination unit 33 is configured to, in response to a verification result of the verification processing on the file data satisfying a preset verification condition, determine the file data as target data read by the storage process.
[0111] In an embodiment of the present application, as shown in Figure 4 The configuration file parsing device further comprises: The reading unit 34 is configured to, in response to being unable to find the target memory segment identifier in the shared memory, read the target configuration file from a preset database based on the storage process, wherein the preset database stores a plurality of configuration files. The parsing unit 35 is configured to perform file parsing processing on the target configuration file to obtain file data. The storage unit 36 is configured to store the file data into a first memory segment of the shared memory, wherein the first memory segment is any blank memory segment in a plurality of memory segments included in the shared memory. The generation unit 37 is configured to generate a first check code based on the file data in the first memory segment. The storage unit 36 is further configured to store the first check code into the first memory segment. The construction unit 38 is configured to construct a first memory segment identifier corresponding to the first memory segment according to the file identifier and first memory segment information of the first memory segment.
[0112] In an embodiment of the present application, as shown in Figure 4 The configuration file parsing device further comprises a verification unit 39, and the verification unit 39 is configured to: Extract a target check code corresponding to the file data from the target memory segment, wherein the target check code is a cyclic check code generated after the historical storage process stores the file data into the target memory segment. Perform data verification processing on the file data based on the target check code to obtain a verification result.
[0113] In an embodiment of the present application, the reading unit 34 is further configured to read the target configuration file from the preset database based on the storage process in response to the verification result not satisfying the preset verification condition. The parsing unit 35 is further configured to perform file parsing processing on the target configuration file to obtain file data. The storage unit 36 is further configured to store the file data into the target memory segment after deleting the data in the target memory segment. The generating unit 37 is further configured to generate a second check code based on the file data in the target memory segment and store the second check code into the target memory segment.
[0114] In an embodiment of the present application, the verification unit 39 is specifically configured to: generate a check code to be verified based on the file data according to the storage process; perform check code matching processing according to the target check code and the check code to be verified to obtain a check code matching result; obtain a first verification result in response to the check code matching result being that the target check code does not match the check code to be verified, wherein the first verification result does not satisfy the preset verification condition; obtain a second verification result in response to the check code matching result being that the target check code matches the check code to be verified, wherein the verification result includes the first verification result and the second verification result, and the second verification result satisfies the preset verification condition.
[0115] In an embodiment of the present application, the parsing unit 35 is specifically configured to: identify a text encoding format and a structured syntax rule of the target configuration file; perform byte stream decoding on the target configuration file based on the text encoding format to obtain a standard character stream, perform syntax analysis on the standard character stream based on the structured syntax rule, and construct a configuration option tree for representing a configuration item hierarchical relationship in the target configuration file; serialize the configuration option tree into a serialized data stream satisfying a preset data format, wherein the preset data format is a data format decoupled from the structured syntax rule; determine the serialized data stream as the file data, wherein the file data can be directly parsed and used by any process supporting the preset data format.
[0116] In an embodiment of the present application, the mapping unit 32 is specifically configured to: map the target memory segment into the address space of the storage process in a read-only mode to obtain a read-only pointer pointing to a start address of the target memory segment; access the file data in the target memory segment through the read-only pointer and copy the file data into the memory of the storage process.
[0117] In an embodiment of the present application, the determining unit 33 is further configured to: monitor a memory usage of the shared memory, and an access frequency and a last access time of each of a plurality of memory segments in the shared memory; in response to the memory usage being greater than a preset usage threshold, determine a candidate memory segment to be data-cleared from the plurality of memory segments based on the access frequency and the last access time; perform a data-cleaning operation on the candidate memory segment, and determine the candidate memory segment after data-cleaning as a blank memory segment of the shared memory.
[0118] In an embodiment of the present application, the generating unit 37 is further configured to: in response to the history storage process needing to read the target configuration file, read the target configuration file and identification information corresponding to the target configuration file from the preset database based on the history storage process; obtain a file path of the shared memory, and perform data combination processing on the identification information and the file path to obtain a file identification.
[0119] In an embodiment of the present application, the generating unit 37 is further configured to: determine a second memory segment in the shared memory according to a preset region size, wherein the second memory segment is any blank memory segment of a plurality of memory segments included in the shared memory, and a region size of the second memory segment is the preset region size; determine the second memory segment as a target memory segment, and perform data combination on the file identification and target memory segment information of the target memory segment to construct a target memory segment identification corresponding to the target memory segment, wherein the target memory segment information at least includes the region size and attribute information corresponding to the target memory segment.
[0120] In an embodiment of the present application, the generating unit 37 is further configured to: store the file data into the target memory segment; generate a target check code based on the file data in the target memory segment, and store the target check code into the target memory segment.
[0121] In an embodiment of the present application, the obtaining unit 31 is further configured to: in response to the storage process needing to obtain the target configuration file, perform data searching in a preset identification library based on the identification information corresponding to the target configuration file to obtain a searching result; in response to the searching result being the file identification corresponding to the identification information being found, extract the file identification; in response to the searching result being the file identification corresponding to the identification information not being found, obtain a file path of the shared memory, perform data combination processing on the identification information and the file path to obtain the file identification, and store the file identification into the preset identification library.
[0122] The features of the embodiments of the configuration file parsing device can be referred to the related descriptions of the embodiments of the configuration file parsing method, which will not be repeated here.
[0123] The embodiments of the present application also provide an electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above configuration file parsing method embodiments.
[0124] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is configured to perform the steps in any of the above configuration file parsing method embodiments when running.
[0125] In an example embodiment, the above computer readable storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0126] The embodiments of the present application also provide a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps in any of the above configuration file parsing method embodiments.
[0127] The embodiments of the present application also provide another computer program product, which comprises a non-volatile computer readable storage medium, and the non-volatile computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in any of the above configuration file parsing method embodiments.
[0128] The skilled person can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the above description. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0129] The above describes in detail the configuration file analysis method and the electronic device provided by the present application. The principles and implementation modes of the present application are described by applying specific examples, and the above description of the embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that, for those skilled in the art, without departing from the principles of the present application, the present application can be improved and modified in several ways, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims
1. A method for parsing a configuration file, characterized in that, include: Obtain the file identifier of the target configuration file that the storage process needs to read, wherein the file identifier is constructed based on the identification information of the target configuration file and the file path used to access the shared memory, the shared memory is used to store the file data obtained by the previous storage process from parsing the target configuration file, and the previous storage process is the process that first needed to read the target configuration file before the current storage process; In response to the ability to find a target memory segment identifier containing the file identifier in the shared memory, the target memory segment corresponding to the target memory segment identifier is mapped to the storage process to extract the file data from the target memory segment, wherein the target memory segment is a memory region in the shared memory that stores the file data; In response to the verification result of the file data verification process meeting the preset verification conditions, the file data is determined as the target data read by the storage process.
2. The configuration file parsing method according to claim 1, characterized in that, After obtaining the file identifier of the target configuration file that the storage process needs to read, the method further includes: In response to the inability to find the target memory segment identifier in the shared memory, the target configuration file is read from a preset database based on the storage process, wherein the preset database stores multiple configuration files; The target configuration file is parsed to obtain the file data, and the file data is stored in the first memory segment of the shared memory, wherein the first memory segment is any blank memory segment among the multiple memory segments included in the shared memory; A first verification code is generated based on the file data in the first memory segment, and the first verification code is stored in the first memory segment; The first memory segment identifier corresponding to the first memory segment is constructed based on the file identifier and the first memory segment information of the first memory segment.
3. The configuration file parsing method according to claim 1, characterized in that, After mapping the target memory segment corresponding to the target memory segment identifier to the storage process to extract the file data from the target memory segment, the method further includes: Extract the target checksum corresponding to the file data from the target memory segment, wherein the target checksum is a loop checksum generated after the file data is stored in the target memory segment by the historical storage process; The file data is verified based on the target checksum to obtain the verification result.
4. The configuration file parsing method according to claim 3, characterized in that, After performing data verification processing on the file data based on the target checksum to obtain the verification result, the method further includes: In response to the verification result not meeting the preset verification conditions, the target configuration file is read from the preset database based on the storage process, and the target configuration file is parsed to obtain the file data; After deleting the data in the target memory segment, the file data is stored in the target memory segment; A second checksum is generated based on the file data in the target memory segment, and the second checksum is stored in the target memory segment.
5. The configuration file parsing method according to claim 3, characterized in that, The data verification process based on the target checksum to obtain the verification result includes: Based on the storage process, a verification code to be verified is generated according to the file data. The target check code is matched with the check code to be verified to obtain the check code matching result. In response to the verification code matching result indicating that the target verification code does not match the verification code to be verified, a first verification result is obtained, wherein the first verification result does not satisfy the preset verification condition; In response to the verification code matching result being that the target verification code matches the verification code to be verified, a second verification result is obtained, wherein the verification result includes the first verification result and the second verification result, and the second verification result satisfies the preset verification condition.
6. The configuration file parsing method according to claim 2, characterized in that, The process of parsing the target configuration file to obtain the file data includes: Identify the text encoding format and structured syntax rules of the target configuration file; The target configuration file is decoded into a byte stream based on the text encoding format to obtain a standard character stream. The standard character stream is then parsed according to the structured syntax rules to construct a configuration option tree that represents the hierarchical relationship of configuration items in the target configuration file. The configuration option tree is serialized into a serialized data stream that meets a preset data format, wherein the preset data format is a data format decoupled from the structured syntax rules; The serialized data stream is identified as the file data, wherein the file data can be directly parsed and used by any process that supports the preset data format.
7. The configuration file parsing method according to claim 2, characterized in that, The step of mapping the target memory segment corresponding to the target memory segment identifier to the storage process, so as to extract the file data from the target memory segment, includes: The target memory segment is mapped to the address space of the storage process in read-only mode to obtain a read-only pointer to the starting address of the target memory segment; The file data in the target memory segment is accessed through the read-only pointer, and the file data is copied into the memory of the storage process.
8. The configuration file parsing method according to claim 2, characterized in that, The method further includes: Monitor the memory usage rate of the shared memory, as well as the access frequency and last access time of each of the multiple memory segments in the shared memory; In response to the memory usage rate being greater than a preset usage rate threshold, a candidate memory segment to be cleared is determined from the plurality of memory segments based on the access frequency and the last access time; Perform a data clearing operation on the candidate memory segment, and determine the candidate memory segment after data clearing as the blank memory segment of the shared memory.
9. The configuration file parsing method according to claim 3, characterized in that, The method further includes: In response to the historical storage process needing to read the target configuration file, the historical storage process reads the target configuration file and the corresponding identification information from a preset database. Obtain the file path of the shared memory, and perform data combination processing on the identification information and the file path to obtain the file identifier; A second memory segment is determined in the shared memory according to a preset region size, wherein the second memory segment is any blank memory segment among the multiple memory segments included in the shared memory, and the region size of the second memory segment is the preset region size; The second memory segment is determined as the target memory segment. Data is combined according to the file identifier and the target memory segment information to construct the target memory segment identifier corresponding to the target memory segment. The target memory segment information includes at least the region size and the attribute information corresponding to the target memory segment.
10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the configuration file parsing method as described in any one of claims 1 to 9 when executing the computer program.
Citation Information
Patent Citations
Method, server and system for sharing resource data
CN104980454A
Data file processing method and system
CN106708825A
Configuration loading method and device
CN107544828A
Configuration file analysis method and system and electronic equipment
CN111124479A
Upgrading method and device, electronic equipment and machine readable storage medium
CN117931241A