Importing method and device of configuration file, and configuration terminal

By converting configuration files into a hierarchical format and extracting key-value pair configuration items, the maintenance difficulties caused by differences in configuration file formats in multiple environments are solved, realizing software configuration management at the configuration item level and improving maintenance accuracy and efficiency.

CN115599431BActive Publication Date: 2026-07-24GUOTAI JUNAN SECURITIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUOTAI JUNAN SECURITIES CO LTD
Filing Date
2022-09-07
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

Existing technologies suffer from significant differences in configuration file formats across various environments, making automatic identification difficult and leading to errors during manual maintenance, thus failing to meet software configuration management requirements.

Method used

The configuration file is converted into a preset hierarchical structure format file, key-value pair configuration items are extracted, hierarchical parameter names are separated by a preset separator, common configuration items are identified, and updates are made in the key-value pair configuration items.

Benefits of technology

It enables software configuration management at the configuration item level, improving maintenance accuracy and efficiency while reducing the complexity of configuration file maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115599431B_ABST
    Figure CN115599431B_ABST
Patent Text Reader

Abstract

The application discloses a configuration file import method and device, and a configuration terminal. The method comprises the following steps: converting the configuration file into a preset hierarchical structure format file, wherein the hierarchical structure format file comprises multiple levels, each level has a parameter name and a parameter value; based on the parameter name and the parameter value of the lowest level parameter of the hierarchical structure format file, extracting key-value pair configuration items, each key-value pair configuration item comprises a key-value pair parameter name and a key-value pair parameter value, the key-value pair parameter name comprises the parameter names of the respective levels, and the parameter names of the respective levels in the key-value pair parameter name are separated by a preset interval symbol; importing the extracted key-value pair configuration items; and determining a common configuration item according to the key-value pair configuration items. The application can realize unified conversion of various format complex configuration files into key-value pair configuration items for maintenance, improve configuration file maintenance accuracy, and reduce configuration file maintenance complexity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for importing configuration files, and a configuration terminal. Background Technology

[0002] In the process of software engineering development, it is inevitable to import configuration parameters and change them according to specific circumstances. Since the change steps may occur at any time, it can easily lead to confusion between development and operation.

[0003] In application systems, configuration parameters may include database connection information, startup parameters, etc., and these parameters are usually loaded in the form of configuration files.

[0004] However, existing configuration file import technologies directly import the current configuration file format. When updating a configuration parameter, especially in multiple environments (e.g., development, testing, production), automatic identification is difficult due to the different configuration file formats in each environment. Manual modification and maintenance of the configuration file are usually required, which is prone to errors and omissions. Furthermore, with business growth and architecture upgrades, the number of application systems and configuration files is increasing daily, making manual configuration file maintenance insufficient for software configuration management requirements.

[0005] There is an urgent need for a method to import configuration files that can improve the adaptability of configuration file import, facilitate the implementation of software configuration management at the configuration item level, and enable the unified conversion of various complex configuration files into key-value pair configuration items for maintenance, thereby improving the accuracy of configuration file maintenance and reducing the complexity of configuration file maintenance. Summary of the Invention

[0006] The technical problem solved by this invention is to provide a method and apparatus for importing configuration files and a configuration terminal, which can convert various complex configuration files into key-value pairs for maintenance, thereby improving the accuracy of configuration file maintenance and reducing the complexity of configuration file maintenance.

[0007] To address the aforementioned technical problems, this invention provides a method for importing a configuration file, comprising: converting the configuration file into a preset hierarchical structure format file, the hierarchical structure format file containing multiple levels, each level having a parameter name and a parameter value; extracting key-value pair configuration items based on the parameter name and parameter value of the lowest-level parameter in the hierarchical structure format file, each key-value pair configuration item containing a key-value pair parameter name and a key-value pair parameter value, the key-value pair parameter name containing the parameter names of each level, and the parameter names of each level in the key-value pair parameter name being separated by a preset separator; importing the extracted key-value pair configuration items; and determining common configuration items based on the key-value pair configuration items.

[0008] Optionally, the hierarchical structure format file contains one or more list levels, each list level containing multiple objects in parallel; the parameter name of the list level in the key-value pair parameter name is expressed as the parameter name of the list level and the ordinal number of the object to which the lowest-level parameter belongs in the list level.

[0009] Optionally, the parameter names at each level in the key-value pair parameter name are separated by the preset separator, and the parameter names at each level are in the order from top to bottom in the key-value pair parameter name.

[0010] Optionally, the preset hierarchical structure format file is selected from: JSON format file, XML format file, and YAML format file.

[0011] Optionally, the hierarchical structure format file contains one or more list levels, each list level containing multiple objects in parallel; wherein, the preset hierarchical structure format file is a JSON format file; the parameter names and parameter values ​​of each level are separated by colons in the JSON format file; the objects are enclosed in curly braces in the JSON format file; and the list levels are enclosed in square brackets in the JSON format file.

[0012] Optionally, the hierarchical structure format file contains one or more list levels, each list level containing multiple objects in parallel; wherein, the preset hierarchical structure format file is an XML format file; the start tag containing the parameter name is enclosed in paired angle brackets in the XML format file, and the end tag containing the slash symbol and the parameter name is enclosed in paired angle brackets in the XML format file, with the parameter value located between the start tag and the end tag; the ordinal number of the object in the list level is the number of times the parameter name appears repeatedly in parallel in the XML format file; the list level in the XML format file is the parameter name that appears repeatedly in parallel.

[0013] Optionally, before extracting key-value pair configuration items based on the parameter names and parameter values ​​of the lowest-level parameters of the hierarchical format file, the method further includes: pre-constructing a conversion template based on the format type of the hierarchical format file, wherein the conversion template is used to indicate the mapping relationship between the hierarchical format file and the key-value pair configuration items; extracting key-value pair configuration items based on the hierarchical format file includes: using the conversion template to directly extract each parameter name and parameter value of the key-value pair configuration items from the hierarchical format file.

[0014] Optionally, determining the common configuration item based on the key-value pair configuration item includes: using the key-value pair configuration item as the main content, entering the common configuration item into the configuration center, and generating a common configuration version number.

[0015] Optionally, the method further includes: when the configuration file is updated in one or more environments, updating the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items in each environment; obtaining an updated hierarchical structure format file based on the updated key-value pair configuration items; and converting the updated hierarchical structure format file into the format of the configuration file for download by terminal devices in each environment.

[0016] Optionally, updating the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items in each environment includes: comparing whether there are differences in the key-value pair parameter values ​​in the key-value pair configuration items in each environment; if there are differences, outputting the updated key-value pair configuration items in each environment, wherein each updated key-value pair configuration item includes key-value pair configuration items that are indistinguishable in the public configuration items, and key-value pair configuration items that are indistinguishable in the private configuration items.

[0017] To address the aforementioned technical problems, embodiments of the present invention provide a configuration file import device, comprising: a conversion module for converting the configuration file into a preset hierarchical structure format file, the hierarchical structure format file containing multiple levels, each level having a parameter name and a parameter value; an extraction module for extracting key-value pair configuration items based on the hierarchical structure format file, each key-value pair configuration item containing a parameter name and a parameter value, the parameter name containing the key values ​​of each upper level of the parameter and the parameter name and parameter value of the parameter based on the lowest level parameter of the hierarchical structure format file; extracting key-value pair configuration items, each key-value pair configuration item containing a key-value pair parameter name and a key-value pair parameter value, the key-value pair parameter name containing the parameter names of each level, and the parameter names of each level in the key-value pair parameter name being separated by a preset separator; an import module for importing the extracted key-value pair configuration items; and a common configuration item determination module for determining common configuration items based on the key-value pair configuration items.

[0018] To address the aforementioned technical problems, embodiments of the present invention provide a computer-readable storage medium storing a computer program thereon, wherein the computer program, when run by a processor, executes the steps of the above-described configuration file import method.

[0019] To address the aforementioned technical problems, this invention provides a configuration terminal, including a memory and a processor. The memory stores a computer program that can run on the processor, and when the processor runs the computer program, it executes the steps of the above-described configuration file import method.

[0020] Compared with the prior art, the technical solution of the embodiments of the present invention has the following beneficial effects:

[0021] In this embodiment of the invention, the configuration file is first converted into a preset hierarchical structure format file, and key-value pair configuration items are extracted based on the parameter name and parameter value of the lowest-level parameter in the preset hierarchical structure format file. In the key-value pair configuration storage mode, one actual row represents one configuration item parameter, and each actual row has a row key and a value. The rows have consistent format rules, so the common configuration items determined by the key-value pair configuration items have adaptability, thereby improving the adaptability of the imported file in the import stage. This is beneficial in the maintenance stage, regardless of whether there are differences in the format of the configuration file, since the common configuration items are determined by key-value pair configuration items, the key-value pair parameter values ​​in the key-value pair configuration items can be modified, that is, maintenance can be completed for the modified and updated content, thereby realizing software configuration management at the configuration item level. Compared with the prior art, which directly imports the current configuration file format and requires manual file-level maintenance, the solution of this embodiment of the invention can extract diverse configuration files into key-value pair configuration items for maintenance, which is beneficial to realizing software configuration management at the configuration item level, improving the accuracy of configuration file maintenance, and reducing the complexity of configuration file maintenance.

[0022] Furthermore, the parameter name expression form of the list-level parameter name in the key-value pair parameter name is: the parameter name of the list level and the ordinal number of the object to which the lowest-level parameter belongs in the list level. By adopting the above scheme, the format rules of parameter names can be further standardized, thereby enabling the extraction of key-value pair configuration items with higher format consistency from diverse configuration files, and further improving the compatibility and adaptability of the configuration file format with various environments.

[0023] Furthermore, a conversion template can be pre-built based on the format type of the hierarchical format file. When extracting key-value pair configuration items, the conversion template can be used to directly extract the parameter names and parameter values ​​of each key-value pair configuration item from the hierarchical format file. Since the conversion template is pre-built, manual construction operations can be added without affecting the extraction efficiency, thus reducing the program design complexity of template construction.

[0024] Furthermore, the preset hierarchical structure format file is a JSON format file, which can be divided according to the existing construction characters (such as colons, curly braces, square brackets, etc.) in the JSON format file, thereby realizing the automatic extraction of each key-value pair parameter name and key-value pair parameter value in the key-value pair configuration item. Since the construction characters are objective and are not affected by the meaning of the string content, using construction characters for division is beneficial to improving the accuracy of key-value pair configuration item extraction.

[0025] Furthermore, the key-value pair configuration items are used as the main content, entered into the configuration center, and a common configuration version number is generated. By adopting the solution in this embodiment of the invention, since each key-value pair configuration item is used as the main content, and the actual rows of the key-value pair configuration items have consistent format rules, the accuracy of maintaining common configuration items can be improved, and the complexity of subsequent maintenance can be reduced.

[0026] Furthermore, when the configuration file is updated in one or more environments, the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items belonging to each environment are updated; based on the updated key-value pair configuration items, an updated hierarchical structure format file is obtained; the updated hierarchical structure format file is then converted back into the format of the configuration file for download by terminal devices in each environment. Using the scheme in this embodiment of the invention, the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items in each environment can be updated manually or automatically. Since the main content of the private configuration items is key-value pair configuration items, the update complexity is significantly reduced. Whether it is a manual update or an automatic update, it is beneficial to improve update accuracy and maintenance efficiency.

[0027] Furthermore, updating the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items in each environment includes: comparing whether there are differences in the key-value pair parameter values ​​in the key-value pair configuration items in each environment; if there are differences, outputting the updated key-value pair configuration items in each environment, wherein each updated key-value pair configuration item includes the key-value pair configuration items that are indistinguishable in the public configuration items and the key-value pair configuration items that are different in the private configuration items, and outputting the updated key-value pair configuration items in each environment, thereby achieving batch updates with higher update efficiency and accuracy. Attached Figure Description

[0028] Figure 1 This is a flowchart of a configuration file import method according to an embodiment of the present invention;

[0029] Figure 2 This is a flowchart of another method for importing configuration files in an embodiment of the present invention;

[0030] Figure 3 This is a partial flowchart of another method for importing a configuration file in an embodiment of the present invention;

[0031] Figure 4 yes Figure 3 A flowchart of a specific implementation of step S31;

[0032] Figure 5This is a schematic diagram of the structure of a configuration file import device according to an embodiment of the present invention;

[0033] Figure 6 This is a schematic diagram of the structure of another configuration file import device in an embodiment of the present invention. Detailed Implementation

[0034] Existing configuration file import technologies typically import the current configuration file directly. However, when updating a configuration parameter, especially across multiple environments (e.g., development, testing, and production), the different configuration file formats in each environment make automatic identification difficult. This usually necessitates manual modification and maintenance, which is prone to errors and omissions. Furthermore, with business growth and architecture upgrades, the number of application systems and configuration files is increasing daily, making manual configuration file maintenance insufficient for software configuration management requirements.

[0035] The inventors of this invention discovered through research that during updates (e.g., modifications and updates) in multiple environments, directly importing the current configuration file format, coupled with the diverse and significant differences between configuration file formats, results in each environment having its own unique configuration file format. This makes automatic identification difficult and easily leads to maintenance errors when modifications and updates are needed. In existing technologies, maintenance is typically performed manually, which is extremely prone to errors due to mistakes made by development / operations personnel.

[0036] Further research by the inventors of this invention revealed that although Software Configuration Management (SCM) technology exists for identifying and controlling changes to configuration parameters, ensuring correct implementation of changes, and reporting change identifiers to relevant personnel, most current SCM solutions only support configuration file-level management and not configuration item-level management. When configuration items differ across environments, each environment has a separate configuration file. Once configuration parameters change, each environment's configuration file must be updated separately. Due to the numerous and varied formats of configuration files, it is difficult to correctly determine the locations to be replaced (e.g., it is difficult to accurately determine which characters need to be replaced), leading to frequent update errors.

[0037] In this embodiment of the invention, the configuration file is first converted into a preset hierarchical structure format file, and key-value pair configuration items are extracted based on the parameter name and parameter value of the lowest-level parameter in the preset hierarchical structure format file. In the key-value pair configuration storage mode, one actual row represents one configuration item parameter, and each actual row has a row key and a value. The rows have consistent format rules, so the common configuration items determined by the key-value pair configuration items have adaptability, thereby improving the adaptability of the imported file in the import stage. This is beneficial in the maintenance stage, regardless of whether there are differences in the format of the configuration file, since the common configuration items are determined by key-value pair configuration items, the key-value pair parameter values ​​in the key-value pair configuration items can be modified, that is, maintenance can be completed for the modified and updated content, thereby realizing software configuration management at the configuration item level. Compared with the prior art, which directly imports the current configuration file format and requires manual file-level maintenance, the solution of this embodiment of the invention can extract diverse configuration files into key-value pair configuration items for maintenance, which is beneficial to realizing software configuration management at the configuration item level, improving the accuracy of configuration file maintenance, and reducing the complexity of configuration file maintenance.

[0038] To make the above-mentioned objectives, features and beneficial effects of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0039] Reference Figure 1 , Figure 1 This is a flowchart of a configuration file import method according to an embodiment of the present invention. The configuration file import method may include steps S11 to S14:

[0040] Step S11: Convert the configuration file into a preset hierarchical structure format file, the hierarchical structure format file containing multiple levels, each level having parameter names and parameter values;

[0041] Step S12: Based on the parameter name and parameter value of the lowest level parameter of the hierarchical structure format file, extract key-value pair configuration items. Each key-value pair configuration item contains a key-value pair parameter name and a key-value pair parameter value. The key-value pair parameter name contains the parameter names of each level, and the parameter names of each level in the key-value pair parameter name are separated by a preset separator.

[0042] Step S13: Used to import the extracted key-value pair configuration items;

[0043] Step S14: Determine the common configuration items based on the key-value pair configuration items.

[0044] In the specific implementation of step S11, the configuration file can be a computer file that contains computer program configuration parameters and initial settings. Typically, the configuration file can include two parts: comments and configuration items.

[0045] In practical applications, configuration files come in various formats. Common configuration files can include properties, JavaScript object notation (JSON), Yet Another Markup Language (YAML), Extensible Markup Language (XML), initialization (INI), scripting languages ​​(Lua), etc.

[0046] The Properties format can be a persistent set of properties. Configuration items are stored in the form of (key=value), where both the key and value are strings. Comments are identified by "#".

[0047] JSON format can be a lightweight, text-based, open data exchange format that can represent data using objects and lists (also known as arrays).

[0048] YAML format is a highly readable format used to express data serialization.

[0049] XML format can be a simple data storage language, or it can be a tree structure that expands from the "root" to the "branches and leaves".

[0050] The following is a JSON file format, which can be used as an example of a non-restrictive hierarchical format file:

[0051]

[0052]

[0053] The JSON file mentioned above contains three levels. For example, "author":"Jack Herrington" can be the lowest level, containing the parameter name "author" and the parameter value "Jack Herrington". The parameter value of the parameter name "author" can be "Jack Herrington". "book":[] can be the middle level, and this middle level contains a list level. Its parameter value can be "book". "books":{} can be the top level, and its parameter value can be "books".

[0054] Furthermore, one or more intermediate levels in the hierarchical format file may contain list levels, and the next level of each list level may contain multiple objects in parallel.

[0055] Specifically, taking the above JSON format file as an example, the middle level "book":[] contains a list level, and the next level of the list level (such as the bottom level) contains two parallel objects, each enclosed in curly braces. Each object contains three parameters and their values.

[0056] Furthermore, the parameter names of objects belonging to the same list structure can be consistent. For example, in the JSON format file above, each object belonging to the same list structure "book":[] contains "author", "publisher", and "title".

[0057] In the process of converting the configuration file into a preset hierarchical format file, conventional conversion methods can be used, such as using various appropriate standard format conversion tools to convert the configuration file into a preset hierarchical format file.

[0058] In a non-limiting embodiment, the configuration file can be an XML file, and the preset hierarchical structure file can be a JSON file. The following pseudocode can be used to convert XML to JSON:

[0059]

[0060] In the specific implementation of step S12, key-value pair configuration items can be extracted based on the parameter name and parameter value of the lowest level parameter of the hierarchical structure format file. Each key-value pair configuration item contains a key-value pair parameter name and a key-value pair parameter value. The key-value pair parameter name contains the parameter names of each level, and the parameter names of each level in the key-value pair parameter name are separated by a preset separator.

[0061] Key-value pairs can be considered a common form of configuration item management, where configuration items are stored in the form of key-value pair parameter name key = key-value pair parameter value.

[0062] Continuing with the JSON file example above, the key-value pair configuration items can be extracted as follows:

[0063] books.book.[0].author=Jack Herrington

[0064] books.book.[0].publisher=O'Reilly

[0065] books.book.[0].title=Podcasting Hacks

[0066] books.book.[1].author=Jack Herrington

[0067] books.book.[1].publisher=O'Reilly

[0068] books.book.[1].title=PHP Hacks

[0069] Specifically, taking the key-value pair parameter name books.book.[0].author as an example, it includes the key-value pair parameter names books.book.[0] at each upper level and the key-value pair parameter name author at the lowest level. Books.book.[0] are separated by a preset separator “.”, and books.book.[0] and author are also separated by a preset separator “.”.

[0070] Furthermore, the hierarchical structure format file contains one or more list levels, each list level containing multiple objects in parallel; the parameter name of the list level in the key-value pair parameter name is expressed as the parameter name of the list level and the ordinal number of the object to which the lowest-level parameter belongs in the list level.

[0071] Specifically, taking the key-value pair abc[0].name = aaa as an example, the parameter name of the list level in the key-value pair parameter name can be expressed as: the parameter name of the list level (such as c), the ordinal number [0] of the object to which the lowest level parameter (such as name) belongs in the list level (c), which is c[0].

[0072] It should be noted that if the hierarchical structure format file contains one or more list levels, and the key-value pair parameter name contains the list level information, then each key-value pair parameter name may include: the parameter name of each upper level of the list level, the parameter name of the list level, and the ordinal number of the object to which the lowest level parameter belongs in the list level.

[0073] Specifically, continuing with the key-value pair abc[0].name = aaa, the key-value pair parameter name may include: the parameter name of each upper level of the list hierarchy (such as ab), the parameter name of the list hierarchy (such as c), and the ordinal number [0] of the object to which the lowest level parameter (such as name) belongs in the list hierarchy (c).

[0074] Similarly, taking the key-value pair abc[1].name=bbb as an example, the key-value pair parameter name may include: the parameter name of each upper level of the list level (such as ab), the parameter name of the list level (such as c), and the ordinal number of the object to which the lowest level parameter (such as name) belongs in the list level (c) [1].

[0075] It should be noted that in the above embodiments, the list level is the lowest level (e.g., c is the lowest level in abc). However, the embodiments of the present invention are not limited to this, and the list level corresponding to the key-value pair parameter name can also be a certain level above it.

[0076] Furthermore, the parameter names at each level in the key-value pair parameter name are separated by the preset separator, and the parameter names at each level are in the order from top to bottom in the key-value pair parameter name.

[0077] Furthermore, the preset separator can be ".".

[0078] It should be noted that other appropriate separators can also be used as the preset separator. In this embodiment of the invention, "." can be used as the preset separator, which is simple and easy to input, and can avoid repetition with symbols (such as colons, commas, etc.) already existing in the hierarchical structure format file.

[0079] Continuing with the example of the parameter names books.book.[0].author at each level, the order of the parameter names at each level in the key-value pair parameter names is from top to bottom. For example, the top-level parameter name books comes first, the list-level parameter name book is in the middle, the object number [0] comes next, and the bottom-level parameter name author comes last. They are connected with a preset separator to generate the parameter name books.book.[0].author.

[0080] Specifically, by setting the order of parameter names at each level in the key-value pair parameter names from top to bottom, the upper-level parameter names with a wider range of content can be placed first, making them easier to identify.

[0081] In this embodiment of the invention, when the key-value pair parameter name contains the list hierarchy information, each key-value pair parameter name includes: the parameter name of each upper level of the list hierarchy, the parameter name of the list hierarchy, and the ordinal number of the object to which the lowest-level parameter belongs in the list hierarchy. By adopting the above scheme, the format rules of parameter names can be further standardized, thereby enabling the extraction of key-value pair configuration items with higher format consistency from diverse configuration files, and further improving the compatibility and adaptability of the configuration file format with various environments.

[0082] Furthermore, the hierarchical structure format file contains one or more list levels, each list level containing multiple objects in parallel; wherein, the preset hierarchical structure format file is a JSON format file; the parameter names and parameter values ​​of each level are separated by colons in the JSON format file; the objects are enclosed in curly braces in the JSON format file; and the list levels are enclosed in square brackets in the JSON format file.

[0083] In a non-limiting specific embodiment, the following pseudocode can be used to extract key-value pair configuration items from a JSON format file:

[0084]

[0085] Here, `String key = it.next();` can be used to obtain the key-value pair parameter name (key) of a JSON file, `prop_config.put(key, value);` can be used to indicate multiple nested loops, thereby obtaining multiple key-value pairs by repeatedly executing this step, and `return prop_config` can be used to indicate the return of key-value pairs.

[0086] In this embodiment of the invention, the preset hierarchical structure format file is a JSON format file. It can be divided according to the existing construction characters (such as colons, curly braces, square brackets, etc.) in the JSON format file, thereby realizing the automatic extraction of each key-value pair parameter name and key-value pair parameter value in the key-value pair configuration item. Since the construction characters are objective and are not affected by the meaning of the string content, using construction characters for division is beneficial to improving the accuracy of key-value pair configuration item extraction.

[0087] Furthermore, the preset hierarchical structure format file can be selected from: JSON format file, XML format file, and YAML format file.

[0088] In this embodiment of the invention, an appropriate format file can be selected as the preset hierarchical structure format file from a wider range of hierarchical structure format files, thereby improving the applicability of the selection according to specific circumstances. For example, an XML format file can be used as the preset hierarchical structure format file.

[0089] The following is a format of an XML file, which can be used as an example of a non-restrictive hierarchical format file:

[0090]

[0091] As can be seen from the above example, the XML format file has a hierarchical structure, and the hierarchical structure is represented in a recursive manner.

[0092] Furthermore, the hierarchical structure format file contains one or more list levels, each list level containing multiple objects in parallel; wherein, the preset hierarchical structure format file is an XML format file; the start tag containing the parameter name is enclosed in paired angle brackets in the XML format file, and the end tag containing the slash symbol and the parameter name is enclosed in paired angle brackets in the XML format file, with the parameter value located between the start tag and the end tag; the ordinal number of the object in the list level is the number of times the parameter name appears repeatedly in parallel in the XML format file; the list level in the XML format file is the parameter name that appears repeatedly in parallel.

[0093] Specifically, with <author> Jack Herrington< / author> For example, <author> The starting tag that contains the parameter name.< / author> The parameter name is an end label containing a forward slash and the parameter name, with the parameter value JackHerrington located between the start label and the end label.

[0094] The object's index in the list hierarchy is determined by the number of times the parameter name appears repeatedly in parallel as used in the XML format file, as in the above embodiment. <book>Number of times it appears.

[0095] The list hierarchy in the XML format file consists of parameter names that appear repeatedly in parallel, as in the above embodiment. <book>.

[0096] In a non-limiting embodiment, the configuration file can be a JSON file, and the preset hierarchical structure file can be an XML file. The following pseudocode can be used to convert JSON to XML:

[0097]

[0098] It is understood that YAML format files also have hierarchical structures, which can be used in this invention, and will not be elaborated here.

[0099] In the specific implementation of step S13, the extracted key-value pair configuration items can be imported.

[0100] Specifically, the extracted key-value pair configuration items can be imported into a preset device or preset module for processing in subsequent steps.

[0101] In a non-limiting specific embodiment, the extracted key-value pair configuration items can be imported into the configuration center.

[0102] In the specific implementation of step S14, common configuration items can be determined based on the key-value pair configuration items.

[0103] As mentioned earlier, configuration files typically include two parts in terms of structure: comments and configuration items. The configuration items can be considered the main content.

[0104] Furthermore, the step of determining the common configuration item based on the key-value pair configuration item may include: using the key-value pair configuration item as the main content, entering the common configuration item into the configuration center, and generating a common configuration version number.

[0105] Specifically, the key-value pair configuration items can be used as the main content of the file, entered as public configuration items, and necessary information can be added according to the specific situation, such as, but not limited to, appropriate comments.

[0106] In this embodiment of the invention, the key-value pair configuration items are used as the main content, and common configuration items are entered into the configuration center to generate a common configuration version number. By adopting the solution in this embodiment of the invention, since each key-value pair configuration item is used as the main content, and the actual rows of the key-value pair configuration items have consistent format rules, the accuracy of common configuration item maintenance can be improved and the complexity of subsequent maintenance can be reduced.

[0107] Specifically, public configuration maintains all configuration items of the application system, which are entered as key-value pairs. In contrast, private configuration can inherit all key-value pairs from public configuration and supports the entry of private, differentiated configuration items for deployment units, overriding identical configuration items in the public configuration center.

[0108] It should be noted that, in addition to the comments, other appropriate information can be added as needed to obtain common configuration items.

[0109] In this embodiment of the invention, the configuration file is first converted into a preset hierarchical structure format file, and key-value pair configuration items are extracted based on the parameter name and parameter value of the lowest-level parameter in the preset hierarchical structure format file. In the key-value pair configuration storage mode, one actual row represents one configuration item parameter, and each actual row has a row key and a value. The rows have consistent format rules, so the common configuration items determined by the key-value pair configuration items have adaptability, thereby improving the adaptability of the imported file in the import stage. This is beneficial in the maintenance stage, regardless of whether there are differences in the format of the configuration file, since the common configuration items are determined by key-value pair configuration items, the key-value pair parameter values ​​in the key-value pair configuration items can be modified, that is, maintenance can be completed for the modified and updated content, thereby realizing software configuration management at the configuration item level. Compared with the prior art, which directly imports the current configuration file format and requires manual file-level maintenance, the solution of this embodiment of the invention can extract diverse configuration files into key-value pair configuration items for maintenance, which is beneficial to realizing software configuration management at the configuration item level, improving the accuracy of configuration file maintenance, and reducing the complexity of configuration file maintenance.

