CN116841639A - Configuration file modification method and device, computer equipment and storage medium - Google Patents

Configuration file modification method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN116841639A
CN116841639A CN202310693633.4A CN202310693633A CN116841639A CN 116841639 A CN116841639 A CN 116841639A CN 202310693633 A CN202310693633 A CN 202310693633A CN 116841639 A CN116841639 A CN 116841639A
Authority
CN
China
Prior art keywords
node
configuration
modification
linked list
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310693633.4A
Other languages
Chinese (zh)
Inventor
张以哲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
CCB Finetech Co Ltd
Original Assignee
China Construction Bank Corp
CCB Finetech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp, CCB Finetech Co Ltd filed Critical China Construction Bank Corp
Priority to CN202310693633.4A priority Critical patent/CN116841639A/en
Publication of CN116841639A publication Critical patent/CN116841639A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming

Landscapes

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

Abstract

The application relates to a configuration file modification method, a configuration file modification device, computer equipment and a storage medium, which can be applied to the technical field of computers. The method comprises the following steps: receiving a configuration modification request sent by terminal equipment, wherein the configuration modification request comprises a modification operation file, and the modification operation file records information of a plurality of modification operations corresponding to the configuration file to be modified; establishing a configuration linked list corresponding to the configuration file to be modified, wherein each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified; according to the information of the plurality of modification operations, the nodes in the configuration linked list are modified for a plurality of times; and splicing each node in the modified configuration linked list to generate a modified configuration file. By adopting the method, the configuration data in the configuration file can be modified according to the rows, and the modification amplitude of the configuration file is reduced, so that the risk of abnormal program operation after the configuration file is modified is reduced.

Description

