Configuration file synchronous updating method and device
By using hashmap and treeset data structures in the configuration center server to compare the keys and values of configuration files from multiple environments, the problems of omissions and errors in configuration file synchronization updates are solved, thus improving configuration efficiency and accuracy.
Patent Information
- Application Number
- CN202511178039.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-12-05
AI Technical Summary
Existing configuration center servers are prone to omissions and errors during the synchronous update of configuration files in multiple environments, and cannot effectively support the comparison and modification of configuration files in multiple environments, resulting in low configuration efficiency.
By reading the configuration file content of the configuration center server in multiple environments line by line, using hashmap and treeset data structures to remove duplicates and reorder them, comparing the key and value values in turn to see if they are consistent, and returning the differences to the client for modification and synchronization updates.
It enables accurate synchronization and updating of configuration files across multiple environments, improving the efficiency and accuracy of configuration file comparison, simplifying the operation process, and reducing the error rate.
Smart Images

Figure CN121070461A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and can also be used in the field of finance, in particular to a configuration file synchronous updating method and device. BACKGROUND
[0002] The configuration center implements the configuration management of micro services, and developers, configuration personnel, operation and maintenance personnel and the like can conveniently perform service configuration adding, modifying and the like on the configuration center.
[0003] At present, the developers have a set of development environment configuration center servers and service configuration files in the development stage, the configuration personnel have a set of acceptance environment configuration center servers and service configuration files in the acceptance stage, and a set of configuration center servers and service configuration files in the production environment; the configuration files need to be synchronously updated in the development environment, the acceptance environment, the production environment and the like. However, the existing configuration center servers only support comparison of two files on the same set of services, and in this process, the problems of omission and content error may occur.
[0004] This section is intended to provide background or context to the embodiments of the application recited in the claims. The description herein does not constitute admission of prior art. SUMMARY
[0005] The embodiments of the present application provide a configuration file synchronous updating method and device to solve the problems of configuration file content omission and error of the configuration center servers in multiple environments.
[0006] The embodiments of the present application provide a configuration file synchronous updating method, which comprises:
[0007] reading the latest content of the configuration files of the configuration center servers in multiple environments line by line;
[0008] storing the latest content of each configuration file in a key-value format into a hashmap data structure corresponding to the configuration file for de-duplication processing;
[0009] storing each row of key values in the hashmap data structure after de-duplication into a treeset data structure corresponding to the configuration file for reordering in alphabetical order;
[0010] respectively taking the reordered treeset data structure content of each configuration file as a benchmark, and alternately comparing whether the key values are consistent, if the key values are inconsistent, keeping the key values consistent, and then taking the hashmap data structure content as a benchmark, and alternately comparing whether the value values are consistent;
[0011] The difference content found by comparison is returned to the client after modification, and is written into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the multi-environment configuration center server.
[0012] In one embodiment, the comparison of the key values includes: taking the treeset data structure of one of the configuration files as a reference, reading the key values in the treeset data structure using a for loop, using the key values to determine whether the corresponding key values exist in the hashmap data structures of the other configuration files, if they exist, comparing the value values; if they do not exist, writing the line number of the key value into a first array, and inserting the key value into the corresponding positions of the hashmap data structures and the treeset data structures of the other configuration files that do not have the key value, and setting the corresponding value value in the hashmap data structure to not_exist.
[0013] In one embodiment, the comparison of the value values includes: taking the hashmap data structure of one of the configuration files as a reference, reading the value values in the hashmap data structure using a for loop, using the value values to determine whether the corresponding value values exist in the hashmap data structures of the other configuration files, if they exist, ending the comparison; if they do not exist, writing the line number of the value value into a second array, and inserting not_exist into the corresponding positions of the hashmap data structures of the other configuration files that do not have the value value.
[0014] In one embodiment, the line numbers of the inconsistent key values are written into the first array in ascending order, and the line numbers of the inconsistent value values are written into the second array in ascending order.
[0015] In one embodiment, the returning of the difference content found by comparison to the client includes: returning the first array, the second array, and the latest key-value format content in the hashmap data structure of each configuration file to the client.
[0016] In one embodiment, the writing into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the multi-environment configuration center server includes: after the client highlights the difference content according to the first array and the second array, receiving the key-value format content modified by the user according to the highlighting, and writing it into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the multi-environment configuration center server.
[0017] In one embodiment, after receiving the key-value format content modified by the user according to the highlight display, the related information of each configuration file saved locally is updated synchronously.
[0018] In one embodiment, before reading the latest content of the configuration file of the multi-environment configuration center server line by line, the configuration file synchronous updating method further comprises: saving the related information of each configuration file of the configuration center server of each environment into a local database.
[0019] In one embodiment, the related information comprises the configuration file server ID, account information and configuration file name.
[0020] In one embodiment, based on the related information, the latest content of the configuration file of the multi-environment configuration center server is read through an http protocol request.
[0021] In one embodiment, before reading the latest content of the configuration file of the multi-environment configuration center server through an http protocol request, the configuration file synchronous updating method further comprises: checking whether the suffix of each configuration file name is consistent, if not, exiting the reading; if consistent, reading the latest content of the configuration file of the multi-environment configuration center server through an http protocol request.
[0022] The embodiment of the present application also provides a configuration file synchronous updating device, comprising:
[0023] A reading module for reading the latest content of the configuration file of the multi-environment configuration center server line by line;
[0024] A deduplication module for storing the latest content of each configuration file in a hashmap data structure corresponding to the configuration file in a key-value format for deduplication processing;
[0025] A reordering module for storing each row of key values in the hashmap data structure after deduplication in a treeset data structure corresponding to the configuration file for reordering in alphabetical order;
[0026] A comparison module for comparing whether the key values are consistent in turn based on the content of the treeset data structure after reordering of each configuration file, if the key values are not consistent, keeping the key values consistent, and then comparing whether the value values are consistent in turn based on the content of the hashmap data structure;
[0027] The synchronous updating module is configured to return the difference content found by comparison to the client for modification, and write the modified content into the corresponding configuration file of the configuration center server to realize the synchronous updating of the configuration file of the configuration center server in multiple environments.
[0028] The embodiment of the present application further provides a computer device, including a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor realizes the configuration file synchronous updating method when executing the computer program.
[0029] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program realizes the configuration file synchronous updating method when executed by a processor.
[0030] The embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program realizes the configuration file synchronous updating method when executed by a processor.
[0031] The embodiment of the present application provides a configuration file synchronous updating method and device, in order to solve the problem that the same configuration items in different environments are inconsistent due to different filling sequences of a same configuration in the configuration file of the configuration center server in multiple environments, the present application reorders when comparing the configuration files, and is not dependent on the sequence of the original configuration items, which is more friendly to the configuration personnel and improves the configuration efficiency. In addition, the present application also supports modifying the difference content in the comparison page and synchronously updating the configuration file on the corresponding configuration center server, which reduces the error rate caused by different configuration file contents and improves the work efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings. In the drawings:
[0033] Figure 1 It is a configuration file synchronous updating method flowchart in the embodiment of the present application;
[0034] Figure 2 It is an application deployment architecture diagram in the embodiment of the present application;
[0035] Figure 3 It is a synchronous configuration structure diagram in the embodiment of the present application;
[0036] Figure 4 A configuration file comparison process schematic diagram for an embodiment of the present application;
[0037] Figure 5 A configuration file synchronization updating device structure schematic diagram is provided for an embodiment of the present application.
[0038] Figure 6 A computer device entity structure schematic diagram is provided for an embodiment of the present application. DETAILED DESCRIPTION
[0039] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer and more apparent, the embodiments of the present application are further described in detail below with reference to the drawings. Herein, the illustrative embodiments of the present application and the descriptions thereof are used to explain the present application, but are not as a limitation of the present application.
[0040] In the technical scheme of the present application, the information collected is authorized by the user or authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant standards, necessary security measures are taken, do not violate public order and good customs, and provide corresponding operation portal for user to choose authorization or refusal.
[0041] In the technical scheme of the present application, the acquisition, transmission, storage, use and processing of data comply with relevant regulations.
[0042] It should be noted that in the embodiments of the present application, some software, components, models and other industry existing schemes may be mentioned, which should be considered as exemplary, and the purpose is only to illustrate the feasibility of the implementation of the technical scheme of the present application, but does not mean that the applicant has or will necessarily use the scheme.
[0043] If the same configuration item and the content filling positions of the plurality of configuration files of the configuration center server are different, it will lead to inconsistent content, which needs to adjust the configuration order again. The UI interface of the existing configuration center service only supports comparison of two files on the same set of services, and in the process of synchronizing configuration files in multiple environments, it will bring more workload, which greatly reduces the configuration efficiency.
[0044] As shown in Figure 1 To solve the technical problem, the embodiment of the present application provides a configuration file synchronization updating method, which comprises:
[0045] S11, read the latest content of the configuration file of the configuration center server of the multiple environments line by line.
[0046] Specifically, the application can overcome the problem that the existing configuration center server does not support comparison and modification of the configuration files of the multi-environment configuration center server by developing an independent third-party widget to read the latest content of the configuration files of the multi-environment configuration center server line by line, thereby improving the configuration file synchronization updating efficiency.
[0047] In one embodiment, before reading the latest content of the configuration files of the multi-environment configuration center server line by line, the configuration file synchronization updating method further comprises saving the related information of the configuration files of the configuration center servers of the respective environments into a local database.
[0048] As shown in Figure 2 Specifically, a user can first input the related information of the configuration files of the configuration center servers of the respective environments into a client, send the information to a server using an http request, and store the related information of the configuration files of the configuration center servers of the respective environments into a local database. This step solves the technical problem of how to initialize the local configuration center configuration information. This step achieves the technical effect of enabling the selection of configuration files for synchronization updating according to needs, thereby improving the work efficiency. In particular, a specific environment and a specific configuration file can be selected according to needs.
[0049] In one embodiment, the related information comprises a configuration file server ID, account information, and a configuration file name.
[0050] As shown in Figure 3 Specifically, the application further provides a synchronization configuration function. After the related information of the configuration files of the configuration center servers of the respective environments is input into a client, the names of all the configuration files of the configuration center server are specifically synchronized to the server of the application, and the server of the application stores the configuration file names and the corresponding configuration center server IDs and account information into a local database. This step solves the technical problem of how to reduce the memory space occupied by the local database while improving the security of data transmission. This step achieves the technical effect of reducing the requirements for the operating environment. The application first saves the related information of the configuration center of the respective environments, such as the service address of the configuration center, account and password, into a local database for subsequent configuration file content synchronization updating.
[0051] In one embodiment, the application further provides a page dedicated to adding, deleting, or modifying the related information of the configuration center in the local.
[0052] In one embodiment, based on the related information, the latest content of the configuration files of the multi-environment configuration center server is read through an http protocol request.
[0053] Specifically, the application configures the center server ID, account information and configuration file name, and uses the http protocol to request to read the latest content of the configuration file of the multi-environment configuration center server. The technical problem solved by this step is how to read the latest content of the configuration file of the multi-environment configuration center server. The technical effect realized by this step is that the http protocol can be used to read the latest content of the configuration file of the multi-environment configuration center server more simply and quickly.
[0054] In one embodiment, before the latest content of the configuration file of the multi-environment configuration center server is requested to be read through the http protocol, the configuration file synchronization updating method further comprises: checking whether the suffixes of each configuration file name are consistent, if not, exiting reading; if consistent, requesting to read the latest content of the configuration file of the multi-environment configuration center server through the http protocol.
[0055] Specifically, in the case of consistent file format, the accuracy of the comparison result can be ensured.
[0056] S12, store the latest content of each configuration file in the hashmap data structure corresponding to the configuration file respectively in the key-value format for de-duplication processing.
[0057] Specifically, HashMap is a key-value storage structure data structure, which is used to store and manage data. It provides fast data access and search capability. HashMap stores key-value pairs key-value in the internal array by calculating the hash value of the key. Through the hash value of the key, the position in the array can be quickly located, so that the data can be quickly accessed and operated. The application stores the latest content of each configuration file in the hashmap data structure corresponding to the configuration file respectively in the key-value format for de-duplication processing, which reduces the subsequent comparison difficulty and improves the comparison efficiency and accuracy. The principle of HashMap de-duplication is to use the characteristics of HashMap, that is, not to allow duplicate keys. When a set needs to be de-duplicated, the elements in the set can be stored in HashMap as keys. Since HashMap does not allow duplicate keys, duplicate elements will be automatically removed.
[0058] S13, store each row of key values in the hashmap data structure after de-duplication into the treeset data structure corresponding to the configuration file for reordering in alphabetical order.
[0059] Specifically, the application stores the latest content of each configuration file in a preset format (such as key-value) into a hashmap data structure (such as hashmap) corresponding to the configuration file respectively for deduplication, and then stores each row key (such as key) in the hashmap data structure into a corresponding treeset data structure (such as treeset) for reordering, and compares the reordered content. When comparing the configuration files, the application reorders the latest content of the configuration files after deduplication in alphabetical order, and does not depend on the original order, which improves the accuracy of the comparison result. By reordering the latest content of each configuration file in the treeset data structure in alphabetical order, the application compares the rows one by one, which solves the technical problem of how to reorder the latest content of each configuration file and compare it. The technical effect achieved by this step is that the treeset data structure can realize efficient insertion, deletion and search operations, and the use of the treeset data structure can improve the comparison efficiency. The treeset data structure is an ordered collection based on red-black tree in Java, and the elements in the treeset data structure are sorted in natural order or through a provided custom order to ensure that the elements are in sorted state.
[0060] In one embodiment, when the client selects the configuration files of the configuration center server in different environments for comparison, the client sends an http request to the server, the server reads the request address and account information of the corresponding configuration center from the local database through the configuration file and configuration center information requested by the client, and then uses the http request to read the latest content of the configuration file from the corresponding configuration center server and returns it to the server. After reading the latest content of the configuration file to the server, the configuration file is reordered first, and then compared after the sorting is completed, the number of different lines is recorded, and the sorted configuration file content and the number of different lines are returned to the client for highlighting. This can help users quickly find the difference content and make modifications, improving work efficiency.
[0061] S14, respectively, take the reordered treeset data structure content of each configuration file as the benchmark, and compare whether the key values are consistent in turn, and then take the hashmap data structure content as the benchmark, and compare whether the value values are consistent in turn.
[0062] Specifically, the content in the treeset data structure is arranged in order, and first, the content of the treeset data structure reordered according to each configuration file is taken as a reference, and whether the key values are consistent is compared in turn, so that inconsistent key values can be quickly found. Because only key values are stored in the treeset data structure, when the value values are compared, the content of the hashmap data structure is taken as a reference to compare in turn. Comparing in turn based on the content reordered according to each configuration file can find all the different content and avoid omission, thereby improving the comparison accuracy.
[0063] In one embodiment, the comparison of whether the key values are consistent includes: taking the treeset data structure of one of the configuration files as a reference, reading the key values in the treeset data structure using a for loop, using the key values to determine whether the hashmap data structure of other configuration files has corresponding key values, if so, comparing the value values; if not, writing the line number of the key value into a first array, and inserting the key value in the corresponding position of the hashmap data structure and the treeset data structure of other configuration files that do not have the key value, and setting the corresponding value value in the hashmap data structure to not_exist. In this way, the comparison is performed according to the above comparison logic based on the treeset data structure corresponding to the configuration file of other environments.
[0064] In one embodiment, the comparison of whether the value values are consistent includes: taking the hashmap data structure of one of the configuration files as a reference, reading the value values in the hashmap data structure using a for loop, using the value values to determine whether the hashmap data structure of other configuration files has corresponding value values, if so, the comparison ends; if not, writing the line number of the value value into a second array, and inserting not_exist in the corresponding position of the hashmap data structure of other configuration files that do not have the value value. In this way, the comparison is performed according to the above comparison logic based on the hashmap data structure corresponding to the configuration file of other environments.
[0065] In one embodiment, the line numbers of inconsistent key values are written into the first array in ascending order, and the line numbers of inconsistent value values are written into the second array in ascending order.
[0066] Specifically, the client can view the reordered configuration file content from the server, and the client provides a quick search button to search for the line where the difference content is located. Through the foregoing comparison process, all difference line numbers are stored in the first array nums and the second array nums_value. The search function actually reads the difference line number returned from the server, and through the difference line number, the difference line can be directly jumped to and highlighted. The difference line number is written in the array in ascending order, and the cursor can also be automatically jumped to different difference positions in ascending order according to the line number, facilitating the user to check the difference content.
[0067] S15, returning the difference content found by comparison to the client for modification, and writing the modified content into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the configuration center server in multiple environments.
[0068] Specifically, the server of the present application returns the difference content found by the foregoing comparison to the client, and the user can modify the difference content on the client interface. Because the configuration file may have differences (for example, the database address of the production environment is different from that of the test environment), the user needs to identify whether the difference content needs to be modified. If the difference content needs to be modified, the user can manually modify it. The present application can also set automatic modification, that is, taking one of the configuration files as a reference, the difference content of the other configuration files is copied and modified.
[0069] In one embodiment, the returning of the difference content found by comparison to the client includes returning the first array, the second array, and the latest key-value format content in the hashmap data structure of each configuration file to the client.
[0070] Specifically, after the comparison is completed, the server returns the first array, the second array, and the latest key-value format content in the hashmap data structure of each configuration file to the client.
[0071] In one embodiment, the writing into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the configuration center server in multiple environments includes, after the client highlights the difference content according to the first array and the second array, receiving the key-value format content of the difference content modified by the user according to the highlight, and writing the key-value format content into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the configuration center server in multiple environments.
[0072] Specifically, the client of the present application highlights the difference content according to the first array and the second array, and then the user modifies the key-value format content after highlighting the difference content, and writes the modified key-value format content into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the multi-environment configuration center server.
[0073] In one embodiment, after receiving the key-value format content modified by the user according to the highlighting, the related information of each configuration file saved locally is synchronized and updated.
[0074] Specifically, the present application synchronously updates and saves the modified key-value format content in the local database, at this time the client sends an http request to save the configuration file to the server, and the server receives the request, reads the address and account information of the corresponding configuration center from the local database according to the configuration center information requested by the client, and then uses the http request to update the configuration file content to the configuration center server according to the address and account information of the configuration center, and returns the update success prompt to the client after the update is successful. After the configuration file content is successfully updated, the client can re-initiate the configuration file comparison as needed.
[0075] The present application reads out the latest content of the configuration file of the multi-environment configuration center server, reorders and compares it, writes the modified content of the difference content found in the comparison into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the multi-environment configuration center server. The prior art can only provide content comparison and cannot modify inconsistent content, and further modification operation needs to be performed in the configuration modification page, and the whole process is not coherent. The present application not only realizes the comparison of multiple configuration files in multiple environments, but also supports direct modification in the comparison page, simplifies the operation process, and improves the synchronization update efficiency.
[0076] In one embodiment, the configuration file of the present application is in propertis format.
[0077] As shown in Figure 4 In one embodiment, the specific comparison process is as follows:
[0078] S21, select the configuration files to be compared.
[0079] Specifically, the specific configuration files of each environment configuration center saved in the client interface are selected for comparison, such as config.properties of test environment A service and config.properties of production environment.
[0080] S22, acquire the latest content of the configuration file of the corresponding configuration center server.
[0081] Specifically, the server will acquire the latest content of the configuration file from the corresponding environment configuration center server. In this stage, the consistency of the configuration file suffix will be verified first. The application supports comparison of files with the same format. Specifically, if the user needs to compare the content difference of the file named config.properties in the test environment and the production environment, the user will select the test environment and the production environment configuration file on the client, and then initiate the comparison. This time, the client will initiate an http request to the server and send the ids of the two configuration files and the corresponding configuration center server name to the server. The server will read the test environment configuration center server address and account password from the local database according to the test environment configuration center server name, initiate an http request to the corresponding configuration center server, and return the latest content of the configuration file to the server according to the request. Similarly, the latest content of the configuration file of the config.properties of the production environment configuration center server is also read to the server.
[0082] S23, reorder the latest content of the configuration file.
[0083] Specifically, the latest content of the two configuration files is read line by line, and the latest content is stored in two hashmap data structures in key-value format for deduplication processing, and then the key values of the two hashmap are stored in two treeset data structures for reordering. Taking the properties file format as an example, the format of each line is key-value format, such as username = jack. The server will divide the content into two parts according to the '=' sign, one is username, indicating key, and the other is jack, indicating value. Then a hashmap data structure (which can deduplicate and supports key-value format storage) is used to set username as key and jack as value, and save it to hashmap. After all the content is processed, the key values of hashmap are stored in treeset for reordering. Treeset can guarantee that the content is ordered and not repeated. When using treeset to save content, the content will be automatically sorted, such as key cba, acc, abc, acb, username. Then it will be automatically sorted as abc, acb, acc, cba, username.
[0084] S24, comparing the reordered content.
[0085] Specifically, the sorted content is taken as the benchmark of the test environment configuration file treeset data structure, and a for loop is used to read each line of key values (this key value is the username in the username = jack in the corresponding configuration file, that is, the content to the left of the '=' in the properties format configuration file). The key is used to determine whether the production environment configuration file hashmap data structure has a corresponding key. If the key does not exist, insert the key into the non-existent hashmap and set a value as not_exist. The production environment treeset also inserts the key, so as to ensure that the treeset data amount of the configuration files of different environments is consistent and prevent the order from being disordered. At the same time, if the key does not exist, record the line in a difference array nums, and if the key exists, compare the values to see if they are consistent. If they are not consistent, record them in a difference array nums_value. Specifically, an array is used to record which lines have key differences. For example, the difference array nums = [3, 4, 7, 20] indicates that the 3rd, 4th, 7th, and 20th lines have differences. An array is used to record which lines have value differences. For example, if the test environment configuration is username = Jack and the production environment configuration is username = May, then this line has value differences. For example, the array nums_value = [4, 6, 9] indicates that the 4th, 6th, and 9th lines have value differences. After the benchmarking of the test environment is completed, the production environment configuration file treeset data structure is taken as the benchmark, and the above comparison process is continued. This process mainly checks the configuration items that exist in the production environment configuration but do not exist in the test environment configuration.
[0086] S25, generating a comparison result and returning it to the client for rendering.
[0087] In one embodiment, after the comparison is completed, the server reads each line of key values of the treeset data structure of each configuration file, and then reads each line of value values of the corresponding hashmap data structure according to the key values, to form a new configuration file content and return it to the client.
[0088] Specifically, based on the contents of the two treeset data structures described above, the server reuses the for loop to read each key, and then reads the corresponding value from the hashmap of the corresponding environment, and then assembles the key-value contents, such as the existence of the username key in the treeset data structure, and then uses the username to obtain the hashmap corresponding value as Jack, and then assembles username = Jack, if the obtained value is not_exist, indicating that this line is originally empty, then assemble an empty line, finally return the string to the front end, save the difference line number to the difference array nums, and return nums_value to the client, the client renders and highlights the modified string content.
[0089] Comparing the configuration files of the two environments respectively as the benchmark can find all the difference items of the two different configuration files. For example, the configuration file of the production environment has only 9 lines, and the configuration file of the test environment has 10 lines. At this time, taking the configuration file of the production environment as the benchmark, the line that is added in the configuration file of the test environment is highlighted, and the other difference lines are generally marked. Taking the configuration file of the test environment as the benchmark, the difference lines are generally marked. At this time, the worker can confirm whether to delete or add the highlighted test environment configuration file to the corresponding position of the production environment configuration file according to the different marking contents.
[0090] In addition, the client also provides a difference button for quickly jumping to the difference content, and provides two comparison modes, one is the key difference comparison, and the other is the value difference comparison. For example, for key value difference comparison, according to the line number in nums, jump to the corresponding line, and highlight the empty line. If the value difference comparison is used, according to the line number in nums_value, jump to the corresponding line, and compare the two values, and then highlight the difference content.
[0091] In one embodiment, when the difference button is continuously clicked, the current position is continuously compared with nums or nums_value, and when there is a difference number greater than the current line number, it indicates that there is inconsistent content, and the cursor jumps to the line and highlights the content of the line or the difference. For example, nums [1, 2, 10, 20], currently in the 10th line, click the difference button, and query whether there is a number greater than 10 in the array, such as 20 in the array, then the cursor jumps to the 20th line. If the current cursor is in the 20th line, query whether there is a number greater than 20 in the array, if not, do not jump, and prompt the user that it has reached the bottom.
[0092] The prior art solution compares the configuration file contents when the configuration file contents are multiple, and can only view line by line whether there is highlighted different content, and cannot quickly locate the different content; the application provides a quick positioning button, which can be clicked to locate the specific different content position, greatly improving the speed of the staff in finding the different configuration file contents in different environments and improving the work efficiency.
[0093] In one embodiment, taking the comparison of three configuration files of the configuration center server in three different environments as an example, the application mainly includes the following steps:
[0094] Step 1, selecting the compared configuration files.
[0095] Specifically, the three configuration files of the configuration center in the development environment, the acceptance environment and the production environment are selected on the client. The server checks whether the suffixes of the selected three configuration files are consistent, if yes, the file comparison process is entered; otherwise, an error is prompted, and the user can reselect the configuration files on the client for comparison or can enter the synchronization configuration page to modify the configuration file information.
[0096] Step 2, obtaining the latest content of the configuration files of the corresponding configuration center server.
[0097] Specifically, entering the file comparison process, the client initiates an http request to the server and sends the ids of the three configuration files and the corresponding configuration center server names to the server. The server reads the test environment configuration center server address and account password from the local database according to the test environment configuration center server name, initiates an http request to the corresponding configuration center server, and the test environment configuration center server returns the latest content of the configuration file to the server according to the corresponding configuration file name of the request. Similarly, the latest content of the configuration files of the configuration center servers of the production environment and the development environment is also read to the server.
[0098] Step 3, reordering the latest content of the configuration files.
[0099] Specifically, the latest content of the three configuration files is read line by line, and the latest content is first stored in three hashmap data structures in key-value format for de-duplication processing, and then the key values of the three hashmap are stored in three treeset data structures for reordering. The obtained file content is first stored in the hashmap data structure for de-duplication, and then the treeset data structure is used for reordering.
[0100] For example, the content of the configuration file config.properties of the test environment is Jack=18, Aben=19, Alis=18, username=jack; the content of the configuration file config.properties of the pre-release environment is Jack=19, Aben=19, Alis=18, username=jack, driod=false; and the content of the configuration file config.properties of the production environment is Jack=18, Aben=19, Alis=19, umash=022.
[0101] The content of the test environment treeset after the treeset and hashmap processing is [Aben, Alis, Jack, username], and the content of the hashmap is {username=jack, jack=18, Alis=18, Aben=19}.
[0102] The content of the pre-release environment treeset is [Aben, Alis, driod, Jack, username], and the content of the hashmap is {username=jack, jack=19, Alis=18, Aben=19, driod=false}.
[0103] The content of the production environment treeset is [Aben, Alis, Jack, umash], and the content of the hashmap is {jack=18, Alis=19, Aben=19, umash=022}.
[0104] Step 4, comparison is made on the reordered content.
[0105] Specifically, the sorted content is used as the benchmark of the test environment's configuration file treeset data structure, and each key is read using a for loop (this key is the username in the username = jack in the corresponding configuration file, that is, the content to the left of '=' in the properties format configuration file). The key is used to determine whether the production environment's configuration file treeset data structure has a corresponding key. If the key does not exist, insert the key into the non-existent hashmap and set a value, which is not_exist. The production environment's treeset also inserts this key, which ensures that the treeset data volume of different environment configuration files is consistent and prevents sequence disorder. At this time, the production configuration file's treeset becomes [Aben, Alis, Jack, umash, username], the production configuration file's hashmap becomes {jack = 18, Alis = 19, Aben = 19, username = not_exist, umash = 022}, the test environment's treeset remains unchanged [Aben, Alis, Jack, username], and the test environment's hashmap remains unchanged {username = jack, jack = 18, Alis = 18, Aben = 19}. After the benchmarking of the test environment is completed, the production configuration file treeset data structure is used as the benchmark to continue the above comparison process. This process mainly checks the configuration items that exist in the production environment configuration, but do not exist in the test environment configuration. According to the above example, the umash difference configuration item needs to be inserted into the test environment's treeset. At this time, the test environment's treeset becomes [Aben, Alis, Jack, umash, username], the test environment's hashmap becomes {username = jack, jack = 18, Alis = 18, Aben = 19, umash = not_exist}, the production configuration file's treeset remains unchanged [Aben, Alis, Jack, umash, username], and the production configuration file's hashmap remains unchanged {jack = 18, Alis = 19, Aben = 19, username = not_exist, umash = 022}; At this time, the configuration verification of the test environment and the production environment is completed. Continue to use the test environment as the benchmark and compare it with the pre-release environment. The test environment treeset is: [Aben, Alis, Jack, umash, username], and the pre-release environment treeset is [Aben, Alis, driod, Jack, username].If the umash configuration item is not found in the pre-release environment, the configuration item is inserted into the treeset of the pre-release environment. At this time, the treeset is [Aben, Alis, driod, Jack, umash, username], and the content of the hashmap is {username=jack, jack=19, Alis=18, Aben=19, driod=false, umash=not exist}. After the loop is completed, the pre-release environment is taken as a benchmark, and the test environment is compared. The content of the loop of the treeset of the pre-release environment is [Aben, Alis, driod, Jack, umash, username], and the content of the test environment treeset is [Aben, Alis, Jack, umash, username]. It is found that the test environment does not have the driod configuration, and the configuration item is inserted into the treeset and hashmap of the test environment. At this time, the content of the treeset is [Aben, Alis, driod, Jack, umash, username], and the content of the hashmap is {username=jack, driod=not exist, jack=18, Alis=18, Aben=19, umash=not exist}. The production environment also needs to insert the driod configuration. Because the production environment has been verified with the test environment before, any new insertion operation of the test environment also needs to be inserted into the production environment. At this time, the content of the configuration treeset of the production environment is [Aben, Alis, driod, Jack, umash, username], and the content of the hashmap is {username=not exist, driod=not exist, jack=18, Alis=18, Aben=19, umash=022}.
[0106] After the above, the verification of the three configuration files is completed, and the final configuration content of the three environments is as follows:
[0107] The treeset of the test environment is [Aben, Alis, driod, Jack, umash, username];
[0108] The treeset of the pre-release environment is [Aben, Alis, driod, Jack, umash, username];
[0109] The treeset of the production environment is [Aben, Alis, driod, Jack, umash, username];
[0110] Test environment hashmap: {username = jack, jack = 18, Alis = 18, Aben = 19, driod = not_exist, umash = not_exist};
[0111] Pre-release environment hashmap: {username = jack, jack = 19, Alis = 18, Aben = 19, driod = false, umash = not_exist};
[0112] Production environment hashmap: {username = not_exist, jack = 18, Alis = 18, Aben = 19, driod = not_exist, umash = 022}.
[0113] Step 5, generate comparison results and return to the client for rendering.
[0114] Specifically, based on the content of the above three treeset data structures, the server reuses the for loop to read each key, then reads the corresponding value from the hashmap of the corresponding environment, and then assembles the key-value content, such as the existence of the username key in the treeset data structure, then use this username to get the value of Jack from the hashmap, then assemble username = Jack, if the value obtained is not_exist, indicating that this line is originally empty, then assemble an empty line, finally return the string to the front end, save the difference line number to the difference array nums, and return nums_value to the client, the client renders the modified string content and highlights it.
[0115] After the key configuration item is checked, the order of the treeset of the test environment, the pre-release environment and the production environment is consistent, and after ensuring that the key order and quantity of the three environments are consistent, the content difference is compared, and the configuration file treeset data structure of the test environment is taken as a benchmark, each key is read by using a for loop, and then the hashmap value of the test environment, the pre-release environment and the production environment corresponding to the key is read. For example, in the above example, the first row reads Aben, the value of the hashmap of the test environment is 19, the values of the hashmap of the pre-release environment and the production environment are also 19, the hashmap values of the three environments are the same, and the next one is compared. When Alis is compared, the value of the hashmap of the test environment is 18, the value of the hashmap of the pre-release environment is 18, and the value of the hashmap of the production environment is 19. The difference array nums_value is recorded as [2], indicating that the second row has a value difference. When driod is compared in the third row, it is found that the values of the test environment and the production environment are not_exist, and the difference array nums is recorded as [3], and the difference array nums_value is recorded as [2, 3]. When Jack is compared in the fourth row, there is also a difference, and the nums_value is recorded as [2, 3, 4]. When username and umash are compared, it is found that there is also a difference, and the final value is recorded as nums=[3, 5, 6] and nums_value=[2, 3, 4, 5, 6].
[0116] As Figure 5 shown, the embodiment of the application also provides a configuration file synchronization updating device, which comprises a reading module 31, a deduplication module 32, a reordering module 33, a comparison module 34 and a synchronization updating module 35.
[0117] The reading module 31 is used for reading the latest content of the configuration file of the configuration center server of the multiple environments line by line.
[0118] Specifically, the application can overcome the problem that the existing configuration center server does not support the comparison and modification of the configuration file of the configuration center server of the multiple environments by developing an independent third-party tool to read the latest content of the configuration file of the configuration center server of the multiple environments, and the configuration file synchronization updating efficiency is improved.
[0119] In one embodiment, before the latest content of the configuration file of the configuration center server of the multiple environments is read line by line, the configuration file synchronization updating method further comprises saving the related information of each configuration file of the configuration center server of each environment into a local database.
[0120] Specifically, the user can first enter the relevant information of each configuration file of the configuration center server of each environment on the client, and send the information to the server using an http request. The server stores the relevant information of each configuration file of the configuration center server of each environment in the local database. This step solves the technical problem of how to initialize the local configuration center configuration information. This step achieves the technical effect of allowing the configuration file to be selected for synchronization update as needed, thereby improving work efficiency. In particular, a specific environment and a specific configuration file can also be selected as needed.
[0121] In one embodiment, the relevant information includes the configuration center server ID where the configuration file is located, account information, and the configuration file name.
[0122] Specifically, the application also provides a synchronization configuration function. After the relevant information of each configuration file of the configuration center server of each environment is entered on the client, the configuration center server all configuration file names are specifically synchronized to the server of the application. Meanwhile, the server of the application stores the configuration file name and the corresponding configuration center server ID and account information in the local database. This step solves the technical problem of how to reduce the memory space occupied by the local database while improving the security of data transmission. This step achieves the technical effect of reducing the requirements for the operating environment. The application first saves the relevant information of the configuration center of each environment, such as the service address of the configuration center, the account password, etc., in the local database for subsequent configuration file content synchronization update.
[0123] In one embodiment, the application also provides a page dedicated to adding, deleting, or modifying the relevant information of the configuration center in the local.
[0124] In one embodiment, based on the relevant information, the latest content of the configuration file of the configuration center server of multiple environments is read through an http protocol request.
[0125] Specifically, the application reads the latest content of the configuration file of the configuration center server of multiple environments through an http protocol request based on the configuration center server ID, the account information, and the configuration file name. This step solves the technical problem of how to read the latest content of the configuration file of the configuration center server of multiple environments. This step achieves the technical effect of allowing the latest content of the configuration file of the configuration center server of multiple environments to be read more simply and quickly through an http protocol.
[0126] In one embodiment, before requesting to read the latest content of the configuration file of the multi-environment configuration center server through the http protocol, the configuration file synchronization updating method further comprises: checking whether the suffixes of each configuration file name are consistent, if not, exiting the reading; if consistent, requesting to read the latest content of the configuration file of the multi-environment configuration center server through the http protocol.
[0127] Specifically, in the case of consistent file format, the accuracy of the comparison result can be ensured.
[0128] The deduplication module 32 is configured to store the latest content of each configuration file in a key-value format into the hashmap data structure corresponding to the configuration file respectively for deduplication processing.
[0129] Specifically, HashMap is a key-value storage structure data structure, which is used to store and manage data. It provides fast data access and lookup capabilities. HashMap stores key-value pairs key-value in the internal array by calculating the hash value of the key. Through the hash value of the key, the position in the array can be quickly located, so that the data can be quickly accessed and operated. The application stores the latest content of each configuration file in a key-value format into the hashmap data structure corresponding to the configuration file respectively for deduplication processing, which reduces the subsequent comparison difficulty and improves the comparison efficiency and accuracy. The principle of HashMap deduplication is to use the characteristics of HashMap, that is, it does not allow duplicate keys. When a set needs to be deduplicated, the elements in the set can be stored in HashMap as keys. Since HashMap does not allow duplicate keys, duplicate elements will be automatically removed.
[0130] The reordering module 33 is configured to store each row of key values in the deduplicated hashmap data structure into the treeset data structure corresponding to the configuration file for reordering in alphabetical order.
[0131] Specifically, the application stores the latest content of each configuration file in a preset format (such as key-value) into a hashmap data structure (such as hashmap) corresponding to the configuration file respectively for deduplication, and then stores each row key (such as key) in the hashmap data structure into a corresponding treeset data structure (such as treeset) for reordering, and compares the reordered content. When comparing the configuration files, the application reorders the latest content of the configuration files after deduplication in alphabetical order, without relying on the original order, which improves the accuracy of the comparison result. By reordering the latest content of each configuration file in the treeset data structure in alphabetical order, the application compares the rows one by one, which solves the technical problem of how to reorder the latest content of each configuration file and compare it. The technical effect achieved by this step is that the treeset data structure can realize efficient insertion, deletion and search operations, and the use of the treeset data structure can improve the comparison efficiency. The treeset data structure is an ordered collection based on red-black tree in Java, and the elements in the treeset data structure are sorted in natural order or through a provided custom order, ensuring that the elements are in sorted state.
[0132] In one embodiment, when the client selects the configuration files of the configuration center server in different environments for comparison, the client sends an http request to the server, the server reads the request address and account information of the corresponding configuration center from the local database through the configuration file and configuration center information requested by the client, and then uses the http request to read the latest content of the configuration file from the corresponding configuration center server and returns it to the server. After reading the latest content of the configuration file to the server, the configuration file is reordered first, and then compared after the sorting is completed, the number of different lines is recorded, and the sorted configuration file content and the number of different lines are returned to the client for highlighting. This can help users quickly find the difference content and make modifications, improving work efficiency.
[0133] The comparison module 34 is used to compare whether the key values are consistent in turn based on the reordered treeset data structure content of each configuration file, and then compare whether the value values are consistent in turn based on the hashmap data structure content.
[0134] Specifically, the content in the treeset data structure is arranged in order, and first, the content of the treeset data structure reordered according to each configuration file is taken as a reference, and whether the key values are consistent is compared in turn, so that inconsistent key values can be quickly found. Because only key values are stored in the treeset data structure, when the value values are compared, the content of the hashmap data structure is taken as a reference to compare in turn. Comparing in turn based on the content reordered according to each configuration file can find all the different content and avoid omission, thereby improving the comparison accuracy.
[0135] In one embodiment, the comparison of whether the key values are consistent includes: taking the treeset data structure of one of the configuration files as a reference, reading the key values in the treeset data structure using a for loop, using the key values to determine whether the hashmap data structure of other configuration files has corresponding key values, if so, comparing the value values; if not, writing the line number of the key value into a first array, and inserting the key value in the corresponding position of the hashmap data structure and the treeset data structure of other configuration files that do not have the key value, and setting the corresponding value value in the hashmap data structure to not_exist. In this way, the comparison is performed according to the above comparison logic based on the treeset data structure corresponding to the configuration file of other environments.
[0136] In one embodiment, the comparison of whether the value values are consistent includes: taking the hashmap data structure of one of the configuration files as a reference, reading the value values in the hashmap data structure using a for loop, using the value values to determine whether the hashmap data structure of other configuration files has corresponding value values, if so, the comparison ends; if not, writing the line number of the value value into a second array, and inserting not_exist in the corresponding position of the hashmap data structure of other configuration files that do not have the value value. In this way, the comparison is performed according to the above comparison logic based on the hashmap data structure corresponding to the configuration file of other environments.
[0137] In one embodiment, the line numbers of inconsistent key values are written into the first array in ascending order, and the line numbers of inconsistent value values are written into the second array in ascending order.
[0138] Specifically, the application can enable the client to view the reordered configuration file content on the server side, and the client can provide a quick search button to search for the line where the difference content is located. Through the aforementioned comparison process, all difference line numbers are stored in the first array nums and the second array nums_value. The search function actually reads the difference line number returned from the server side, and through the difference line number, the difference line can be directly jumped to and highlighted. The difference line number is written in the array in ascending order, and the cursor can also be automatically jumped to different difference positions in ascending order according to the line number, which facilitates the user to check the difference content.
[0139] The synchronization updating module 35 is configured to return the difference content found by comparison to the client for modification, and write the modified content into the corresponding configuration center server configuration file to realize the synchronization updating of the configuration file of the configuration center server in multiple environments.
[0140] Specifically, the server of the application returns the difference content found by comparison to the client, and the user can modify the difference content on the client interface. Because the configuration file may have differences (for example, the database address of the production environment is different from that of the test environment), the user needs to identify whether the difference content needs to be modified. If the difference content needs to be modified, the user can manually modify it. The application can also set automatic modification, that is, taking one of the configuration files as a reference, the difference content of other configuration files is copied and modified.
[0141] In one embodiment, the returning of the difference content found by comparison to the client includes returning the first array, the second array, and the latest key-value format content in the hashmap data structure of each configuration file to the client.
[0142] Specifically, after the comparison is completed, the server returns the first array, the second array, and the latest key-value format content in the hashmap data structure of each configuration file to the client.
[0143] In one embodiment, the writing of the difference content into the corresponding configuration center server configuration file to realize the synchronization updating of the configuration file of the configuration center server in multiple environments includes: after the client highlights the difference content according to the first array and the second array, receiving the key-value format content of the difference content modified by the user according to the highlight, and writing the key-value format content into the corresponding configuration center server configuration file to realize the synchronization updating of the configuration file of the configuration center server in multiple environments.
[0144] Specifically, after the client of the present application highlights the difference content according to the first array and the second array, the user can modify the key-value format content after highlighting the difference content, and write the modified key-value format content into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the multi-environment configuration center server.
[0145] In one embodiment, after receiving the key-value format content modified by the user according to the highlighting, the related information of each configuration file saved locally is synchronized and updated.
[0146] Specifically, the present application synchronously updates and saves the key-value format content after modification in the local database, at this time the client sends an http request to save the configuration file to the server, after receiving the request, the server reads the address and account information of the corresponding configuration center from the local database according to the configuration center information requested by the client, and then uses the http request to update the configuration file content to the configuration center server according to the address and account information of the configuration center, after successful update, the server returns the client an update success prompt. After successfully updating the configuration file content, the client can re-initiate the configuration file comparison according to the needs.
[0147] In one embodiment, the configuration file synchronization updating device 003 further comprises a storage module. The storage module is used to save the related information of each configuration file of each environment configuration center server to the local database before reading the latest content of the configuration file of the multi-environment configuration center server. Specifically, the user can first input the related information of each configuration file of each environment configuration center server in the client, and send it to the server using the http request, and the server stores the related information of each configuration file of each environment configuration center server to the local database. The technical problem solved by this step is how to realize the initialization of the local configuration center configuration information. The technical effect realized by this step is that the configuration file can be selected for synchronization update according to the needs, which improves the work efficiency. In particular, specific environment and specific configuration file can also be selected according to the needs.
[0148] The application reads the latest content of the configuration file of the multi-environment configuration center server, reorders and compares, writes the modified content of the difference content found in the comparison into the corresponding configuration center server configuration file to realize the configuration file synchronization update of the multi-environment configuration center server.
[0149] As Figure 6 The computer equipment entity structure schematic diagram provided by the embodiment of the application is shown in the figure, and the computer equipment 004 includes a processor 41, a memory 42 and a bus 43.
[0150] The processor 41 is used to call the program instruction in the memory 42 to execute the method provided by each method embodiment.
[0151] The embodiment of the application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program.
[0152] The embodiment of the application further provides a computer program product, and the computer program product includes a computer program.
[0153] The embodiment of the application provides a configuration file synchronization update method and device, and the application is used to solve the problem that the same configuration in the configuration file of the multi-environment configuration center server is different due to the different filling orders of different personnel, the same configuration item in each environment is inconsistent, the configuration file is compared, the order is reordered, the original order of the configuration item is not dependent, the configuration personnel is more friendly, and the configuration efficiency is improved.
[0154] Compared with the prior art, the application has the following advantages:
[0155] 1. The prior art solution can only view line by line whether there is highlighted difference content when comparing the contents of configuration files, and cannot quickly locate the difference content. The present application provides a quick positioning button, which can locate the specific difference content position after being clicked, greatly improving the speed of the user in finding the difference content.
[0156] 2. In the prior art solution, even if the configuration files are the same configuration item, because of the difference in the filling order, even if the contents are consistent, it will be considered as a difference. In order to solve the problem that the same configuration in multiple environment configuration files is inconsistent due to different personnel filling order, the present application reorders when comparing the configuration files, and is not dependent on the order of the configuration item, which is more friendly to the configuration personnel.
[0157] 3. The prior art solution can only support the comparison of configuration files of the configuration center server of the same environment. The present application can support the comparison of configuration files of the configuration center server of multiple environments by developing a small tool to read the configuration files from the configuration center server for comparison.
[0158] 4. The prior art solution can only support the comparison of two configuration files. The present application can support the comparison of multiple configuration files by developing a small tool to read the configuration files from the configuration center server for comparison.
[0159] 5. The prior art solution cannot modify the difference content when comparing, and needs to enter the menu function of modifying the configuration for modification, and the operation process is not coherent. The present application can support modifying the difference content on the comparison page and supporting synchronous updating to the corresponding configuration center server by developing a small tool to read the configuration files from the configuration center server for comparison.
[0160] It should be noted that the configuration file synchronous updating method and device provided by the embodiments of the present application can be used in the financial field, and can also be used in any technical field other than the financial field, and the application field of the configuration file synchronous updating method and device is not limited by the embodiments of the present application.
[0161] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0162] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart or flows and / or block or blocks in the block diagrams. Figure 1 one or more functions specified in the flowchart or flows and / or block or blocks of the block diagrams. Figure 1 one or more functions specified in the flowchart or flows and / or block or blocks of the block diagrams.
[0163] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the Figure 1 one or more functions specified in the flowchart or flows and / or block or blocks of the block diagrams. Figure 1 one or more functions specified in the flowchart or flows and / or block or blocks of the block diagrams.
[0164] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart or flows and / or block or blocks in the block diagrams. Figure 1 one or more functions specified in the flowchart or flows and / or block or blocks of the block diagrams. Figure 1 one or more functions specified in the flowchart or flows and / or block or blocks of the block diagrams.
[0165] The above described specific embodiments are merely intended to further describe and explain the principle, technical scheme and advantages of the present application, and should be understood that the above description is merely for specific embodiments of the present application and is not intended to limit the protection scope of the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A configuration file synchronization update method, characterized by, The application relates to a method for synchronously updating configuration files of a multi-environment configuration center server. The method comprises the following steps: reading the latest content of the configuration files of the multi-environment configuration center server row by row; storing the latest content of each configuration file in a hashmap data structure corresponding to the configuration file in a key-value format respectively to perform deduplication processing; storing each row of key values in the hashmap data structure after deduplication in a treeset data structure of the corresponding configuration file to perform reordering in alphabetical order; comparing whether the key values are consistent in turn based on the reordered treeset data structure content of each configuration file respectively, and then comparing whether the value values are consistent in turn based on the hashmap data structure content; 2. The configuration file synchronization update method of claim 1, wherein, returning the difference content found by comparison to a client for modification, and then writing the modified content into the corresponding configuration file of the configuration center server to realize synchronous updating of the configuration files of the multi-environment configuration center server.
3. The configuration file synchronization update method of claim 2, wherein, The comparison of whether the key values are consistent comprises the following steps: taking the treeset data structure of one of the configuration files as a reference, reading the key values in the treeset data structure by using a for loop, judging whether the hashmap data structure of the other configuration files has corresponding key values by using the key values, if yes, comparing whether the value values are consistent, if no, writing the row number of the key values into a first array, and inserting the key values into the corresponding positions of the hashmap data structure and the treeset data structure of the other configuration files which do not have the key values, and setting the corresponding value values in the hashmap data structure as not_exist.
4. The configuration file synchronization update method of claim 3, wherein, The comparison of whether the value values are consistent comprises the following steps: taking the hashmap data structure of one of the configuration files as a reference, reading the value values in the hashmap data structure by using a for loop, judging whether the hashmap data structure of the other configuration files has corresponding value values by using the value values, if yes, ending the comparison, if no, writing the row number of the value values into a second array, and inserting not_exist into the corresponding positions of the hashmap data structure of the other configuration files which do not have the value values.
5. The configuration file synchronization update method of claim 4, wherein, The row numbers of the inconsistent key values are written into the first array in ascending order, and the row numbers of the inconsistent value values are written into the second array in ascending order. The method comprises the following steps: returning the first array, the second array and the latest key-value format content in the hashmap data structure of each configuration file to the client.
6. The configuration file synchronization update method of claim 5, wherein, The writing into the corresponding configuration center server configuration file to realize the configuration file synchronous update of the multi-environment configuration center server includes: after the client highlights the difference content according to the first array and the second array, receiving the key-value format content modified by the user according to the highlight, and writing into the corresponding configuration center server configuration file to realize the configuration file synchronous update of the multi-environment configuration center server.
7. The configuration file synchronization update method of claim 6, wherein, After receiving the key-value format content modified by the user according to the highlight, the related information of each configuration file saved locally is synchronously updated.
8. The configuration file synchronization update method of claim 1, wherein, Before reading the latest content of the configuration file of the multi-environment configuration center server line by line, the configuration file synchronous update method further includes: saving the related information of each configuration file of the configuration center server of each environment to the local database.
9. The configuration file synchronization update method of claim 8, wherein, The related information includes the configuration file name, the account information, and the configuration center server ID.
10. The configuration file synchronization update method of claim 8 or 9, wherein, Based on the related information, the latest content of the configuration file of the multi-environment configuration center server is read through the http protocol.
11. The configuration file synchronization update method of claim 10, wherein, Before reading the latest content of the configuration file of the multi-environment configuration center server through the http protocol, the configuration file synchronous update method further includes: checking whether the suffixes of each configuration file name are consistent, if not, exiting reading; if consistent, reading the latest content of the configuration file of the multi-environment configuration center server through the http protocol.
12. A configuration file synchronization updating apparatus characterized by comprising: Including: A reading module for reading the latest content of the configuration file of the multi-environment configuration center server line by line; A deduplication module for storing the latest content of each configuration file in the hashmap data structure corresponding to the configuration file in key-value format for deduplication processing; A reordering module for storing each row of key values in the hashmap data structure after deduplication in the treeset data structure corresponding to the configuration file in alphabetical order for reordering; A comparison module for comparing whether the key values are consistent by taking the treeset data structure content reordered after each configuration file as a benchmark, and if the key values are inconsistent, making the key values consistent, and then comparing whether the value values are consistent by taking the hashmap data structure content as a benchmark; A synchronous update module for writing the difference content found by comparison into the corresponding configuration center server configuration file to realize the configuration file synchronous update of the multi-environment configuration center server after returning the difference content to the client for modification.
13. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the configuration file synchronous update method of any one of claims 1-11.
14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to realize the configuration file synchronous update method of any one of claims 1-11.
15. A computer program product, characterised in that, The computer program product includes a computer program, and the computer program is executed by the processor to realize the configuration file synchronous update method of any one of claims 1-11.