[0110] Furthermore, before extracting key-value pair configuration items based on the parameter names and parameter values ​​of the lowest-level parameters of the hierarchical format file, the method may further include: pre-constructing a conversion template based on the format type of the hierarchical format file, wherein the conversion template is used to indicate the mapping relationship between the hierarchical format file and the key-value pair configuration items; extracting key-value pair configuration items based on the hierarchical format file includes: using the conversion template to directly extract each parameter name and parameter value of the key-value pair configuration items from the hierarchical format file.

[0111] Reference Figure 2 , Figure 2 This is a flowchart illustrating another method for importing a configuration file according to an embodiment of the present invention. The other method for importing a configuration file may include... Figure 1 Steps S11, S13, and S14 may also include steps S21 and S22, wherein step S21 may precede step S22, and step S22 may precede step S13. The following describes each step.

[0112] In step S21, a conversion template is constructed in advance based on the format type of the hierarchical format file, wherein the conversion template is used to indicate the mapping relationship between the hierarchical format file and the key-value pair configuration items.

[0113] In one specific implementation, since it is a pre-built conversion template, manual construction operations can be added, such as by experienced personnel, and then it can be reused repeatedly in the subsequent extraction stage, thereby reducing the possibility of errors that may occur in the automatically built template.

[0114] In another specific implementation, an automatic construction method or a combination of manual and automatic construction methods can be used to build a conversion template. Then, a certain number of hierarchical structure format files are used to test the constructed conversion template. Since it is a pre-built conversion template, more time can be spent on optimization, which does not affect the extraction efficiency of the subsequent extraction stage and improves the extraction accuracy.

[0115] In step S11, the configuration file is converted into a preset hierarchical structure format file, which contains multiple levels, each level having a parameter name and a parameter value.

[0116] It should be noted that there are no restrictions on the execution order between steps S21 and S11. For more information on step S11, please refer to the preceding text and... Figure 1 The description in the text will not be repeated here.

[0117] In step S22, the conversion template is used to directly extract the parameter names and parameter values ​​of the key-value pair configuration items from the hierarchical structure format file.

[0118] Specifically, since it is a pre-built conversion template, extraction can be performed directly based on the template in the extraction step, which effectively improves extraction efficiency and accuracy.

[0119] In step S13, the extracted key-value pair configuration items are imported.

[0120] In step S14, common configuration items are determined based on the key-value pair configuration items.

[0121] For more details on steps S13 and S14, please refer to the previous text and... Figure 1 The description in the text will not be repeated here.

[0122] In this embodiment of the invention, a conversion template can be pre-built based on the format type of the hierarchical format file. When extracting key-value pair configuration items, the conversion template can be used to directly extract the parameter names and parameter values ​​of each key-value pair configuration item from the hierarchical format file. Since the step of pre-building the conversion template is adopted, manual construction operations can be added without affecting the extraction efficiency, thus reducing the program design complexity of template construction.

[0123] Reference Figure 3 , Figure 3 This is a partial flowchart of another configuration file import method according to an embodiment of the present invention. The other configuration file import method may include... Figure 1 Steps S11 to S14 may also include steps S31 to S33, and each step is explained below.

[0124] In step S31, when the configuration file is updated in one or more environments, the key-value pair parameter values ​​are updated in the key-value pair configuration items of the private configuration items in each environment.

[0125] In practice, parameter values ​​in the key-value pair configuration items of private configuration items in various environments can be updated manually or automatically.

[0126] Reference Figure 4 , Figure 4 yes Figure 3 A flowchart illustrating a specific implementation of step S31 is provided. The step of updating the key-value pair parameter value in the key-value pair configuration item of the private configuration item in various environments may include steps S41 to S42, which are described below.

[0127] In step S41, the key-value pair parameter values ​​in the key-value pair configuration items under each environment are compared to see if there are any differences.

[0128] In step S42, if they exist, the updated key-value pair configuration items for each environment are output, wherein each updated key-value pair configuration item includes key-value pair configuration items that are indistinguishable in the public configuration items and key-value pair configuration items that are different in the private configuration items.

[0129] In this embodiment of the invention, updating the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items in each environment includes: comparing whether there are differences in the key-value pair parameter values ​​in the key-value pair configuration items in each environment; if so, outputting the updated key-value pair configuration items in each environment, wherein each updated key-value pair configuration item includes key-value pair configuration items that are indistinguishable in the public configuration items, and key-value pair configuration items that are different in the private configuration items. By adopting the solution in this embodiment of the invention, batch updates can be achieved by outputting the updated key-value pair configuration items in each environment, resulting in higher update efficiency and accuracy.

[0130] Continue to refer to Figure 3 In step S32, an updated hierarchical structure format file is obtained based on the updated key-value pair configuration items.

[0131] In specific implementation, the values ​​in the key-value pair configuration items can be substituted in an appropriate way to obtain a hierarchical structure format file. This embodiment of the invention does not limit the specific substitution method.

[0132] In a non-limiting specific embodiment, the following pseudocode can be used to obtain a JSON format file based on key-value pair configuration items:

[0133]

[0134] Here, `String prop_key = prop_keys.nextElement();` can be used to obtain the key from the key-value pair, which can be used as the parameter name in the JSON file; `json_config.accumulate(prop_key, properties.get(prop_key));` can be used to indicate multiple nested loops, so that multiple key-value pairs obtained by repeatedly performing this step can be used as parameter names in the JSON file; `return json_config;` can be used to indicate the return of the JSON file.

[0135] In step S33, the updated hierarchical structure format file is converted into the format of the configuration file for import by various environments.

[0136] In this embodiment of the invention, when the configuration file is updated in one or more environments, the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items belonging to each environment are updated; based on the updated key-value pair configuration items, an updated hierarchical structure format file is obtained; the updated hierarchical structure format file is then converted back into the format of the configuration file for download by terminal devices in each environment. Using the solution in this embodiment of the invention, the key-value pair parameter values ​​in the key-value pair configuration items of the private configuration items in each environment can be updated manually or automatically. Since the main content of the private configuration items is key-value pair configuration items, the update complexity is significantly reduced. Whether it is a manual update or an automatic update, it is beneficial to improve update accuracy and maintenance efficiency.

[0137] Reference Figure 5 , Figure 5 This is a schematic diagram of a configuration file import device according to an embodiment of the present invention. The configuration file import device may include:

[0138] The conversion module 51 is used to convert the configuration file into a preset hierarchical structure format file, the hierarchical structure format file containing multiple levels, each level having a parameter name and a parameter value;

[0139] Extraction module 52 is used to extract key-value pair configuration items based on the parameter name and parameter value of the lowest level parameter of the hierarchical structure format file. Each key-value pair configuration item contains a key-value pair parameter name and a key-value pair parameter value. The key-value pair parameter name contains the parameter names of each level, and the parameter names of each level in the key-value pair parameter name are separated by a preset separator.

[0140] Import module 53 is used to import the extracted key-value pair configuration items;

[0141] The common configuration item determination module 54 is used to determine common configuration items based on the key-value pair configuration items.

[0142] For the principles, specific implementation, and beneficial effects of the configuration file import device, please refer to the previous description of the configuration file import method; it will not be repeated here.

[0143] Reference Figure 6 , Figure 6 This is a schematic diagram of the structure of another configuration file import device in an embodiment of the present invention. Except... Figure 5 In addition to the conversion module 51, extraction module 52, import module 53, and common configuration item determination module 54 shown, another configuration file import device may also include:

[0144] The conversion template construction module 61 is used to construct a conversion template in advance based on the format type of the hierarchical format file, wherein the conversion template is used to indicate the mapping relationship between the hierarchical format file and the key-value pair configuration items.

[0145] Specifically, the conversion template pre-built by the conversion template building module 61 can directly extract the key-value pair parameter names and key-value pair parameter values ​​of the key-value pair configuration items from the hierarchical structure format file when the extraction module 52 extracts the key-value pair configuration items.

[0146] After the key-value pair configuration items are imported by the import module 53 and the common configuration items are determined by the common configuration item determination module 54, the configuration center can generate and publish the common configuration version number so that terminal devices in one or more environments can obtain the common configuration items based on the common configuration version number.

[0147] Among them, the public configuration items can be modified based on the public configuration item interface modification module 55, and the public configuration items are determined by the public configuration item determination module 54.

[0148] Furthermore, another configuration file import device may also include: a private configuration item determination module 62, used to update the key-value pair parameter value in the key-value pair configuration item of the private configuration item in each environment when the configuration file is updated in one or more environments, so as to obtain the private configuration item in each environment.

[0149] Among them, the private configuration item can be modified based on the private configuration item interface modification module 64, and the private configuration item determination module 62 updates the key-value pair parameter value.

[0150] Specifically, the private configuration item determination module 62 may inherit each key-value pair configuration item of the public configuration item in the private configuration item, and use the newly added differential key-value pair configuration item to cover the corresponding key-value pair configuration item to obtain the private configuration item in each environment.

[0151] For more information on module 62, which determines private configuration items, please refer to the previous text and... Figure 4 The steps shown will not be repeated here.

[0152] Furthermore, another configuration file import device may also include: a conversion module 63, used to obtain an updated hierarchical structure format file based on the updated key-value pair configuration items; and to convert the updated hierarchical structure format file into the format of the configuration file for download by terminal devices in various environments.

[0153] Specifically, terminal devices in each environment can search for the updated public configuration version number in the current environment and download the private configuration items in the current environment to obtain the updated configuration file.

[0154] For the principles, specific implementation, and beneficial effects of the configuration file import device, please refer to the previous description of the configuration file import method; it will not be repeated here.

[0155] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, performs the steps of the above-described method. The computer-readable storage medium may include, for example, non-volatile or non-transitory memory, and may also include optical discs, hard disk drives, solid-state drives, etc.

[0156] Specifically, in this embodiment of the invention, the processor can be a central processing unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0157] It should also be understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0158] This invention also provides a configuration terminal, including a memory and a processor. The memory stores a computer program that can run on the processor, and the processor executes the steps of the above-described method when running the computer program.

[0159] The configuration terminal can be integrated into or connected to the configuration center, or it can be integrated into or connected to appropriate terminals, such as cloud platforms, servers, computers, etc. The configuration terminal includes, but is not limited to, mobile phones, computers, tablets, servers, cloud platforms, etc.

[0160] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article indicates that the preceding and following related objects have an "or" relationship.

[0161] In the embodiments of this application, "multiple" refers to two or more.

[0162] The descriptions of "first," "second," etc., appearing in the embodiments of this application are for illustrative purposes and to distinguish the objects being described. They have no order and do not indicate any special limitation on the number of devices in the embodiments of this application, nor do they constitute any limitation on the embodiments of this application.

[0163] While the present invention has been disclosed above, it is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the invention; therefore, the scope of protection of the present invention should be determined by the scope defined in the claims.< / book> < / book>

Claims

1. A method for importing a configuration file, characterized in that, include: The configuration file is converted into a preset hierarchical structure format file, which contains multiple levels, each level having parameter names and parameter values; Based on the parameter name and parameter value of the lowest level parameter of the hierarchical structure format file, key-value pair configuration items are extracted. Each key-value pair configuration item contains a key-value pair parameter name and a key-value pair parameter value. The key-value pair parameter name contains the parameter names of each level, and the parameter names of each level in the key-value pair parameter name are separated by a preset separator. Import the extracted key-value pair configuration items; among them, the public configuration items maintain all the configuration items of the application system and are entered into the public configuration in the form of key-value pair configuration items; the private configuration inherits all key-value pair configuration items of the public configuration and supports the entry of private differential configuration items of the deployment unit, which overwrites the same configuration items in the public configuration center; determine the public configuration items based on the key-value pair configuration items; Before extracting key-value pair configuration items based on the parameter names and values ​​of the lowest-level parameters in the hierarchical format file, the method further includes: A conversion template is pre-constructed based on the format type of the hierarchical format file, wherein the conversion template is used to indicate the mapping relationship between the hierarchical format file and the key-value pair configuration items; Based on the hierarchical format file, the extracted key-value pair configuration items include: Using the conversion template, the parameter names and values ​​of each key-value pair configuration item are directly extracted from the hierarchical format file.

2. The method for importing configuration files according to claim 1, characterized in that, The hierarchical structure format file contains one or more list levels, each list level containing multiple objects in parallel; the parameter name of the list level in the key-value pair parameter name is expressed as the parameter name of the list level and the ordinal number of the object to which the lowest level parameter belongs in the list level.

3. The method for importing configuration files according to claim 1 or 2, characterized in that, The parameter names at each level in the key-value pair parameter name are separated by the preset separator, and the order of the parameter names at each level in the key-value pair parameter name is from top to bottom.

4. The method for importing configuration files according to claim 1, characterized in that, The preset hierarchical structure format file is selected from: JSON format file, XML format file, and YAML format file.

5. The method for importing configuration files according to claim 1, characterized in that, The hierarchical format file contains one or more list levels, each containing multiple objects in parallel; The preset hierarchical structure format file is a JSON format file; The parameter names and values ​​for each level are separated by colons in the JSON file; The object is enclosed in curly braces in the JSON format file; The list hierarchy is enclosed in square brackets in the JSON format file.

6. The method for importing configuration files according to claim 1, characterized in that, The hierarchical format file contains one or more list levels, each containing multiple objects in parallel; The preset hierarchical structure format file is an XML format file; The start tag containing the parameter name is enclosed in pairs of angle brackets in the XML format file, and the end tag containing the slash and the parameter name is also enclosed in pairs of angle brackets in the XML format file. The parameter value is located between the start tag and the end tag. The ordinal number of the object in the list hierarchy is the number of times the parameter name appears in parallel repetition in the XML format file. The list hierarchy consists of parameter names that appear repeatedly in parallel within the XML format file.

7. The method for importing configuration files according to claim 1, characterized in that, Based on the key-value pair configuration items, the common configuration items include: The key-value pair configuration items are used as the main content, and the common configuration items are entered into the configuration center to generate a common configuration version number.

8. The method for importing configuration files according to claim 1, characterized in that, Also includes: When the configuration file is updated in one or more environments, the key-value pair parameter values ​​are updated in the key-value pair configuration items of the private configuration items in each environment; Based on the updated key-value pair configuration items, the updated hierarchical structure format file is obtained; The updated hierarchical structure format file is converted into the format of the configuration file for download by terminal devices in various environments.

9. The method for importing configuration files according to claim 8, characterized in that, Updating the key-value pair parameter values ​​in the key-value pair configuration items of private configuration items in various environments includes: Compare the key-value pair parameter values ​​in the key-value pair configuration items under different environments to see if there are any differences. If it exists, the updated key-value pair configuration items for each environment are output, wherein each updated key-value pair configuration item includes key-value pair configuration items that are indistinguishable in the public configuration items, and key-value pair configuration items that are different in the private configuration items.

10. A device for importing configuration files, characterized in that, include: The conversion module is used to convert the configuration file into a preset hierarchical structure format file, which contains multiple levels, each level having a parameter name and a parameter value; The extraction module is used to extract key-value pair configuration items based on the parameter name and parameter value of the lowest level parameter of the hierarchical structure format file. Each key-value pair configuration item contains a key-value pair parameter name and a key-value pair parameter value. The key-value pair parameter name contains the parameter names of each level, and the parameter names of each level in the key-value pair parameter name are separated by a preset separator. The import module is used to import extracted key-value pair configuration items. Among them, the public configuration items maintain all the configuration items of the application system and are entered into the public configuration as key-value pair configuration items. The private configuration inherits all key-value pair configuration items of the public configuration and supports the entry of private differential configuration items of the deployment unit, which can override the same configuration items in the public configuration center. A common configuration item determination module is used to determine common configuration items based on the key-value pair configuration items; A conversion template building module is used to pre-build a conversion template based on the format type of the hierarchical format file, wherein the conversion template is used to indicate the mapping relationship between the hierarchical format file and the key-value pair configuration items; The extraction module is specifically used to extract the parameter names and parameter values ​​of the key-value pair configuration items directly from the hierarchical format file using the conversion template.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program, when run by a processor, performs the steps of the import method for the configuration file as described in any one of claims 1 to 9.

12. A configuration terminal, comprising a memory and a processor, wherein the memory stores a computer program capable of running on the processor, characterized in that, When the processor runs the computer program, it performs the steps of the import method for the configuration file according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • CN112650529A

  • US20200379435A1