Configuration file modification method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and apparatus for modifying a configuration file, a computer device, and a storage medium.
Background
The configuration file is a variable save file with a standardized data format, and can have guiding effect on the execution of the program. The configuration data in the configuration file is closely related to the deployment environment, and in different environments, the configuration data in the configuration file can be different. Environmental changes often occur throughout the life cycle of a configuration file, thus requiring timely modification of the configuration file.
In the related art, when the configuration file is modified, the updated configuration file may be reintroduced. And then, the background can replace the original whole configuration file by using the updated configuration file, thereby completing the modification of the configuration file.
However, the direct replacement of the whole configuration file has larger modification amplitude and more modification quantity, and any row of configuration data errors in the updated configuration file can influence the running of the program, so that the risk of abnormal running of the program after the configuration file is modified is higher.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a configuration file modification method, apparatus, computer device, and storage medium that can reduce the risk of abnormal program operation after configuration file modification.
In a first aspect, the present application provides a method for modifying a configuration file. The method comprises the following steps:
receiving a configuration modification request sent by terminal equipment, wherein the configuration modification request comprises a modification operation file, and the modification operation file records information of a plurality of modification operations corresponding to the configuration file to be modified;
establishing a configuration linked list corresponding to the configuration file to be modified, wherein each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified;
according to the information of the plurality of modification operations, performing a plurality of modifications on the nodes in the configuration linked list;
and splicing each node in the modified configuration linked list to generate a modified configuration file.
In one embodiment, the establishing a configuration linked list corresponding to the configuration file to be modified includes:
traversing each row of configuration data in the configuration file to be modified, and generating a plurality of nodes in the configuration linked list, wherein the node value of each node is the configuration data of the corresponding row of the node;
determining an associated node of each node in the configuration linked list according to the position of each row of configuration data in the configuration file to be modified, wherein the associated node comprises a last node and/or a next node;
And establishing a configuration linked list corresponding to the configuration file to be modified according to the associated node of each node in the configuration linked list.
In one embodiment, the information of the modification operation includes a location identifier of the modification operation and a modification type of the modification operation;
and modifying the nodes in the configuration linked list for a plurality of times according to the information of the plurality of modification operations, wherein the method comprises the following steps:
positioning a corresponding target node of the target modification operation in the configuration linked list according to the position identification of the target modification operation and the modification type of the target modification operation, wherein the target modification operation is any modification operation in the plurality of modification operations;
and carrying out the target modification operation on the target node.
In one embodiment, if the modification type is a delete type or an update type, the locating the target node corresponding to the target modification operation in the configuration linked list includes:
and determining the node matched with the position identification as the target node.
In one embodiment, the performing the target modification operation on the target node includes:
if the target modification operation is a deletion type operation, deleting the target node;
And if the target modification operation is an update type operation, replacing the node value in the target node by using the configuration data in the information of the target modification operation.
In one embodiment, if the modification type is an addition type, the locating the target node corresponding to the target modification operation in the configuration linked list includes:
determining whether a node matched with the position identifier exists in the current configuration linked list;
and if the node matched with the position identifier exists and the node matched with the position identifier is the last node in the configuration linked list, determining the node matched with the position identifier as the target node.
In one embodiment, after said determining whether there is a node in the current configuration linked list that matches the location identity, the method further comprises:
if the node matched with the position identifier exists and the node matched with the position identifier is not the last node in the configuration linked list, determining the last continuously newly-added node after the node matched with the position identifier according to the position identifier of each node in the configuration linked list;
And determining the last continuously added node as the target node.
In one embodiment, after said determining whether there is a node in the current configuration linked list that matches the location identity, the method further comprises:
and if no node matched with the position identification exists and the node corresponding to the position identification is the first node in the initial configuration linked list, determining that the target node does not exist in the current configuration linked list.
In one embodiment, after said determining whether there is a node in the current configuration linked list that matches the location identity, the method further comprises:
if no node matched with the position identifier exists and the node corresponding to the position identifier is not the first node in the initial configuration linked list, subtracting one from the value of the position identifier to update the position identifier until the node matched with the updated position identifier is inquired;
and determining the target node according to the node matched with the updated position identification.
In one embodiment, the performing the target modification operation on the target node includes:
generating a new node of the configuration linked list according to the configuration data in the information of the target modification operation;
And adding the newly added node after the target node.
In one embodiment, the modification operation file is a form file, and each row of forms in the form file is used for recording information of one modification operation.
In a second aspect, the application further provides a device for modifying the configuration file. The device comprises:
the system comprises a receiving module, a configuration modification module and a configuration processing module, wherein the receiving module is used for receiving a configuration modification request sent by a terminal device, the configuration modification request comprises a modification operation file, and information of a plurality of modification operations corresponding to a configuration file to be modified is recorded in the modification operation file;
the setting module is used for setting up a configuration linked list corresponding to the configuration file to be modified, and each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified;
the modification module is used for modifying the nodes in the configuration linked list for a plurality of times according to the information of the plurality of modification operations; and splicing each node in the modified configuration linked list to generate a modified configuration file.
In one embodiment, the building module is specifically configured to traverse each row of configuration data in the configuration file to be modified, generate a plurality of nodes in the configuration linked list, and a node value of each node is the configuration data of the corresponding row of the node; determining an associated node of each node in the configuration linked list according to the position of each row of configuration data in the configuration file to be modified, wherein the associated node comprises a last node and/or a next node; and establishing a configuration linked list corresponding to the configuration file to be modified according to the associated node of each node in the configuration linked list.
In one embodiment, the information of the modification operation includes a location identifier of the modification operation and a modification type of the modification operation;
the modification module is specifically configured to locate a target node corresponding to a target modification operation in the configuration linked list according to a location identifier of the target modification operation and a modification type of the target modification operation, where the target modification operation is any modification operation in the plurality of modification operations; and carrying out the target modification operation on the target node.
In one embodiment, if the modification type is a deletion type or an update type, the modification module is specifically configured to determine a node that matches the location identifier as the target node.
In one embodiment, the modification module is specifically configured to delete the target node if the target modification operation is a delete class operation; and if the target modification operation is an update type operation, replacing the node value in the target node by using the configuration data in the information of the target modification operation.
In one embodiment, if the modification type is an addition type, the modification module is specifically configured to determine whether a node matching the location identifier exists in the current configuration linked list; and if the node matched with the position identifier exists and the node matched with the position identifier is the last node in the configuration linked list, determining the node matched with the position identifier as the target node.
In one embodiment, the modification module is specifically configured to determine, if there is a node that matches the location identifier and the node that matches the location identifier is not the last node in the configuration linked list, a last continuously added node after the node that matches the location identifier according to the location identifiers of the nodes in the configuration linked list; and determining the last continuously added node as the target node.
In one embodiment, the modifying module is specifically configured to determine that the target node does not exist in the current configuration linked list if there is no node that matches the location identifier and the node that corresponds to the location identifier is a first node in the initial configuration linked list.
In one embodiment, the modifying module is specifically configured to, if there is no node that matches the location identifier and the node that corresponds to the location identifier is not the first node in the initial configuration linked list, continuously subtracting one from the value of the location identifier to update the location identifier until a node that matches the updated location identifier is queried; and determining the target node according to the node matched with the updated position identification.
In one embodiment, the modification module is specifically configured to generate a new node of the configuration linked list according to configuration data in the information of the target modification operation; and adding the newly added node after the target node.
In one embodiment, the modification operation file is a form file, and each row of forms in the form file is used for recording information of one modification operation.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor executing the method of modifying the configuration file described above.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which is executed by a processor by the above-described configuration file modification method.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which is executed by a processor for performing the method of modifying a configuration file as described above.
The configuration file modification method, the configuration file modification device, the computer equipment and the storage medium firstly receive a configuration modification request sent by the terminal equipment, wherein the configuration modification request comprises a modification operation file, and a plurality of pieces of information of modification operations corresponding to the configuration file to be modified are recorded in the modification operation file. And then, establishing a configuration linked list corresponding to the configuration file to be modified, wherein each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified. And finally, according to the information of the plurality of modification operations, modifying the nodes in the configuration linked list for a plurality of times, and splicing each node in the modified configuration linked list to generate a modified configuration file. By the method, configuration data in the configuration file can be modified according to the rows, and the modification amount of the configuration file is reduced, so that the risk of abnormal program operation after the configuration file is modified is reduced.
Drawings
FIG. 1 is an application environment diagram of a method for modifying a configuration file according to an embodiment of the present application;
fig. 2 is a flow chart of a method for modifying a configuration file according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a configuration linked list according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a method for establishing a configuration linked list according to an embodiment of the present application;
fig. 5 is a schematic flow chart of a node query method according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating a method for modifying a node in a configuration linked list according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a configuration file modification device according to an embodiment of the present application;
fig. 8 is an internal structure diagram of a computer device according to an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The configuration file modification method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server.
The terminal 102 may send a configuration modification request to the server to upload the modification operation file. Server 104 may establish a configuration linked list corresponding to the configuration file to be modified and modify nodes in the configuration linked list based on each modification operation in the modification operation file. After the modification is completed, the server 104 may splice each node in the modified configuration chain table to generate a modified configuration file.
The terminal 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, etc. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In one embodiment, as shown in fig. 2, a method for modifying a configuration file is provided, and the method is applied to the server in fig. 1 for illustration, and includes S201-S204:
s201, receiving a configuration modification request sent by the terminal equipment, wherein the configuration modification request comprises a modification operation file, and the modification operation file records information of a plurality of modification operations corresponding to the configuration file to be modified.
In the application, when the configuration file needs to be modified, the terminal can send the configuration modification request to the server, so that the server carries out multiple modification operations on the configuration file to be modified through the modification operation file in the configuration modification request.
The modification operation file may be a form file, where each row of forms in the form file is used to record information of a modification operation. Correspondingly, by setting a plurality of rows of forms in the form file and adding information of corresponding modification operations in each row of forms, the modification operations for the configuration file can be imported in batches, so that the modification speed of the configuration file is improved.
The configuration file to be modified may be a non-performance (properties) configuration file, where the properties configuration file may be a configuration file of a key value pair not in each row, and may include: extensible markup language (Extensible Markup Language, XML) files, another markup language (YAML Ain't a Markup Language, YAML) files, configuration commands (Config, conf), object profile files (JavaScript Object Notation, JSON), and the like.
It should be understood that the embodiment of the present application does not limit the information of the modification operation, and in some embodiments, the information of the modification operation may include a serial number of the modification operation, a name of a configuration file to be modified, a modification type of the modification operation, a location identifier of the modification operation, updated configuration data, a prefix space number, a suffix space number, and the like.
It should be understood that the above-described profile names to be modified are used to indicate the profiles to be modified. The location identifier of the modification operation may be a snapshot line number of the unmodified configuration file, which is used to indicate a location in the configuration file where the modification operation is to be modified. The updated configuration data is used for replacing the original configuration data or is newly added configuration data in the configuration file. Since the form file automatically filters the preceding and following spaces during parsing, the prefix space number and the suffix space number are used to indicate the number of spaces to be vacated before and after the character content of the updated configuration data.
In the embodiment of the application, since the configuration file is stored in the database of the server, the user initiating the configuration modification request needs to be authenticated every time the configuration file is modified, thereby ensuring that only an administrator can modify the configuration file in the server. By recording the information of the plurality of modification operations in the modification operation file according to the row, when an administrator performs the plurality of modification operations, the modification operation file is only required to be uploaded to the server through the configuration modification request, the server performs a plurality of modifications on the configuration file after analyzing the modification operation file, and the modified configuration file can be pushed to each unit of the micro service after the modification is completed, so that the batch import of the plurality of modification operations is realized, and the modification speed of the configuration file is accelerated.
S202, establishing a configuration linked list corresponding to the configuration file to be modified.
In this step, after the server receives the configuration modification request sent by the terminal device, a configuration linked list corresponding to the configuration file to be modified may be established.
It should be appreciated that a linked list is a non-contiguous, non-sequential storage structure on physical storage elements, with the logical order of data elements being achieved by the order of pointer links in the linked list. The linked list includes a number of column nodes, which may be dynamically generated at runtime. Correspondingly, the configuration linked list in the embodiment of the application can also comprise a plurality of nodes, and each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified.
It should be noted that the modification operation file may correspond to one configuration file to be modified, or may correspond to a plurality of configuration files to be modified, and may be determined according to a configuration file name to be modified in information of each line of modification operation in the modification configuration file. If the modification operation file corresponds to a plurality of configuration files to be modified, each configuration file to be modified can establish a configuration linked list.
In some embodiments, the configuration linked list is a doubly linked list, and each node in the doubly linked list has two pointers that can respectively indicate the previous node and the next node
It should be understood that, in the embodiment of the present application, no limitation is imposed on how to create the configuration linked list corresponding to the configuration file to be modified, and in some embodiments, the server may traverse each row of configuration data in the configuration file to be modified to generate a plurality of nodes in the configuration linked list, where a node value of each node is the configuration data of the row corresponding to the node. And then, the server determines the associated node of each node in the configuration chain table according to the position of each row of configuration data in the configuration file to be modified, wherein the associated node comprises the last node and/or the next node. And finally, the server establishes a configuration linked list corresponding to the configuration file to be modified according to the associated node of each node in the configuration linked list.
The last node and/or the next node included in the associated node of each node may be the nodes pointed by the two pointers of the doubly linked list, and the direct successor and the direct predecessor of each node may be determined by configuring the associated node of each node in the linked list, so as to form the configuration linked list corresponding to the configuration file to be modified.
By way of example, the server may determine, by the location of each row of configuration data in the configuration file to be modified, the previous row of configuration data and the next row of configuration data for the row of configuration data, thereby determining the node of the previous row of configuration data as the previous node of the node corresponding to the row of configuration data and the node of the next row of configuration data as the next node of the node corresponding to the row of configuration data.
Fig. 3 is a schematic diagram of a configuration linked list according to an embodiment of the present application. As shown in fig. 3, the configuration linked list includes a plurality of nodes, and two adjacent nodes are indicated in both directions. Related information may be stored in each node, which may include a node value, a previous node, a next node, and a location identifier.
The node value may be configuration data of a row corresponding to the node. The location identifier may be a snapshot line number, that is, an initial line number of the configuration data corresponding to the node before the configuration file is modified. If the node is the first node, the value of the last node of the node is null, and if the node is the last node, the value of the next node of the node is null.
S203, modifying the nodes in the configuration chain table for a plurality of times according to the information of the plurality of modification operations.
In this step, after the server establishes the configuration linked list corresponding to the configuration file to be modified, the server may read each line of form information in the form file from top to bottom, so as to sequentially execute the modification operation corresponding to each line of form information.
It should be understood that the embodiments of the present application do not limit how many modifications are made to nodes in the configuration linked list, and in some embodiments, the information of the modification operation includes a location identifier of the modification operation and a modification type of the modification operation. Correspondingly, the server can position the corresponding target node of the target modification operation in the configuration linked list according to the position identification of the target modification operation and the modification type of the target modification operation, wherein the target modification operation is any modification operation in a plurality of modification operations. The server may then perform a target modification operation on the target node.
The location identifier may be a snapshot line number, which is used to indicate a line number of the configuration data to be modified in the unmodified configuration file. The modification type of the modification operation may include a delete type, an update type, or an add type, where the delete type of modification operation is used to delete a certain row of configuration data, the update type of modification operation is used to replace a certain row of configuration data, and the add type of modification operation is used to add a certain row of configuration data.
The following describes a modification operation in which the modification type is a deletion type or an update type.
In some embodiments, if the modification type is a delete type or an update type, the server may directly determine the node that matches the location identity as the target node. If the target modification operation is a delete class operation, the server may delete the target node to complete the modification operation. If the target modifying operation is an updating type operation, the node value in the target node is replaced by the configuration data in the information of the target modifying operation so as to complete the modifying operation.
It should be understood that, since each node records the previous node and the next node of the node, for the deletion class operation, after deleting the target node, the associated node of the previous node of the target node may be modified from the target node to the next node of the target node, and the associated node of the next node of the target node may be modified from the target node to the previous node of the target node, so that the previous node and the next node of the target node are connected.
It should be noted that, for a modification operation with a modification type of a deletion type or an update type, if a node matching with the location identifier is not found, it may be determined that the target node does not exist, and the modification operation does not need to be executed.
The following describes a modification operation in which the modification type is the addition type.
In some embodiments, if the modification type is an add type, the server may determine whether there is a node in the current configuration linked list that matches the location identification. If the node matched with the position identifier exists and the node matched with the position identifier is the last node in the configuration linked list, the node matched with the position identifier is determined to be a target node.
It should be appreciated that the server may determine that the target node has not been deleted because there is a node that matches the location identity. And when the node matched with the position identifier is the last node in the configuration linked list, the server can determine that no other newly-added node is arranged after the node matched with the position identifier, and can directly position the target node at the moment.
In some embodiments, after determining whether a node matching the location identifier exists in the current configuration linked list, if the node matching the location identifier exists and the node matching the location identifier is not the last node in the configuration linked list, determining the last continuously added node after the node matching the location identifier according to the location identifiers of the nodes in the configuration linked list. And determining the last continuously added node as a target node.
It should be appreciated that since the newly added node in the configuration linked list has no location identifier, when there are other addition types of modification operations before the target modification operation, there may be other newly added nodes after the target node, and thus, it is necessary to determine the last consecutive newly added node so as to insert the newly added node of the modification operation after the last consecutive newly added node. Accordingly, since the newly added node has no location identifier, the last continuously added node can be determined by whether the location identifier exists in the node after the node matched with the location identifier. The server may determine a node next to the node having the location identifier after the node having the location identifier, as a last consecutive newly added node.
In some embodiments, after determining whether a node matching the location identifier exists in the current configuration linked list, if the node matching the location identifier does not exist and the node corresponding to the location identifier is the first node in the initial configuration linked list, determining that the target node does not exist in the current configuration linked list.
It should be appreciated that since the modification operation prior to the target operation may have deleted some nodes, there may not be a node matching the location identity, at which point the node prior to the location identity may be looked up. Because there is no previous node when the node corresponding to the location identifier is the first node in the initial configuration linked list, if there is no node matching the location identifier and the node corresponding to the location identifier is the first node in the initial configuration linked list, it can be determined that there is no target node, and the server does not need to execute the modification operation at this time.
In some embodiments, after determining whether a node matching the location identifier exists in the current configuration linked list, if no node matching the location identifier exists and the node corresponding to the location identifier is not the first node in the initial configuration linked list, subtracting one from the value of the location identifier to update the location identifier until the node matching the updated location identifier is queried; and determining the target node according to the node matched with the updated position identification.
For example, the server may subtract the value of the location identifier one at a time to update the location identifier and then query for nodes that match the updated location identifier. If no node matching the updated location identifier is queried, the value of the location identifier may be decremented by one again each time to update the location identifier, and the node matching the updated location identifier may be found again. The server loops through until a node is queried that matches the updated location identification.
It should be noted that, after querying the node matching the updated location identifier, the server also needs to determine whether the node matching the updated location identifier is the last node. If yes, determining the node matched with the updated position identification as a target node. If not, determining the last continuously added node after the node with the matched updated position identification as a target node.
In some embodiments, after the server determines the target node, a new node of the configuration linked list may be generated according to the configuration data in the information of the target modification operation, and the new node may be added after the target node.
When the new node is added, the configuration data in the information of the target modification operation may be used as the node value of the new node. Meanwhile, the newly added node, the last node of the newly added node and the associated node of the next node of the newly added node need to be modified so as to finish the insertion of the newly added node.
The embodiment of the application adopts a chain table type mode to position the target node to execute the modification operation, can avoid the offset of the line number corresponding to the configuration data caused by the addition and deletion modification of the configuration data by the previous modification operation in the related technology, does not have the problem of the execution sequence of the modification operation, and can ensure that the configuration data added in a specified way is inserted into an accurate position.
S204, splicing each node in the modified configuration chain table to generate a modified configuration file.
In this step, after the server modifies the nodes in the configuration linked list for multiple times, each node in the modified configuration linked list may be spliced to generate a modified configuration file.
It should be understood that the embodiment of the present application does not limit how each node in the modified configuration linked list is spliced, and in some embodiments, the server may splice the node value of each node in the modified configuration linked list, thereby forming a modified configuration file.
For example, if the configuration linked list includes four nodes, the node value of the first node is "a", the node value of the second node is "abc", the node value of the third node is "hig", and the node value of the fourth node is "efg", the server may splice the node values of the respective nodes to "a/abc/hig/efg", and the node value of each node is a row of configuration data, thereby forming a modified configuration file.
The modification method provided by the embodiment of the application can directly modify various types of configuration files. Because of the numerous types of configuration files, the related art relies on a third party library to parse the configuration files. The configuration files are modified in a mode of collecting the configuration linked list, and various types of configuration files can be modified without depending on a third party library, so that the risk of open sources is avoided, the safety is ensured, and the maintenance workload of operation and maintenance personnel on the configuration files is reduced.
In addition, compared with the method of directly importing the whole configuration file to carry out replacement modification, the configuration file modification method adopted by the application can modify the configuration file row by row because the configuration file is modified based on the configuration linked list, only the configuration data of the configuration file in the designated row is modified, other parts still use the original configuration data, the modification amount is reduced, and the risk of abnormal program operation after the configuration file is modified is further reduced.
The configuration file modification method, the configuration file modification device, the computer equipment and the storage medium firstly receive a configuration modification request sent by the terminal equipment, wherein the configuration modification request comprises a modification operation file, and a plurality of pieces of information of modification operations corresponding to the configuration file to be modified are recorded in the modification operation file. And then, establishing a configuration linked list corresponding to the configuration file to be modified, wherein each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified. And finally, according to the information of the plurality of modification operations, modifying the nodes in the configuration linked list for a plurality of times, and splicing each node in the modified configuration linked list to generate a modified configuration file. By the method, configuration data in the configuration file can be modified according to the rows, and the modification amount of the configuration file is reduced, so that the risk of abnormal program operation after the configuration file is modified is reduced.
In some embodiments, as shown in fig. 4, a method for setting up a configuration linked list is provided, where the method for setting up a configuration linked list corresponding to a configuration file to be modified is used to describe a specific process. The method for establishing the configuration linked list comprises S401-S410:
s401, determining the total number of rows of configuration data in the configuration file to be modified.
S402, sequentially reading one row of configuration data in the configuration file to be modified.
The sequence is from top to bottom according to the row numbers of the configuration files.
S403, generating nodes in the configuration data by taking the read configuration data as node values.
S404, taking the row number of the read configuration data as the snapshot row number of the currently generated node.
S405, determining whether the currently generated node is the first node.
If yes, S406 is executed, and if no, S407 is executed.
S406, determining that the currently generated node has no previous node.
After S406 is performed, S407 is performed.
S407, taking the previous generated node as the previous node of the current generated node, and taking the current generated node as the next node of the previous generated node.
S408, determining whether the generated node number is smaller than the configuration total number of rows.
If yes, S402 is executed, and if no, S409 is executed.
S409, determining the currently generated node as the last node.
S410, outputting a configuration linked list corresponding to the configuration file to be modified.
In some embodiments, as shown in fig. 5, a node query method is provided for querying nodes matching a location identity of a target modification operation when multiple modifications are made to nodes in a configuration linked list. The node query method comprises the steps of S501-S504:
s501, determining a position identifier of the target modification operation.
S502, sequentially reading the position identification of one node in the configuration linked list.
S503, determining whether the position identification of the target modification operation is consistent with the read position identification of the node.
If yes, S504 is executed, and if no, S502 is executed.
S504, determining the read node as a node matched with the position identification of the target modification operation.
In some embodiments, as shown in fig. 6, a method of modifying a node in a configuration linked list is provided to illustrate how different types of modification operations are performed. The method for modifying the nodes in the configuration linked list comprises S601-S504:
S601, determining whether the modification operation is an addition type.
If yes, S607 is executed, and if no, S602 is executed.
S602, whether a node matched with the position identification of the modification operation is queried or not.
If yes, S603 is executed, and if no, S604 is executed.
S603, determining that the target node does not exist.
S604, determining whether the modification operation is a deletion type.
If yes, S605 is executed, and if no, S606 is executed.
S605, deleting the target node.
S606, replacing the node value in the target node by using the configuration data in the information of the target modification operation.
S607, whether the node matching the position identification of the modification operation is queried.
If yes, S611 is executed, and if no, S608 is executed.
S608, determining whether the node corresponding to the position identification is the first node in the initial configuration linked list.
If yes, S603 is executed, and if no, S609 is executed.
S609, the value of the location identifier of the modification operation is decremented by one.
S610, whether the node matched with the position identification is inquired.
If yes, S611 is executed, and if no, S609 is executed.
S611, determining whether the node matched with the position identification is the last node.
If yes, S612 is executed, and if no, S613 is executed.
S612, determining the node matched with the position identifier as a target node.
S615 is performed after S612.
S613, determining the last continuously newly added node after the node matched with the position identification.
S614, determining the last continuously added node as a target node.
S615, adding new nodes after the target nodes.
The configuration file modification method, the configuration file modification device, the computer equipment and the storage medium firstly receive a configuration modification request sent by the terminal equipment, wherein the configuration modification request comprises a modification operation file, and a plurality of pieces of information of modification operations corresponding to the configuration file to be modified are recorded in the modification operation file. And then, establishing a configuration linked list corresponding to the configuration file to be modified, wherein each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified. And finally, according to the information of the plurality of modification operations, modifying the nodes in the configuration linked list for a plurality of times, and splicing each node in the modified configuration linked list to generate a modified configuration file. By the method, configuration data in the configuration file can be modified according to the rows, and the modification amount of the configuration file is reduced, so that the risk of abnormal program operation after the configuration file is modified is reduced.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a modification device for realizing the modification method of the configuration file. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiment of the modification device for one or more configuration files provided below may refer to the limitation of the modification method for a configuration file hereinabove, and will not be described herein.
In one embodiment, as shown in fig. 7, there is provided a configuration file modification apparatus 700, including: a receiving module 701, a setting-up module 702 and a modifying module 703, wherein:
a receiving module 701, configured to receive a configuration modification request sent by a terminal device, where the configuration modification request includes a modification operation file, and information of a plurality of modification operations corresponding to a configuration file to be modified is recorded in the modification operation file;
the establishing module 702 is configured to establish a configuration linked list corresponding to the configuration file to be modified, where each node in the configuration linked list corresponds to a row of configuration data in the configuration file to be modified;
a modifying module 703, configured to modify the nodes in the configuration linked list for multiple times according to the information of multiple modifying operations; and splicing each node in the modified configuration linked list to generate a modified configuration file.
In one embodiment, the establishing module 702 is specifically configured to traverse each row of configuration data in the configuration file to be modified, generate a plurality of nodes in the configuration linked list, and the node value of each node is the configuration data of the row corresponding to the node; determining associated nodes of each node in a configuration chain table according to the position of each row of configuration data in a configuration file to be modified, wherein the associated nodes comprise a last node and/or a next node; and establishing a configuration linked list corresponding to the configuration file to be modified according to the associated node of each node in the configuration linked list.
In one embodiment, the information of the modification operation includes a location identifier of the modification operation and a modification type of the modification operation;
the modification module 703 is specifically configured to locate, according to the location identifier of the target modification operation and the modification type of the target modification operation, a target node corresponding to the target modification operation in the configuration linked list, where the target modification operation is any modification operation in the plurality of modification operations; and performing target modification operation on the target node.
In one embodiment, if the modification type is a delete type or an update type, the modification module 703 is specifically configured to determine the node that matches the location identifier as the target node.
In one embodiment, the modification module 703 is specifically configured to delete the target node if the target modification operation is a delete class operation; if the target modification operation is an update class operation, the node value in the target node is replaced by the configuration data in the information of the target modification operation.
In one embodiment, if the modification type is the addition type, the modification module 703 is specifically configured to determine whether a node matching the location identifier exists in the current configuration linked list; if the node matched with the position identifier exists and the node matched with the position identifier is the last node in the configuration linked list, the node matched with the position identifier is determined to be a target node.
In one embodiment, the modification module 703 is specifically configured to determine, if there is a node that matches the location identifier and the node that matches the location identifier is not the last node in the configuration linked list, a last continuously added node after the node that matches the location identifier according to the location identifiers of the nodes in the configuration linked list; and determining the last continuously added node as a target node.
In one embodiment, the modifying module 703 is specifically configured to determine that the current configuration linked list does not have the target node if there is no node that matches the location identifier and the node that corresponds to the location identifier is the first node in the initial configuration linked list.
In one embodiment, the modifying module 703 is specifically configured to, if there is no node that matches the location identifier and the node that corresponds to the location identifier is not the first node in the initial configuration linked list, continuously subtracting one from the value of the location identifier to update the location identifier until the node that matches the updated location identifier is queried; and determining the target node according to the node matched with the updated position identification.
In one embodiment, the modification module 703 is specifically configured to generate a new node of the configuration linked list according to the configuration data in the information of the target modification operation; and adding a newly added node after the target node.
In one embodiment, the modification operation file is a form file, and each row of forms in the form file is used to record information of one modification operation.
The various modules in the configuration file modifying device may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 8. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing data. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of modifying a configuration file.
It will be appreciated by those skilled in the art that the structure shown in FIG. 8 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided that includes a memory having a computer program stored therein and a processor that implements the method of modifying a configuration file described above when the computer program is executed.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, provides a method of modifying the above-described configuration file.
In an embodiment, a computer program product is provided comprising a computer program which, when executed by a processor, is a method of modifying the above-mentioned configuration file.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (15)

1. A method for modifying a configuration file, the method comprising:
receiving a configuration modification request sent by terminal equipment, wherein the configuration modification request comprises a modification operation file, and the modification operation file records information of a plurality of modification operations corresponding to the configuration file to be modified;
establishing a configuration linked list corresponding to the configuration file to be modified, wherein each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified;
According to the information of the plurality of modification operations, performing a plurality of modifications on the nodes in the configuration linked list;
and splicing each node in the modified configuration linked list to generate a modified configuration file.
2. The method of claim 1, wherein the establishing a configuration linked list corresponding to the configuration file to be modified comprises:
traversing each row of configuration data in the configuration file to be modified, and generating a plurality of nodes in the configuration linked list, wherein the node value of each node is the configuration data of the corresponding row of the node;
determining an associated node of each node in the configuration linked list according to the position of each row of configuration data in the configuration file to be modified, wherein the associated node comprises a last node and/or a next node;
and establishing a configuration linked list corresponding to the configuration file to be modified according to the associated node of each node in the configuration linked list.
3. The method according to claim 1, wherein the information of the modification operation includes a location identifier of the modification operation and a modification type of the modification operation;
and modifying the nodes in the configuration linked list for a plurality of times according to the information of the plurality of modification operations, wherein the method comprises the following steps:
Positioning a corresponding target node of the target modification operation in the configuration linked list according to the position identification of the target modification operation and the modification type of the target modification operation, wherein the target modification operation is any modification operation in the plurality of modification operations;
and carrying out the target modification operation on the target node.
4. The method of claim 3, wherein if the modification type is a delete type or an update type, the locating the corresponding target node of the target modification operation in the configuration linked list comprises:
and determining the node matched with the position identification as the target node.
5. The method of claim 4, wherein said performing said target modification operation on said target node comprises:
if the target modification operation is a deletion type operation, deleting the target node;
and if the target modification operation is an update type operation, replacing the node value in the target node by using the configuration data in the information of the target modification operation.
6. The method of claim 3, wherein if the modification type is an add type, the locating the corresponding target node of the target modification operation in the configuration linked list comprises:
Determining whether a node matched with the position identifier exists in the current configuration linked list;
and if the node matched with the position identifier exists and the node matched with the position identifier is the last node in the configuration linked list, determining the node matched with the position identifier as the target node.
7. The method of claim 6, wherein after said determining whether there is a node in the current configuration linked list that matches the location identity, the method further comprises:
if the node matched with the position identifier exists and the node matched with the position identifier is not the last node in the configuration linked list, determining the last continuously newly-added node after the node matched with the position identifier according to the position identifier of each node in the configuration linked list;
and determining the last continuously added node as the target node.
8. The method of claim 6, wherein after said determining whether there is a node in the current configuration linked list that matches the location identity, the method further comprises:
and if the node matched with the position identifier does not exist and the node corresponding to the position identifier is the first node in the initial configuration linked list, determining that the target node does not exist in the current configuration linked list.
9. The method of claim 6, wherein after said determining whether there is a node in the current configuration linked list that matches the location identity, the method further comprises:
if no node matched with the position identifier exists and the node corresponding to the position identifier is not the first node in the initial configuration linked list, subtracting one from the value of the position identifier to update the position identifier until the node matched with the updated position identifier is inquired;
and determining the target node according to the node matched with the updated position identification.
10. The method according to any of claims 6-9, wherein said performing said target modification operation on said target node comprises:
generating a new node of the configuration linked list according to the configuration data in the information of the target modification operation;
and adding the newly added node after the target node.
11. The method of claim 1, wherein the modification operation file is a form file, and each row of forms in the form file is used to record information of one modification operation.
12. A device for modifying a configuration file, the device comprising:
The system comprises a receiving module, a configuration modification module and a configuration processing module, wherein the receiving module is used for receiving a configuration modification request sent by a terminal device, the configuration modification request comprises a modification operation file, and information of a plurality of modification operations corresponding to a configuration file to be modified is recorded in the modification operation file;
the setting module is used for setting up a configuration linked list corresponding to the configuration file to be modified, and each node in the configuration linked list corresponds to one row of configuration data in the configuration file to be modified;
the modification module is used for modifying the nodes in the configuration linked list for a plurality of times according to the information of the plurality of modification operations; and splicing each node in the modified configuration linked list to generate a modified configuration file.
13. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 11 when the computer program is executed.
14. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 11.
15. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any one of claims 1 to 11.
CN202310693633.4A 2023-06-12 2023-06-12 Configuration file modification method and device, computer equipment and storage medium Pending CN116841639A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310693633.4A CN116841639A (en) 2023-06-12 2023-06-12 Configuration file modification method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310693633.4A CN116841639A (en) 2023-06-12 2023-06-12 Configuration file modification method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116841639A true CN116841639A (en) 2023-10-03

Family

ID=88169701

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310693633.4A Pending CN116841639A (en) 2023-06-12 2023-06-12 Configuration file modification method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116841639A (en)

Similar Documents

Publication Publication Date Title
CN111177302B (en) Service bill processing method, device, computer equipment and storage medium
CN105468473A (en) Data migration method and data migration apparatus
CN111324577B (en) Yml file reading and writing method and device
CN110968509B (en) Method and system for batch customizing of variables
WO2021179488A1 (en) Monitoring data storage method and device, server and storage medium
CN114138907A (en) Data processing method, computer device, storage medium, and computer program product
CN116841639A (en) Configuration file modification method and device, computer equipment and storage medium
CN111428114A (en) Index creating method and device for Elasticissearch search engine
CN115061726A (en) Script file batch processing method, device, equipment, medium and program product
CN114297196A (en) Metadata storage method and device, electronic equipment and storage medium
CN110222105B (en) Data summarization processing method and device
CN117131023B (en) Data table processing method, device, computer equipment and readable storage medium
CN116055589B (en) Data management method and device and computer equipment
CN117851341B (en) Metadata indexing method, apparatus, computer device and storage medium
CN112445759B (en) Method and device for copying data across clusters of distributed database and electronic equipment
CN116880927A (en) Rule management method, device, computer equipment and storage medium
CN117033518A (en) Data synchronization method, device, computer equipment and storage medium
CN117033172A (en) Test data processing method, apparatus, device, storage medium and program product
CN117851348A (en) Method for efficiently exporting import file by RBD snapshot
CN118151988A (en) Engineering library comparison method, device, computer equipment and storage medium
CN116614513A (en) Block chain data migration method, device, computer equipment and storage medium
CN117743299A (en) Database migration method, device, equipment, medium and product
CN118394846A (en) Data synchronization method and device, electronic equipment and storage medium
CN118113595A (en) Test case generation method, device, computer equipment and storage medium
CN117234562A (en) Configuration parameter updating method and device and computer equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination