Configuration updating method and device, equipment and storage medium
By introducing task identification and distributed cache between the task server and the application server, periodic reporting and status synchronization of configuration updates is achieved, which solves the problem that the headquarters configuration center cannot perceive the success of the configuration update, and improves the reliability of configuration updates. .
Patent Information
- Application Number
- CN202411426550.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-02-18
AI Technical Summary
In business systems deployed by provinces, the headquarters configuration center cannot sense whether the latest configuration data is successfully effective in the provinces system, resulting in low reliability of configuration updates.
By introducing task identification and distributed cache between the task server and the application server, periodic reporting and status synchronization of configuration updates can be achieved. The task server receives configuration update tasks, stores target configuration information, and generates task identification. The application server updates configuration information based on the task identification, and records the update status in the distributed cache. The task server periodically obtains update information and reports it to the general server.
Real-time monitoring and status synchronization of configuration updates is realized, the reliability of configuration updates is improved, and the overall server can promptly inform the configuration updates of each application server in the server cluster.
Smart Images

Figure CN119484279A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a configuration update method, device, equipment and storage medium. Background Art
[0002] In some scenarios, you can deploy business systems in a province-by-province manner to meet the business needs of different regions. For example, in the insurance business scenario, you can deploy the insurance business system in a province-by-province manner, that is, different provinces or regions have independent provincial systems.
[0003] In related technologies, the configuration data of provincial systems can be centralized in the headquarters configuration center for unified storage and management, and the headquarters configuration center can provide an application programming interface (API) for data query services. When a provincial system needs to obtain a certain updated configuration, it can obtain the configuration update data from the headquarters configuration center through the API.
[0004] However, in the above method, after the provincial system obtains data from the headquarters configuration center, the headquarters configuration center cannot sense whether the latest configuration data has been successfully implemented in the provincial system, resulting in low reliability of configuration updates. Summary of the invention
[0005] The present application provides a configuration update method, apparatus, device and storage medium to solve the problem of low answer reliability.
[0006] In a first aspect, the present application provides a configuration update method, which is applied to a task server, wherein the task server is located in a server cluster, and the server cluster also includes multiple application servers, and the method includes:
[0007] receiving a first configuration update task sent by the main server, where the first configuration update task is used to instruct to update the configuration information of the multiple application servers to target configuration information;
[0008] Storing the target configuration information in a database corresponding to the server cluster;
[0009] Generate a task identifier corresponding to the first configuration update task, and send the task identifier to the main server, so that the main server sends the task identifier to the multiple application servers, and the multiple application servers obtain the target configuration information in the database;
[0010] According to the task identifier, update information of the multiple application servers is periodically obtained and sent to the main server, where the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated.
[0011] In a possible design, the server cluster includes a plurality of task servers; storing the target configuration information in a database corresponding to the server cluster includes:
[0012] Perform an optimistic lock preemption operation in the distributed cache to obtain an optimistic lock preemption result, wherein the optimistic lock preemption result is a preemption success or a preemption failure;
[0013] If the optimistic locking result is that the preemption is successful, determining a first service state of the task server, where the first service state is used to indicate whether there is a running task on the task server;
[0014] According to the first service state, the target configuration information is stored in the database.
[0015] In a possible design, storing the target configuration information in the database according to the first service state includes:
[0016] If the first service status indicates that there is a task being run on the task server, pausing the running task and storing the target configuration information in the database;
[0017] If the first service status indicates that there is no running task on the task server, the target configuration information is stored in the database.
[0018] In one possible design, the method further includes:
[0019] If the optimistic locking result is the preemption failure, determining a second service state of the task server, where the second service state is used to indicate whether the task server has a running task;
[0020] If the second service status indicates that there is a task being run on the task server, the running task is suspended.
[0021] In a possible design, periodically acquiring update information of the multiple application servers according to the task identifier and sending the update information to the main server includes:
[0022] Determine multiple reporting times according to the reporting cycle, wherein the multiple reporting times are periodically distributed;
[0023] For any reporting time, at the reporting time, according to the task identifier, multiple record information is obtained in the distributed cache, the record information includes the task identifier, the identifier of the application server and the update status, and the update status is an updated state or a non-updated state;
[0024] generating the update information according to the plurality of record information;
[0025] Send the update information to the main server.
[0026] In a possible design, generating the update information according to the plurality of record information includes:
[0027] Determine the number of the plurality of record information, and determine the number of the plurality of record information as the total number of the plurality of application servers;
[0028] Determining first record information and second record information from the plurality of record information, wherein the update status in the first record information is the updated status, and the update status in the second record information is the not updated status;
[0029] Determine the number of the first record information as the number of application servers whose configuration information has been updated;
[0030] The update information further includes an identifier of the application server in the second record.
[0031] In one possible design, the method further includes:
[0032] Determine whether the total number of the plurality of application servers is the same as the number of application servers whose configuration information has been updated;
[0033] If so, the first configuration update task is terminated.
[0034] In a second aspect, the present application provides a configuration update method, which is applied to an application server, wherein the application server is located in a server cluster, and the server cluster includes multiple application servers and task servers, and the method includes:
[0035] Receive the task identifier sent by the main server;
[0036] Generate record information according to the task identifier, the record information including the task identifier, the identifier of the application server and an update status, the update status being a non-updated status;
[0037] The recorded information is stored in a distributed cache, and the task server is used to report update information to the main server according to the recorded information in the distributed cache, wherein the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated;
[0038] According to the task identifier, obtaining target configuration information in a database corresponding to the server cluster, and updating the configuration information of the application server to the target configuration information;
[0039] The update status in the distributed cache and the record information is modified to an updated status.
[0040] In a possible design, generating record information according to the task identifier includes: determining whether the task identifier is empty;
[0041] If the task identifier is not empty, a key-value pair is generated with the task identifier as a key and the identifier of the application server and the update status as values;
[0042] The key-value pair is determined as the record information.
[0043] In one possible design, updating the configuration information of the application server to the target configuration information includes:
[0044] Determining a configuration cache corresponding to the application server;
[0045] Clearing the configuration cache;
[0046] The target configuration information is stored in the configuration cache to update the configuration information of the application server to the target configuration information.
[0047] In a third aspect, the present application provides a configuration update device, including: a first receiving module, a first storage module, a first generating module, a sending module and an acquiring module, wherein:
[0048] The first receiving module is used to receive a first configuration update task sent by the main server, where the first configuration update task is used to instruct to update the configuration information of the multiple application servers to the target configuration information;
[0049] The first storage module is used to store the target configuration information in a database corresponding to the server cluster;
[0050] The first generating module is used to generate a task identifier corresponding to the first configuration update task;
[0051] The sending module is used to send the task identifier to the main server, so that the main server sends the task identifier to the multiple application servers, and enables the multiple application servers to obtain the target configuration information in the database;
[0052] The acquisition module is used to periodically acquire update information of the multiple application servers according to the task identifier;
[0053] The sending module is further used to send the update information to the main server, where the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated.
[0054] In a possible design, the first storage module is specifically used for:
[0055] Perform an optimistic lock preemption operation in the distributed cache to obtain an optimistic lock preemption result, wherein the optimistic lock preemption result is a preemption success or a preemption failure;
[0056] If the optimistic locking result is that the preemption is successful, determining a first service state of the task server, where the first service state is used to indicate whether there is a running task on the task server;
[0057] According to the first service state, the target configuration information is stored in the database.
[0058] In a possible design, the first storage module is specifically used for:
[0059] If the first service status indicates that there is a task being run on the task server, pausing the running task and storing the target configuration information in the database;
[0060] If the first service status indicates that there is no running task on the task server, the target configuration information is stored in the database.
[0061] In a possible design, the configuration updating device further includes a determining module and a pausing module, wherein:
[0062] The determination module is used to determine the second service state of the task server if the optimistic locking result is the preemption failure, wherein the second service state is used to indicate whether the task server has a running task;
[0063] The pause module is configured to pause the running task if the second service status indicates that there is a running task on the task server.
[0064] In a possible design, the acquisition module is specifically used for:
[0065] Determine multiple reporting times according to the reporting cycle, wherein the multiple reporting times are periodically distributed;
[0066] For any reporting time, at the reporting time, according to the task identifier, multiple record information is obtained in the distributed cache, the record information includes the task identifier, the identifier of the application server and the update status, and the update status is an updated state or a non-updated state;
[0067] generating the update information according to the plurality of record information;
[0068] Send the update information to the main server.
[0069] In a possible design, the acquisition module is specifically used for:
[0070] Determine the number of the plurality of record information, and determine the number of the plurality of record information as the total number of the plurality of application servers;
[0071] Determining first record information and second record information from the plurality of record information, wherein the update status in the first record information is the updated status, and the update status in the second record information is the not updated status;
[0072] Determine the number of the first record information as the number of application servers whose configuration information has been updated;
[0073] The update information further includes an identifier of the application server in the second record.
[0074] In a possible design, the acquisition module is specifically used for:
[0075] Determine whether the total number of the plurality of application servers is the same as the number of application servers whose configuration information has been updated;
[0076] If so, the first configuration update task is terminated.
[0077] In a fourth aspect, the present application provides a configuration update device, comprising: a second receiving module, a second generating module, a second storage module, an updating module and a modifying module, wherein:
[0078] The second receiving module is used to receive the task identifier sent by the main server;
[0079] The second generating module is used to generate record information according to the task identifier, wherein the record information includes the task identifier, the identifier of the application server and an update status, and the update status is a non-updated status;
[0080] The second storage module is used to store the record information in the distributed cache, and the task server is used to report update information to the main server according to the record information in the distributed cache, wherein the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated;
[0081] The updating module is used to obtain target configuration information in a database corresponding to the server cluster according to the task identifier, and update the configuration information of the application server to the target configuration information;
[0082] The modification module is used to modify the update status in the distributed cache and the record information to an updated status.
[0083] In a possible design, the second generation module is specifically used for:
[0084] Determine whether the task identifier is empty;
[0085] If the task identifier is not empty, a key-value pair is generated with the task identifier as a key and the identifier of the application server and the update status as values;
[0086] The key-value pair is determined as the record information.
[0087] In a possible design, the update module is specifically used for:
[0088] Determining a configuration cache corresponding to the application server;
[0089] Clearing the configuration cache;
[0090] The target configuration information is stored in the configuration cache to update the configuration information of the application server to the target configuration information.
[0091] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor and a memory; the memory stores computer execution instructions; the at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the configuration update method described in the first aspect and various possible designs of the first aspect.
[0092] In the sixth aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor and a memory; the memory stores computer execution instructions; the at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the configuration update method described in the second aspect and various possible designs of the second aspect.
[0093] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the configuration update method of the first aspect and various possible designs of the first aspect are implemented.
[0094] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the configuration update method of the second aspect and various possible designs of the second aspect are implemented.
[0095] In a ninth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the configuration update method of the first aspect and various possible designs of the first aspect.
[0096] In a tenth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the configuration update method of the second aspect and various possible designs of the second aspect.
[0097] The configuration update method, apparatus, device and storage medium provided in the present application enable the main server to send a configuration update task to the task server when the configuration of multiple application servers needs to be updated. The task server can control each application server to perform configuration update, periodically obtain the configuration update status of each application server, and report the configuration update status of each application server to the main server, so that the main server can be aware of the configuration update status of each application server in the server cluster in real time, thereby improving the reliability of configuration update. BRIEF DESCRIPTION OF THE DRAWINGS
[0098] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0099] Figure 1 A schematic diagram of the system architecture provided for an embodiment of the present application;
[0100] Figure 2 A flowchart of a configuration update method provided in an embodiment of the present application;
[0101] Figure 3 A schematic diagram of a visual operation window of a configuration system provided in an embodiment of the present application;
[0102] Figure 4 A schematic diagram of a method process for storing target configuration information in a database provided in an embodiment of the present application;
[0103] Figure 5A schematic diagram of the structure of a configuration update device provided in an embodiment of the present application;
[0104] Figure 6 A schematic diagram of the structure of another configuration update device provided in an embodiment of the present application;
[0105] Figure 7 A schematic diagram of the structure of another configuration update device provided in an embodiment of the present application;
[0106] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0107] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0108] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0109] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved shall comply with the provisions of relevant laws and regulations and shall not violate public order and good morals.
[0110] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0111] For ease of understanding, the following Figure 1 , the system architecture applicable to the embodiments of the present application is described.
[0112] Figure 1 This is a schematic diagram of the system architecture provided by the embodiment of this application. Figure 1, including a main server 101 and multiple server clusters 102. The main server 101 may include a configuration system, and users can update configuration information in the configuration system. There may be multiple server clusters 102, and the multiple server clusters 102 are independently deployed. The server cluster 102 may include multiple application servers and multiple task servers. The server cluster 102 may receive configuration information sent from the main server 101, and the main server 101 may receive update information sent by multiple server clusters 102.
[0113] In related technologies, the configuration data of provincial systems can be centralized in the headquarters configuration center for unified storage and management, and the headquarters configuration center provides an API to the outside world. When a provincial system needs to obtain a certain updated configuration, it can obtain the required configuration update data from the headquarters configuration center through the API. However, in the above method, after the provincial system obtains data from the headquarters configuration center, the headquarters configuration center cannot sense whether the latest configuration data has been successfully implemented in the provincial system, resulting in low system reliability.
[0114] In response to the above technical problems, in an embodiment of the present application, the server cluster includes a task server and multiple application servers. When the configurations of multiple application servers need to be updated, the main server can send a configuration update task to the task server. The task server can control each application server to perform a configuration update, periodically obtain the configuration update status of each application server, and report the configuration update status of each application server to the main server, so that the main server can be aware of the configuration update status of each application server in the server cluster in real time, thereby improving the reliability of the configuration update.
[0115] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0116] Figure 2 A flowchart of a configuration update method provided in an embodiment of the present application. Figure 2 As shown, the method may include the following steps:
[0117] S201. A main server sends a first configuration update task to a task server.
[0118] The task server can be a server located in a server cluster, which also includes multiple application servers. The task server can be used to receive configuration update tasks from the main server, and can also be used to periodically obtain the update status of the application server and synchronize the update status to the main server. The application server can be used to modify the configuration information to the target configuration information sent by the main server.
[0119] The main server may include a configuration system, which may have a visual operation window. Users may modify the configuration information of different server clusters through the visual operation window of the configuration system. The visual operation window of the configuration system may include a "publish" control, a server cluster selection module and a configuration information modification module.
[0120] Next, combine Figure 3 , through specific examples, the visual operation window of the configuration system is explained.
[0121] Figure 3 For a schematic diagram of a visual operation window of a configuration system provided in an embodiment of the present application, see Figure 3 , including a "Publish" control, a server cluster selection module and a configuration information modification module. The user can select the server cluster identifier in the server cluster selection module, select the configuration name to be modified in the configuration information input module and enter the modified configuration data. The user can generate the first configuration update task by clicking the "Publish" control.
[0122] The first configuration update task may be used to instruct to update the configuration information of multiple application servers to target configuration information. The configuration information may include a configuration name and corresponding configuration data. For example, when the configuration name is a product directory and the corresponding configuration data is a product name, the configuration information may be "product directory: product name".
[0123] S202: The task server stores the target configuration information in a database corresponding to the server cluster.
[0124] The database may be located in the storage space of the server cluster, and all configuration information of the server cluster is stored in the database.
[0125] The target configuration information data can be updated to the database in the following manner: the task server can obtain the target configuration information according to the first configuration update task, determine the configuration name of the target configuration information according to the target configuration information, search for corresponding configuration information in the database according to the configuration name, and update the configuration data of the target configuration information to the database.
[0126] S203: The task server generates a task identifier corresponding to the first configuration update task.
[0127] The task identifier may refer to an identifier for identifying task information, and may uniquely indicate the first configuration update task. Optionally, the task identifier may consist of 32 hexadecimal digits and be divided into five groups by hyphens, for example, the task identifier may be "550e8400-e29b-41d4-a716-446655440000".
[0128] S204: The task server sends a task identifier to the main server.
[0129] S205: The main server sends a task identifier to multiple application servers.
[0130] Whether to send a task identifier to multiple application servers can be determined in the following way: after the main server receives the task identifier, it obtains an identifier list in the storage space corresponding to the main server, and determines whether the task identifier exists in the identifier list. If not, the task identifier is sent to multiple application servers; if so, it indicates that the configuration update task is being executed and the task identifier is not sent.
[0131] S205: The application server generates record information according to the task identifier and stores it in the distributed cache.
[0132] The distributed cache can be located in the storage space of the server cluster and is used to store record information.
[0133] The record information includes a task identifier, an application server identifier, and an update status, wherein the application server identifier may refer to an Internet Protocol Address (IP address) of the application server, and the update status may include an updated status and a not updated status, and the current update status is a not updated status.
[0134] The record information may be generated in the following manner: determine whether the task identifier is empty; if the task identifier is not empty, generate a key-value pair with the task identifier as a key and the identifier and update status of the application server as values; and determine the key-value pair as the record information. The record information may be in the form of "task identifier: identifier of the application server, update status", for example, the record information may be "123e4567-e89b-12d3-a456-426614174000: 192.168.1.1, not updated status".
[0135] S206: The application server obtains target configuration information from the database, and updates the configuration information of the application server to the target configuration information.
[0136] The configuration information of the application server may be updated to the target configuration information in the following manner: determining a configuration cache corresponding to the application server; clearing the configuration cache; and storing the target configuration information in the configuration cache, so as to update the configuration information of the application server to the target configuration information.
[0137] The configuration cache may be located in the storage space of the application server and is used to cache configuration information of the application server.
[0138] S207: The application server modifies the update status in the distributed cache and the record information to an updated status.
[0139] For any application server, when the configuration information of the application server is updated to the target configuration information, the corresponding record information is searched in the distributed cache database according to the IP address of the application server, and the update status in the record information is modified to the updated status. For example, the modified record information can be "123e4567-e89b-12d3-a456-426614174000: 192.168.1.1, updated status"
[0140] S209: The task server periodically obtains update information of multiple application servers according to the task identifier.
[0141] The update information includes the total number of multiple application servers, the number of application servers whose configuration information has been updated, and the identifiers of application servers whose configuration information has not been updated.
[0142] Periodic reporting can be performed in the following manner: according to the reporting period, multiple reporting times are determined, and the multiple reporting times are distributed periodically; for any reporting time, at the reporting time, according to the task identifier, multiple record information is obtained in the distributed cache, the record information includes the task identifier, the application server identifier and the update status, and the update status is an updated status or a non-updated status; based on the multiple record information, update information is generated; and the update information is sent to the main server.
[0143] Among them, the user can pre-set the reporting cycle. For example, assuming the reporting cycle is 1 hour, the reporting time can be 1 o'clock, 2 o'clock, 3 o'clock, etc., and the reporting time is periodically distributed; assuming the reporting cycle is every day, the reporting time can be 0 o'clock every day.
[0144] The update information can be determined in the following manner: determine the number of multiple record information, and determine the number of multiple record information as the total number of multiple application servers; determine the first record information and the second record information in the multiple record information, the update status in the first record information is the updated status, and the update status in the second record information is the unupdated status; determine the number of the first record information as the number of application servers whose configuration information has been updated; the update information also includes the identifier of the application server in the second record information.
[0145] For example, assuming that the number of multiple record information is 100, the number of first record information is 97, and the identifiers of application servers in the second record information are IP1, IP2, and IP3, then the update information is "the total number of multiple application servers: 100, the number of application servers whose configuration information has been updated: 97, the identifiers of application servers whose configuration information has not been updated: IP1, IP2, and IP3".
[0146] The above method also includes that the task server can determine whether the total number of multiple application servers is the same as the number of application servers whose configuration information has been updated based on the update information. If they are the same, it means that all application servers have completed the configuration information update and the first configuration update task is ended.
[0147] S210: The task server sends update information to the main server.
[0148] In an embodiment of the present application, when the configuration needs to be updated, the task server in the server cluster can receive the first configuration update task of the main server, and the task server can store the target configuration information in the first configuration update task in the database, generate a task identifier corresponding to the first configuration update task, and send the task identifier to the main server; after the main server receives the task identifier, it sends the task identifier to multiple application servers, and the application server generates record information based on the task identifier and stores it in the distributed cache, obtains the target configuration information in the database, and updates the configuration information in the application server. After the update is completed, the update status in the distributed cache is modified to an updated status; the task server periodically obtains the update information of multiple application servers based on the task identifier, and sends the update information to the main server; when the total number of multiple application servers is the same as the number of application servers that have completed the update of the configuration information, the first configuration update task is terminated, thereby improving the reliability of the configuration update.
[0149] Based on any of the above embodiments, Figure 4 , a method for storing target configuration information in a database is described in detail.
[0150] Figure 4A schematic diagram of a method for storing target configuration information in a database provided in an embodiment of the present application. Figure 4 , the method is applied to the task server and may include:
[0151] S401. Multiple task servers receive a first configuration update task sent by a main server.
[0152] It should be noted that the execution process of the above S401 can refer to S201 and will not be repeated here.
[0153] S402: Perform an optimistic lock preemption operation in the distributed cache, obtain an optimistic lock preemption result, and determine whether the optimistic lock preemption result is a successful preemption.
[0154] Optimistic locking may refer to a concurrency control mechanism, wherein the optimistic locking preemption result may include preemption success or preemption failure.
[0155] The preemption result of the optimistic lock can be determined in the following manner: the task server receives the first configuration update task sent by the main server; determines the target configuration information according to the first configuration update task, reads the data in the distributed cache, and records the first version number in the distributed cache; writes the target configuration information into the distributed cache, and reads the second version number in the distributed cache; determines whether the first version number and the second version number are consistent, if they are consistent, determines that the preemption result of the optimistic lock is a successful preemption, if they are inconsistent, determines that the preemption result of the optimistic lock is a preemption failure.
[0156] If yes, execute S403.
[0157] If not, execute S407.
[0158] S403: Determine a first service status of the task server.
[0159] The first service status is used to indicate whether there is a running task on the task server.
[0160] The first service status of the task server can be determined in the following manner: obtain a task table in the task server, wherein each time the task server starts running a task, it records the task running status of the task server in the task table, and the running status may include task running and task running completed; based on the task status in the task table, the first service status of the task server can be determined, that is, if the task status is that the task is running, then it indicates that the first service status of the task server is that there is a running task; if the task status is that the task is completed, then it indicates that the first service status of the task server is that there is no running task.
[0161] S404: Determine, based on the first service status, whether there is a task running on the first service status indicating task server.
[0162] If yes, execute S405.
[0163] If not, execute S406.
[0164] S405: Pause the running task and store the target configuration information in the database.
[0165] S406: Store the target configuration information in a database.
[0166] S407: Determine the second service status of the task server.
[0167] The second service status is used to indicate whether there is a running task on the task server.
[0168] The second service status of the task server can be determined in the following manner: obtain the task table in the task server, wherein each time the task server starts running a task, it records the task running status of the task server in the task table, and the running status may include task running and task running completed; based on the task status in the task table, the second service status of the task server can be determined, that is, if the task status is that the task is running, then it indicates that the second service status of the task server is that there is a running task; if the task status is that the task is completed, then it indicates that the second service status of the task server is that there is no running task.
[0169] S408: If the second service status indicates that there is a task being run on the task server, suspend the running task.
[0170] In an embodiment of the present application, when it is necessary to update the configuration, multiple task servers in the server cluster can receive the first configuration update task of the main server, and the task server can perform an optimistic lock preemption operation in the distributed cache, and can determine the preemption result of the optimistic lock, and judge whether the preemption result of the optimistic lock is a successful preemption. If so, the first service state of the task server is determined. According to the first service state, if the task server has a running task, the running task is paused and the target configuration information is stored in the database. If the task server does not have a running task, the target configuration information is directly stored in the database; if not, the second service state of the task server is determined. If the second service state indicates that the task server has a running task, the running task is paused. By having multiple task servers preempt optimistic locks, task conflicts between multiple servers are avoided, and the reliability of configuration updates is improved.
[0171] Figure 5This is a schematic diagram of the structure of a configuration update device provided in an embodiment of the present application. Figure 5 , applied to the task server, the configuration update device 10 includes: a first receiving module 11, a first storage module 12, a first generating module 13, a sending module 14 and an acquiring module 15, wherein,
[0172] The first receiving module 11 is used to receive a first configuration update task sent by the main server, where the first configuration update task is used to instruct to update the configuration information of the multiple application servers to target configuration information;
[0173] The first storage module 12 is used to store the target configuration information in a database corresponding to the server cluster;
[0174] The first generating module 13 is used to generate a task identifier corresponding to the first configuration update task;
[0175] The sending module 14 is used to send the task identifier to the main server, so that the main server sends the task identifier to the multiple application servers, and enables the multiple application servers to obtain the target configuration information in the database;
[0176] The acquisition module 15 is used to periodically acquire update information of the multiple application servers according to the task identifier;
[0177] The sending module 14 is further used to send the update information to the main server, where the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated.
[0178] A configuration updating device provided in an embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0179] In a possible design, the first storage module 12 is specifically used for:
[0180] Perform an optimistic lock preemption operation in the distributed cache to obtain an optimistic lock preemption result, wherein the optimistic lock preemption result is a preemption success or a preemption failure;
[0181] If the optimistic locking result is that the preemption is successful, determining a first service state of the task server, where the first service state is used to indicate whether there is a running task on the task server;
[0182] According to the first service state, the target configuration information is stored in the database.
[0183] In a possible design, the first storage module 12 is specifically used for:
[0184] If the first service status indicates that there is a task being run on the task server, pausing the running task and storing the target configuration information in the database;
[0185] If the first service status indicates that there is no running task on the task server, the target configuration information is stored in the database.
[0186] In a possible design, the acquisition module 15 is specifically used for:
[0187] Determine multiple reporting times according to the reporting cycle, wherein the multiple reporting times are periodically distributed;
[0188] For any reporting time, at the reporting time, according to the task identifier, multiple record information is obtained in the distributed cache, the record information includes the task identifier, the identifier of the application server and the update status, and the update status is an updated state or a non-updated state;
[0189] generating the update information according to the plurality of record information;
[0190] Send the update information to the main server.
[0191] In a possible design, the acquisition module 15 is specifically used for:
[0192] Determine the number of the plurality of record information, and determine the number of the plurality of record information as the total number of the plurality of application servers;
[0193] Determining first record information and second record information from the plurality of record information, wherein the update status in the first record information is the updated status, and the update status in the second record information is the not updated status;
[0194] Determine the number of the first record information as the number of application servers whose configuration information has been updated;
[0195] The update information further includes an identifier of the application server in the second record.
[0196] In a possible design, the acquisition module 15 is specifically used for:
[0197] Determine whether the total number of the plurality of application servers is the same as the number of application servers whose configuration information has been updated;
[0198] If so, the first configuration update task is terminated.
[0199] Figure 6A schematic diagram of another configuration update device provided in an embodiment of the present application. Figure 5 Based on Figure 6 The configuration updating device 10 further includes a determining module 16 and a pausing module 17, wherein:
[0200] The determination module 16 is used to determine the second service state of the task server if the optimistic locking result is the preemption failure, where the second service state is used to indicate whether there is a running task on the task server;
[0201] The pausing module 17 is configured to suspend the running task if the second service status indicates that there is a running task on the task server.
[0202] A configuration updating device provided in an embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0203] Figure 7 This is a schematic diagram of another configuration update device provided in an embodiment of the present application. Figure 7 , applied to the application server, the configuration update device 20 includes: a second receiving module 21, a second generating module 22, a second storage module 23, an updating module 24 and a modifying module 25, wherein,
[0204] The second receiving module 21 is used to receive the task identifier sent by the main server;
[0205] The second generating module 22 is used to generate record information according to the task identifier, wherein the record information includes the task identifier, the identifier of the application server and an update status, and the update status is a non-updated status;
[0206] The second storage module 23 is used to store the record information in the distributed cache, and the task server is used to report update information to the main server according to the record information in the distributed cache, wherein the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated;
[0207] The updating module 24 is used to obtain target configuration information in the database corresponding to the server cluster according to the task identifier, and update the configuration information of the application server to the target configuration information;
[0208] The modification module 25 is used to modify the update status in the distributed cache and the record information to an updated status.
[0209] A configuration updating device provided in an embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0210] In a possible design, the second generating module 22 is specifically used for:
[0211] Determine whether the task identifier is empty;
[0212] If the task identifier is not empty, a key-value pair is generated with the task identifier as a key and the identifier of the application server and the update status as values;
[0213] The key-value pair is determined as the record information.
[0214] In a possible design, the update module 24 is specifically used for:
[0215] Determining a configuration cache corresponding to the application server;
[0216] Clearing the configuration cache;
[0217] The target configuration information is stored in the configuration cache to update the configuration information of the application server to the target configuration information.
[0218] A configuration updating device provided in an embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0219] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8 As shown, the electronic device 30 may include: a transceiver 31 , a processor 32 , and a memory 33 .
[0220] The processor 32 executes the computer execution instructions stored in the memory, so that the processor 32 executes the scheme in the above embodiment. The processor 32 can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0221] The memory 33 is connected to the processor 32 via a system bus and completes communication between them. The memory 33 is used to store computer program instructions.
[0222] The transceiver 31 may be used to obtain tasks to be executed and configuration information of the tasks to be executed.
[0223] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory.
[0224] The electronic device provided in the embodiment of the present application may be the terminal device of the above embodiment.
[0225] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the configuration update method in the above embodiment.
[0226] An embodiment of the present application further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the computer executes the technical solution of the configuration update method in the above embodiment.
[0227] An embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, it can implement the technical solution of the configurable update method in the above embodiment.
[0228] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0229] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0230] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0231] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0232] It should be understood that the above processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0233] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0234] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0235] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0236] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic control unit or a main control device.
[0237] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0238] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A configuration update method, characterized in that: Applied to a task server, the task server is located in a server cluster, and the server cluster also includes multiple application servers. The method includes: receiving a first configuration update task sent by the main server, where the first configuration update task is used to instruct to update the configuration information of the multiple application servers to target configuration information; Storing the target configuration information in a database corresponding to the server cluster; Generate a task identifier corresponding to the first configuration update task, and send the task identifier to the main server, so that the main server sends the task identifier to the multiple application servers, and the multiple application servers obtain the target configuration information in the database; According to the task identifier, update information of the multiple application servers is periodically obtained and sent to the main server, where the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated.
2. The method according to claim 1, characterized in that: The server cluster includes a plurality of task servers; storing the target configuration information in a database corresponding to the server cluster includes: Perform an optimistic lock preemption operation in the distributed cache to obtain an optimistic lock preemption result, wherein the optimistic lock preemption result is a preemption success or a preemption failure; If the optimistic locking result is that the preemption is successful, determining a first service state of the task server, where the first service state is used to indicate whether there is a running task on the task server; According to the first service state, the target configuration information is stored in the database.
3. The method according to claim 2, characterized in that According to the first service state, storing the target configuration information in the database includes: If the first service status indicates that there is a task being run on the task server, pausing the running task and storing the target configuration information in the database; If the first service status indicates that there is no running task on the task server, the target configuration information is stored in the database.
4. The method according to claim 2 or 3, characterized in that: The method further comprises: If the optimistic locking result is the preemption failure, determining a second service state of the task server, where the second service state is used to indicate whether the task server has a running task; If the second service status indicates that there is a task being run on the task server, the running task is suspended.
5. The method according to any one of claims 1 to 4, characterized in that: According to the task identifier, periodically acquiring update information of the multiple application servers and sending the update information to the main server includes: Determine multiple reporting times according to the reporting cycle, wherein the multiple reporting times are periodically distributed; For any reporting time, at the reporting time, according to the task identifier, multiple record information is obtained in the distributed cache, the record information includes the task identifier, the identifier of the application server and the update status, and the update status is an updated state or a non-updated state; generating the update information according to the plurality of record information; Send the update information to the main server.
6. The method according to claim 5, characterized in that Generating the update information according to the plurality of record information includes: Determine the number of the plurality of record information, and determine the number of the plurality of record information as the total number of the plurality of application servers; Determining first record information and second record information from the plurality of record information, wherein the update status in the first record information is the updated status, and the update status in the second record information is the not updated status; Determine the number of the first record information as the number of application servers whose configuration information has been updated; The update information further includes an identifier of the application server in the second record.
7. The method according to claim 5 or 6, characterized in that: The method further comprises: Determine whether the total number of the plurality of application servers is the same as the number of application servers whose configuration information has been updated; If so, the first configuration update task is terminated.
8. A configuration update method, characterized in that: Applied to an application server, the application server is located in a server cluster, the server cluster includes multiple application servers and task servers, the method includes: Receive the task identifier sent by the main server; Generate record information according to the task identifier, the record information including the task identifier, the identifier of the application server and an update status, the update status being a non-updated status; The recorded information is stored in a distributed cache, and the task server is used to report update information to the main server according to the recorded information in the distributed cache, wherein the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated; According to the task identifier, obtaining target configuration information in a database corresponding to the server cluster, and updating the configuration information of the application server to the target configuration information; The update status in the distributed cache and the record information is modified to an updated status.
9. The method according to claim 8, characterized in that Generating record information according to the task identifier includes: determining whether the task identifier is empty; If the task identifier is not empty, a key-value pair is generated with the task identifier as a key and the identifier of the application server and the update status as values; The key-value pair is determined as the record information.
10. The method according to claim 8 or 9, characterized in that: Updating the configuration information of the application server to the target configuration information includes: Determining a configuration cache corresponding to the application server; Clearing the configuration cache; The target configuration information is stored in the configuration cache to update the configuration information of the application server to the target configuration information.
11. A configuration updating device, characterized in that: Applied to a task server, comprising: a first receiving module, a first storage module, a first generating module, a sending module and an acquiring module, wherein: The first receiving module is used to receive a first configuration update task sent by the main server, where the first configuration update task is used to instruct to update the configuration information of the multiple application servers to the target configuration information; The first storage module is used to store the target configuration information in a database corresponding to the server cluster; The first generating module is used to generate a task identifier corresponding to the first configuration update task; The sending module is used to send the task identifier to the main server, so that the main server sends the task identifier to the multiple application servers, and enables the multiple application servers to obtain the target configuration information in the database; The acquisition module is used to periodically acquire update information of the multiple application servers according to the task identifier; The sending module is further used to send the update information to the main server, where the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated.
12. A configuration updating device, characterized in that: Applied to an application server, comprising: a second receiving module, a second generating module, a second storing module, an updating module and a modifying module, wherein: The second receiving module is used to receive the task identifier sent by the main server; The second generating module is used to generate record information according to the task identifier, wherein the record information includes the task identifier, the identifier of the application server and an update status, and the update status is a non-updated status; The second storage module is used to store the record information in the distributed cache, and the task server is used to report update information to the main server according to the record information in the distributed cache, wherein the update information includes the total number of the multiple application servers and the number of application servers whose configuration information has been updated; The updating module is used to obtain target configuration information in a database corresponding to the server cluster according to the task identifier, and update the configuration information of the application server to the target configuration information; The modification module is used to modify the update status in the distributed cache and the record information to an updated status.
13. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7, or the method according to any one of claims 8 to 10.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 7, or the method according to any one of claims 8 to 10.
15. A computer program product, characterized in that The method comprises a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 7 or the method according to any one of claims 8 to 10.
Citation Information
Patent Citations
Multi-node high-availability configuration distribution system and working method thereof
CN115396302A
Configuration data synchronization method and device for multiple systems
CN116233154A
Information synchronization method and apparatus
WO2022078243A1