Parameter synchronization method and apparatus

CN117520457BActive Publication Date: 2026-08-21BEIJING PACTERA JINXIN TECH LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311672422.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-07
Publication Date
2026-08-21
Estimated Expiration
2043-12-07

AI Technical Summary

Technical Problem

但在参数同步过程中,可能存在参数同步一致性问题,比如参数同步过程中各缓存同步的参数数据可能不一致

Benefits of technology

[0025]By acquiring the first parameter data to be synchronized, the first parameter data is stored in the target cache database and set to an inactive state. Then, at least one first node is determined from the node cluster. If second parameter data matching the number of first parameters exists in the designated memory of any first node, that first node is designated as a second node, and the second parameter data in the designated memory of at least one second node is set to an invalid state. Once the second parameter data in the designated memory of all second nodes has been set to an invalid state, the first parameter data in the target cache database is set to an active state. Each second node is then notified to retrieve the active first parameter data from the target cache database to replace the second parameter data, and the replaced second parameter data is set to an active state. Thus, during parameter synchronization, data consistency is ensured through state switching. Furthermore, by adding designated memory for storing parameter data to each node in the node cluster, parameter data retrieval can be performed directly by accessing the node's designated memory, eliminating the need for database lookups, table lookups, or cache middleware queries, thereby improving execution efficiency and reducing network overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117520457B_ABST
    Figure CN117520457B_ABST
Patent Text Reader

Abstract

The application provides a parameter synchronization method and device. The method comprises the following steps: obtaining first parameter data to be synchronized, storing the first parameter data to a target cache database, setting a state of the first parameter data as an un-effective state, then determining at least one first node from a node cluster, and determining the first node as a second node in the case that second parameter data matching the first parameter data exists in a set memory of any first node, setting the second parameter data in the set memory of at least one second node as an ineffective state, setting the first parameter data in the target cache database as an effective state in the case that the second parameter data in the set memory of each second node has been set as the ineffective state, then notifying each second node to obtain the first parameter data in the effective state from the target cache database to replace the second parameter data, and setting the replaced second parameter data as the effective state. Thus, the data consistency can be ensured through state switching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a parameter synchronization method and apparatus. Background Technology

[0002] In related technologies, there are business scenarios with many reads and few writes of parameters. For example, in banking, there are parameters like currency type and institution address that change infrequently but are read frequently. For such scenarios, related technologies can employ a multi-level caching architecture to reduce the number of accesses to the target cache and / or database, thus alleviating their access pressure. However, even with a multi-level caching architecture, it's still necessary to ensure that the parameters obtained from accessing different caches are consistent and up-to-date. Therefore, parameter synchronization is required across caches. However, during parameter synchronization, consistency issues may arise; for example, the synchronized parameter data across different caches may be inconsistent. Furthermore, reading parameter data may involve database lookups, table lookups, or cache middleware queries, leading to low execution efficiency and network overhead. Summary of the Invention

[0003] The present invention aims to at least partially solve one of the technical problems in the related art.

[0004] Therefore, the first objective of this invention is to propose a parameter synchronization method to ensure data consistency during parameter synchronization by switching states, and to improve execution efficiency and reduce network overhead by adding a dedicated memory for storing parameter data to each node in the node cluster, so that parameter data can be obtained by directly accessing the node's dedicated memory without querying the database, table, or cache middleware.

[0005] The second objective of this invention is to provide a parameter synchronization device.

[0006] The third objective of this invention is to provide an electronic device.

[0007] The fourth objective of this invention is to provide a computer-readable storage medium.

[0008] The fifth objective of this invention is to provide a computer program product.

[0009] To achieve the above objectives, a first aspect of the present invention proposes a parameter synchronization method, applied to any node in a node cluster, wherein the node is a master node, and each node in the node cluster is additionally provided with a designated memory for storing parameter data, and the parameter data stored in the designated memory of the node all have a first primary key; the method includes:

[0010] The system obtains the first parameter data to be synchronized sent by the parameter platform and stores the first parameter data in the target cache database. The parameter data stored in the target cache database all have a second primary key, and the status of the first parameter data stored in the target cache database is set to an inactive state. The first parameter data is the latest version of the parameter data.

[0011] At least one first node is determined from the node cluster, wherein the first node is an online node;

[0012] For any of the first nodes, based on the comparison result between the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data, it is determined whether there is second parameter data in the designated memory of the first node that matches the first parameter data. If the second parameter data exists in the designated memory of the first node, the first node is determined to be the second node, wherein the second parameter data is the parameter data of the previous version.

[0013] Set the second parameter data in the designated memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an active state when the second parameter data in the designated memory of each second node has been set to an invalid state.

[0014] The second node is notified to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and the replaced second parameter data is set as the effective status.

[0015] To achieve the above objectives, a second aspect of the present invention provides a parameter synchronization device applied to any node in a node cluster, wherein the node is a master node, and each node in the node cluster is additionally provided with a designated memory for storing parameter data, and the parameter data stored in the designated memory of the node all have a first primary key; the device includes:

[0016] The first processing module is used to obtain the first parameter data to be synchronized sent by the parameter platform and store the first parameter data in the target cache database. The parameter data stored in the target cache database all have a second primary key, and the status of the first parameter data stored in the target cache database is set to an inactive state. The first parameter data is the latest version of the parameter data.

[0017] A first determining module is configured to determine at least one first node from the node cluster, wherein the first node is an online node;

[0018] The second processing module is used to determine, for any first node, whether there is second parameter data matching the first parameter data in the set memory of the first node based on the comparison result of the first primary key of the parameter data stored in the set memory of the first node and the second primary key of the first parameter data, and if the second parameter data exists in the set memory of the first node, determine the first node as the second node, wherein the second parameter data is the parameter data of the previous version.

[0019] The third processing module is used to set the second parameter data in the designated memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an effective state when the second parameter data in the designated memory of each second node has been set to an invalid state.

[0020] The fourth processing module is used to notify each of the second nodes to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and to set the replaced second parameter data as the effective status.

[0021] To achieve the above objectives, a third aspect of the present invention provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the parameter synchronization method of the first aspect described above.

[0022] To achieve the above objectives, a fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions for causing the computer to execute the parameter synchronization method of the first aspect.

[0023] To achieve the above objectives, a fifth aspect of the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the parameter synchronization method of the first aspect described above.

[0024] The technical solutions provided by the embodiments of the present invention have the following beneficial effects:

[0025] By acquiring the first parameter data to be synchronized, the first parameter data is stored in the target cache database and set to an inactive state. Then, at least one first node is determined from the node cluster. If second parameter data matching the number of first parameters exists in the designated memory of any first node, that first node is designated as a second node, and the second parameter data in the designated memory of at least one second node is set to an invalid state. Once the second parameter data in the designated memory of all second nodes has been set to an invalid state, the first parameter data in the target cache database is set to an active state. Each second node is then notified to retrieve the active first parameter data from the target cache database to replace the second parameter data, and the replaced second parameter data is set to an active state. Thus, during parameter synchronization, data consistency is ensured through state switching. Furthermore, by adding designated memory for storing parameter data to each node in the node cluster, parameter data retrieval can be performed directly by accessing the node's designated memory, eliminating the need for database lookups, table lookups, or cache middleware queries, thereby improving execution efficiency and reducing network overhead.

[0026] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0027] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:

[0028] Figure 1 This is a flowchart illustrating a parameter synchronization method provided in an embodiment of the present invention;

[0029] Figure 2 This is a schematic diagram illustrating parameter acquisition in a specific scenario according to an embodiment of the present invention.

[0030] Figure 3 This is a schematic diagram illustrating how, in a scenario provided by an embodiment of the present invention, the master node of a node cluster sets the second parameter data in the memory of a second node to an invalid state.

[0031] Figure 4 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention;

[0032] Figure 5 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention;

[0033] Figure 6 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention;

[0034] Figure 7 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention;

[0035] Figure 8 This is a flowchart illustrating a parameter synchronization method in a given scenario, as provided in an embodiment of the present invention.

[0036] Figure 9 This is a schematic diagram of the structure of a parameter synchronization device provided in an embodiment of the present invention;

[0037] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0038] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0039] The parameter synchronization method and apparatus of the present invention are described below with reference to the accompanying drawings.

[0040] Figure 1 This is a flowchart illustrating a parameter synchronization method provided in an embodiment of the present invention.

[0041] It should be noted that the parameter synchronization method in this embodiment is applied to any node in the node cluster, and this node is the master node. Each node in the node cluster is equipped with a set memory for storing parameter data, and the parameter data stored in the node's set memory all have a first primary key.

[0042] like Figure 1 As shown, the parameter synchronization method includes the following steps:

[0043] Step 101: Obtain the first parameter data to be synchronized sent by the parameter platform, and store the first parameter data in the target cache database.

[0044] The parameter data stored in the target cache database all have a second primary key, and the status of the first parameter data stored in the target cache database is set to inactive. The first parameter data is the latest version of the parameter data.

[0045] The target cache database can be any cache database used to temporarily store parameter data during parameter synchronization to avoid inconsistencies in the parameter data stored in the memory of each node in the node cluster. For example, Redis, etc., are not limited in this embodiment.

[0046] Since parameter data can be temporarily stored in the target cache database during parameter synchronization, when the parameter data in the node's memory is set to an invalid state, i.e., the local parameter data becomes invalid, the parameter data temporarily stored in the target cache database can be used uniformly, thus ensuring data consistency during parameter synchronization.

[0047] In some embodiments, the first parameter data to be synchronized sent by the parameter platform can be obtained, and the obtained first parameter data can be stored in the target cache database. It should be noted that during the process of storing the obtained first parameter data in the target cache database, the status of the first parameter data stored in the target cache can be set to an inactive state. This avoids the situation where, when the target cache database contains both the old first parameter data that is currently in effect and the inactive first parameter data to be synchronized (the first parameter data to be synchronized is used to replace the old first parameter data), directly setting the obtained first parameter data to be synchronized to an active state would cause both the old and new first parameter data to be effective simultaneously.

[0048] As an example, such as Figure 2 As shown, the first parameter data to be synchronized is stored in the parameter platform. The parameter platform can send the first parameter data to be synchronized to the node cluster by sending an HTTP (Hypertext Transfer Protocol) request to the core gateway or publishing an MQ (Message Queue) message to the message middleware. In other words, the parameter platform can send the first parameter data to be synchronized to the node cluster via HTTP or message consumption. Therefore, the master node of the node cluster can obtain the first parameter data to be synchronized sent by the parameter platform.

[0049] It should be noted that this invention employs a multi-level caching architecture (defined memory for nodes in the node cluster - target cache database - database corresponding to the node cluster) to reduce the number of accesses to the target cache database and / or the database corresponding to the node cluster, thereby alleviating the access pressure on the target cache database and / or the database corresponding to the node cluster. The database corresponding to the node cluster can be the same database for all nodes in the node cluster (no database sharding), or each node in the node cluster can have its own database (database sharding), or some nodes in the node cluster can have a single database (database sharding), etc. This invention does not impose any limitations on this. Optionally, the database corresponding to the node cluster can be a relational database, such as MySQL Database, Oracle Database, etc. Therefore, after receiving parameter data sent by the parameter platform and registering the parameter data in the database corresponding to the node cluster, the node cluster can send execution results back to the parameter platform. HTTP-based execution result feedback is synchronous; if it fails, it waits for a retry. Message consumption-based execution result feedback is asynchronous; that is, the parameter platform publishes a message, the node cluster consumes the message, registers it in the database, and publishes a success or failure feedback message.

[0050] Step 102: Identify at least one first node from the node cluster.

[0051] In some embodiments, the master node in a node cluster can determine at least one first node from the node cluster based on whether at least one node other than the master node is online. The first node is an online node.

[0052] Step 103: For any first node, based on the comparison result of the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data, determine whether there is second parameter data in the designated memory of the first node that matches the first parameter data, and if there is second parameter data in the designated memory of the first node, determine the first node as the second node.

[0053] In related technologies, without a multi-level caching architecture, when retrieving parameter data, the cache middleware (i.e., the target cache database in this invention) is accessed first. If the data is not found in the cache middleware, the database (i.e., the database corresponding to the node cluster) is accessed, and the parameter data is obtained by querying the database and tables. However, in this process, input / output and / or network bandwidth bottlenecks can easily lead to excessively long parameter data reading times, low query efficiency, and high network overhead. To solve this problem, this invention adopts a multi-level caching architecture. By adding a layer of dedicated memory, the query order for retrieving parameter data is: first query the dedicated memory, then query the cache middleware (target cache database), and finally query the database (the database corresponding to the node cluster). Therefore, parameter data can be directly retrieved by querying the dedicated memory, reducing network overhead and improving query efficiency.

[0054] The memory can be any memory used for local data storage, such as JVM (Java Virtual Machine) memory, etc., and this embodiment does not impose any restrictions on it.

[0055] It should be noted that each node in the node cluster has its own set memory. Therefore, when using parameter data, each node can directly query the corresponding set memory to obtain the parameter data, without having to query the database, table, or cache middleware, which improves execution efficiency and reduces network overhead.

[0056] In some embodiments, since the parameter data stored in the designated memory of a node all have a first primary key, and the parameter data stored in the target cache database all have a second primary key, the master node in the node cluster can, for any first node, determine whether there is second parameter data in the designated memory of the first node that matches the first parameter data based on the comparison result between the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data. Then, if the second parameter data exists in the designated memory of any first node, that first node is determined to be a second node. Here, the second parameter data is the parameter data from the previous version.

[0057] Optionally, the memory of any first node may contain second parameter data that matches the first parameter data, or it may not contain second parameter data that matches the first parameter data. This embodiment does not impose any restrictions on this.

[0058] It should be noted that matching the second parameter data with the first parameter data does not mean that they are the same. The first parameter data is the parameter data of the latest version, while the second parameter data is the parameter data of the previous version. They are different.

[0059] Optionally, the parameter data in the target cache database and the set memory of each node in the node cluster can be stored in the form of a primary key-value pair, so that the parameter data stored in the target cache database and the parameter data stored in the set memory of any node in the node cluster have a primary key for unique identification.

[0060] Step 104: Set the second parameter data in the setting memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an active state when the second parameter data in the setting memory of each second node has been set to an invalid state.

[0061] In some embodiments, since the first parameter data is the latest version of parameter data and the second parameter data is the previous version of parameter data, the existence of the second parameter data in the setting memory of the second node means that the setting memory of the second node stores the parameter data of the previous version. At this time, since it is necessary to synchronize the first parameter data (the latest version of parameter data) temporarily stored in the target cache database to the setting memory of the second node, in order to avoid the previous version of parameter data and the latest version of parameter data in the setting memory of the second node being effective at the same time, it is necessary to first set the second parameter data (the previous version of parameter data) stored in the setting memory of the second node to an invalid state.

[0062] It should be noted that since the number of second nodes is at least one, that is, the number of second nodes is one or more, when the number of second nodes is one, if the second parameter data in the setting memory of the second node has been set to invalid, the first parameter data in the target cache database can be set to effective; when the number of second nodes is multiple, the first parameter data in the target cache database can only be set to effective when the second parameter data in the setting memory of all these multiple second nodes has been set to invalid.

[0063] It should be noted that during the process of setting the second parameter data of multiple second nodes to an invalid state, there may be a situation where some second nodes are successfully set to an invalid state while others fail to do so. In this case, for the second nodes that failed to set to an invalid state, the invalid state can be reset until it is successful.

[0064] It should be noted that the target cache database may contain third parameter data in an effective state that matches the first parameter data. This third parameter data is the parameter data of the previous version stored in the target cache database. In this case, the target cache database simultaneously contains the parameter data of the previous version that is currently in effect (the third parameter data) and the parameter data of the latest version that is ineffective and awaiting synchronization (the first parameter data). The parameter data of the latest version that is ineffective and awaiting synchronization is used to replace the parameter data of the previous version that is currently in effect (the first parameter data is used to replace the third parameter data). If the node's configuration memory stores second parameter data that matches the first parameter data, since the second parameter data is the parameter data of the previous version, the second parameter data stored in the node's configuration memory is the same as the third parameter data stored in the target cache database. Therefore, during parameter synchronization, when some nodes successfully set the failure state while others fail, the nodes that successfully set the failure state can use the parameter data temporarily stored in the target cache database (since the first parameter data is inactive, the node that successfully set the failure state uses the parameter data of the previous version that is currently in effect stored in the target cache database, i.e., the third parameter data). The nodes that failed to set the failure state use the parameter data in their setting memory (since the node's setting memory stores the second parameter data, and the second parameter data stored in the node's setting memory is the same as the third parameter data stored in the target cache database, the node that failed to set the failure state uses the same parameter data as the node that failed to set the failure state). Thus, regardless of whether a node successfully sets the failure state, the parameter data it uses is consistent, effectively ensuring data consistency during parameter synchronization.

[0065] As an example, such as Figure 3As shown, assume the node cluster includes node 1, node 2, ..., node 5. The target cache database simultaneously stores the parameter data of the previous version that is currently in effect (third parameter data) and the parameter data of the latest version that is not yet in effect and is yet to be synchronized (first parameter data). The master node is node 1. The memory of nodes 2, 3, 4 and 5 all stores second parameter data that matches the first parameter data. The second parameter data is the parameter data of the previous version. If node 1 fails to set the second parameter data in node 2's memory to a failed state, but succeeds in setting the second parameter data in nodes 3, 4, and 5's memory to a failed state, then because the active previous version of parameter data (second parameter data) stored in the memory of nodes 3, 4, and 5 is in an invalid state, to ensure data consistency and continuity, nodes 3, 4, and 5 can use the active previous version of parameter data (third parameter data) temporarily stored in the target cache database. Since the active previous version of parameter data (second parameter data) stored in node 2's memory has not been successfully set to an invalid state, node 2 can continue to use the active previous version of parameter data (second parameter data) stored in its memory. Because the second parameter data stored in the node's memory is the same as the third parameter data stored in the target cache database, regardless of whether the node successfully sets the invalid state, the parameter data it uses is consistent, effectively ensuring data consistency during parameter synchronization.

[0066] It should be noted that since the first parameter data is the latest version of the parameter data, if the target cache database contains third parameter data with an effective state that matches the first parameter data, where the third parameter data is the parameter data of the previous version stored in the target cache database, then the third parameter data needs to be cleaned before setting the first parameter data in the target cache database to an effective state. This is to avoid the situation where the first parameter data (the parameter data of the previous version) is set to an effective state directly without the third parameter data (the parameter data of the previous version) being cleaned up, resulting in both the old and new parameter data being effective at the same time.

[0067] Step 105: Notify each second node to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and set the replaced second parameter data as the effective status.

[0068] In some embodiments, after the master node in the node cluster sets the first parameter data in the target cache database to an effective state, it can notify each second node to retrieve the first parameter data in an effective state from the target cache database to replace the second parameter data. At this time, although the second parameter data has been replaced with the first parameter data in an effective state to be synchronized, since the second parameter data has been set to an invalid state before, the replaced second parameter data is also in an invalid state. Therefore, it is necessary to set the replaced second parameter data to an effective state to complete the parameter synchronization of each second node.

[0069] The parameter synchronization method provided in this embodiment obtains the first parameter data to be synchronized, stores the first parameter data in a target cache database, and sets its state to inactive. Then, it determines at least one first node from the node cluster. If second parameter data matching the number of first parameters exists in the designated memory of any first node, this first node is determined as a second node, and the second parameter data in the designated memory of at least one second node is set to inactive. Once the second parameter data in the designated memory of all second nodes has been set to inactive, the first parameter data in the target cache database is set to active. Each second node is then notified to retrieve the active first parameter data from the target cache database to replace the second parameter data, and the replaced second parameter data is set to active. Therefore, during parameter synchronization, data consistency is ensured through state switching. Furthermore, by adding designated memory for storing parameter data to each node in the node cluster, parameter data retrieval can be performed directly by accessing the node's designated memory, eliminating the need for database lookups, table lookups, or cache middleware lookups, thus improving execution efficiency and reducing network overhead.

[0070] To clearly illustrate the previous embodiment, this embodiment provides another parameter synchronization method. Figure 4 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention.

[0071] Similarly, the parameter synchronization method in this embodiment is applied to any node in the node cluster, and that node is the master node. Each node in the node cluster is provided with a set memory for storing parameter data, and the parameter data stored in the node's set memory all have a first primary key.

[0072] like Figure 4 As shown, the parameter synchronization method includes the following steps:

[0073] Step 401: Obtain the first parameter data to be synchronized sent by the parameter platform, and store the first parameter data in the target cache database.

[0074] Step 402: Identify at least one first node from the node cluster.

[0075] It should be noted that the execution process of steps 401-402 can be referred to steps 101-102 in the previous embodiment, as the principle is the same, and will not be repeated here.

[0076] Step 403: For any first node, compare the first primary key of the parameter data stored in the designated memory of the first node with the second primary key of the first parameter data.

[0077] In some embodiments, since the parameter data stored in the designated memory of the node all have a first primary key and the parameter data stored in the target cache database all have a second primary key, the master node in the node cluster can compare the first primary key of the parameter data stored in the designated memory of the first node with the second primary key of the first parameter data for any first node.

[0078] It should be noted that the other execution processes in this step can be referred to step 103 in the previous embodiment, and the principle is the same, so they will not be repeated here.

[0079] Step 4041: If the first primary key of any parameter data stored in the designated memory of the first node is consistent with the second primary key of the first parameter data, the parameter data is determined to be the second parameter data that matches the first parameter data, and it is determined that there is second parameter data that matches the first parameter data in the designated memory of the first node.

[0080] In some embodiments, if the first primary key of any parameter data in the designated memory of the first node is consistent with the second primary key of the first parameter data, then the parameter data can be determined as the second parameter data that matches the first parameter data, and it can also be determined that the designated memory of the first node contains second parameter data that matches the first parameter data.

[0081] Step 4042: If the second parameter data exists in the memory of the first node, then the first node is determined to be the second node.

[0082] The number of second nodes can be one or more, and this embodiment does not limit this.

[0083] Step 4051: If the first primary key of any parameter data stored in the designated memory of the first node is not consistent with the second primary key of the first parameter data, determine that there is no second parameter data in the designated memory of the first node that matches the first parameter data.

[0084] In some embodiments, if the first primary key of all parameter data in the set memory of the first node is not consistent with the second primary key of the first parameter data, it can be determined that there is no second parameter data in the set memory of the first node that matches the first parameter data.

[0085] Step 4052: If there is no second parameter data matching the first parameter data in the memory of the first node, determine the first node as the third node.

[0086] Similarly, the number of second nodes can be one or more, and this embodiment does not limit this.

[0087] Therefore, it is easy to see that the first node includes the second node and / or the third node.

[0088] Step 4061: If the first node includes at least one second node, set the second parameter data in the setting memory of at least one second node to an invalid state.

[0089] It should be noted that the first node including at least one second node includes the following two situations: 1. At least one first node has second parameter data matching the first parameter data in its set memory, and at least one first node is a second node; 2. There are multiple first nodes, some first nodes have second parameter data matching the first parameter data in their set memory, and some first nodes do not have second parameter data matching the first parameter data in their set memory, that is, some first nodes are second nodes and some second nodes are third nodes.

[0090] It should be noted that the execution process of this step can be referred to step 104 in the previous embodiment, as the principle is the same, and will not be repeated here.

[0091] Step 4062: Compare the second primary key of the effective status parameter data stored in the target cache database with the second primary key of the first parameter data to determine whether there is a third parameter data of effective status in the target cache database that matches the first parameter data.

[0092] The third parameter data is the parameter data of the previous version stored in the target cache database.

[0093] As can be seen from the above analysis, the target cache database may contain parameter data of the previous version that is currently in effect. Therefore, in some embodiments, the second primary key of the parameter data in effect stored in the target cache database can be compared with the second primary key of the first parameter data to determine whether there is third parameter data in effect in the target cache database that matches the first parameter data.

[0094] Similarly, matching the third parameter data with the first parameter data does not mean that they are the same. The first parameter data is the parameter data of the latest version, while the third parameter data is the parameter data of the previous version. They are different.

[0095] It should be noted that the third parameter data and the second parameter data are the same parameter data, except that the third parameter data is stored in the target cache database, while the second parameter data is stored in the designated memory of each second node in the node cluster.

[0096] Step 4063: If the third parameter data exists in the target cache database, delete the third parameter data.

[0097] Since the first parameter data is the latest version of the parameter data, if there is a third parameter data in the target cache database that is in an effective state matching the first parameter data, where the third parameter data is the parameter data of the previous version stored in the target cache database, the third parameter data needs to be deleted before setting the first parameter data in the target cache database to an effective state. This is to avoid the situation where the first parameter data (the parameter data of the previous version) is set to an effective state directly without the third parameter data (the parameter data of the previous version) being cleared, resulting in both the old and new parameter data being effective at the same time.

[0098] Step 4064: If the second parameter data in the set memory of each second node has been set to invalid state and there is no third parameter data in the target cache database, set the first parameter data in the target cache database to active state.

[0099] In some embodiments, if the first node includes at least one second node, the presence of second parameter data in the configuration memory of the second node implies that the configuration memory of the second node stores parameter data from the previous version. Therefore, the second parameter data stored in the configuration memory of at least one second node needs to be set to an invalid state first. Furthermore, the presence of third parameter data in the target cache database implies that the target cache database stores parameter data from the previous version. Therefore, the third parameter data stored in the target cache database needs to be deleted first. Thus, if the first node includes at least one second node, the first parameter data in the target cache database can only be set to an active state if the second parameter data in the configuration memory of each second node has been set to an invalid state and the target cache database does not contain third parameter data.

[0100] Specifically, when there is only one second node, the first parameter data in the target cache database can only be set to the active state if the second parameter data in the memory of this second node has been set to the invalid state and the third parameter data does not exist in the target cache database; when there are multiple second nodes, the first parameter data in the target cache database can only be set to the active state if the second parameter data in the memory of all these multiple second nodes has been set to the invalid state and the third parameter data does not exist in the target cache database.

[0101] It should be noted that since the first node includes at least one second node, there are two possibilities: 1. At least one first node is a second node; 2. There are multiple first nodes, some of which are second nodes and some of which are third nodes. Therefore, for the case where at least one first node is a second node, as mentioned above, the first parameter data in the target cache database can only be set to an active state if the second parameter data in the designated memory of each second node has been set to an invalid state and the third parameter data does not exist in the target cache database. For the case where there are multiple first nodes, some of which are second nodes and some of which are third nodes, since the second parameter data is not present in the designated memory of the third node, it also means that the second parameter data is not present in the designated memory of the third node. The previous version's parameter data is stored. Therefore, for the third node, it is only necessary to consider whether there is third parameter data in the target cache database that is in an effective state matching the first parameter data. However, for the second node, it is necessary to consider whether the second parameter data in the setting memory of the second node has been set to an invalid state, and whether there is third parameter data in the target cache database that is in an effective state matching the first parameter data. Therefore, as mentioned above, when there are multiple first nodes, some first nodes are second nodes, and some second nodes are third nodes, the first parameter data in the target cache database can only be set to an effective state if the second parameter data in the setting memory of each second node has been set to an invalid state and there is no third parameter data in the target cache database.

[0102] Step 4065: In response to the first node only including the second node, notify each second node to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and set the replaced second parameter data as the effective status.

[0103] Since the first node includes at least one second node, there are two possibilities: 1. At least one first node is a second node; 2. There are multiple first nodes, some of which are second nodes and some of which are third nodes. Therefore, in some embodiments, in response to the first node only including the second node, it is only necessary to notify each second node to obtain the first parameter data of the effective status from the target cache database to replace the second parameter data, and set the replaced second parameter data as the effective status.

[0104] Step 4066: In response to the first node including at least one second node and at least one third node, each second node is notified to retrieve the first parameter data of the effective state from the target cache database to replace the second parameter data, and the replaced second parameter data is set to the effective state; and each third node is notified to retrieve the first parameter data of the effective state from the target cache database and store it in the designated memory of each third node, and the state of the first parameter data stored in the designated memory of each third node is set to the effective state.

[0105] Since the first node includes at least one second node, there are two possibilities: 1. At least one first node is a second node; 2. There are multiple first nodes, some of which are second nodes and some of which are third nodes. Therefore, in some embodiments, in response to the first node including at least one second node and at least one third node, it is necessary to notify each second node to retrieve the first parameter data of the effective state from the target cache database to replace the second parameter data and set the replaced second parameter data to the effective state. It is also necessary to notify each third node to retrieve the first parameter data of the effective state from the target cache database and store it in the designated memory of each third node, and set the state of the first parameter data stored in the designated memory of each third node to the effective state.

[0106] Step 4071: If the first node only includes the third node, compare the second primary key of the parameter data of the effective status stored in the target cache database with the second primary key of the first parameter data to determine whether there is third parameter data of the effective status that matches the first parameter data in the target cache database.

[0107] In some embodiments, since the second parameter data is not present in the setting memory of the third node, it means that the parameter data of the previous version is not stored in the setting memory of the third node. Therefore, for the case where the first node only includes the third node, it is only necessary to consider whether there is third parameter data in the target cache database that matches the effective state of the first parameter data.

[0108] It should be noted that the execution process of this step can be referred to step 4062 in this embodiment, as the principle is the same, and will not be repeated here.

[0109] Step 4072: If the third parameter data exists in the target cache database, delete the third parameter data.

[0110] It should be noted that the execution process of this step can be referred to step 4063 in this embodiment, as the principle is the same, and will not be repeated here.

[0111] Step 4073: If the third parameter data does not exist in the target cache database, set the first parameter data in the target cache database to the active state.

[0112] In some embodiments, if the first node only includes the third node, since the second parameter data is not present in the setting memory of the third node, it means that the parameter data of the previous version is not stored in the setting memory of the third node. Therefore, if the third parameter data is not present in the target cache database, the first parameter data in the target cache can be directly set to the effective state.

[0113] Step 4074: Notify at least one third node to retrieve the first parameter data of the effective state from the target cache database and store it in the designated memory of at least one third node, and set the state of the first parameter data stored in the designated memory of at least one third node to the effective state.

[0114] In some embodiments, if the first node only includes the third node, then it is only necessary to notify each third node to retrieve the first parameter data of the effective state from the target cache database, store it in the designated memory of each third node, and set the state of the first parameter data stored in the designated memory of each third node to the effective state.

[0115] The parameter synchronization method provided in this embodiment compares the first primary key of the parameter data stored in the designated memory of the first node with the second primary key of the first parameter data for any first node. If the first primary key of any parameter data stored in the designated memory of the first node matches the second primary key, the parameter data is determined to be the second parameter data matching the first parameter data, and it is determined that the designated memory of the first node contains the second parameter data matching the first parameter data. Alternatively, if the first primary key of any parameter data stored in the designated memory of the first node does not match the second primary key of the first parameter data, it is determined that the designated memory of the first node does not contain the second parameter data matching the first parameter data. Then, if the second parameter data exists in the designated memory of the first node, the first node is determined to be the second node; or, if the designated memory of the first node does not contain the second parameter data matching the first parameter data, the first node is determined to be the third node. Subsequently, if the first node includes at least one second node, the second parameter data in the designated memory of at least one second node is set to an invalid state, and the second primary key of the parameter data in the effective state stored in the target cache database is compared with the second primary key of the first parameter data to determine whether there is third parameter data in the target cache database that is in an effective state matching the first parameter data. If the third parameter data exists in the target cache database, the third parameter data is deleted. If the second parameter data in the designated memory of each second node has been set to an invalid state and there is no third parameter data in the target cache database, the first parameter data in the target cache database is set to an effective state. In response to a first node comprising only a second node, the system notifies each second node to retrieve the first parameter data of the effective state from the target cache database to replace the second parameter data, and sets the replaced second parameter data to the effective state. Alternatively, in response to a first node comprising at least one second node and at least one third node, the system notifies each second node to retrieve the first parameter data of the effective state from the target cache database to replace the second parameter data, and sets the replaced second parameter data to the effective state. The system also notifies each third node to retrieve the first parameter data of the effective state from the target cache database and store it in the designated memory of each third node, and sets the state of the first parameter data stored in the designated memory of each third node to the effective state.Alternatively, if the first node only includes a third node, the second primary key of the parameter data in the target cache database that is in effect is compared with the second primary key of the first parameter data to determine whether there is third parameter data in the target cache database that is in effect and matches the first parameter data. If the third parameter data exists in the target cache database, it is deleted; if it does not exist, the first parameter data in the target cache database is set to in effect. This notifies at least one third node to retrieve the first parameter data in effect from the target cache database and store it in a designated memory location on at least one third node, setting the status of the first parameter data stored in the designated memory location on at least one third node to in effect. This allows the first parameter data to be synchronized to at least one second node and / or at least one third node's designated memory. Simultaneously, it avoids the third parameter data and the first parameter data in the target cache database from becoming effective simultaneously.

[0116] To clearly illustrate how multiple first nodes are determined from a node cluster in this invention, this embodiment provides another parameter synchronization method. Figure 5 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention.

[0117] Similarly, the parameter synchronization method in this embodiment is applied to any node in the node cluster, and this node is the master node. Each node in the node cluster is additionally provided with a set memory for storing parameter data, and the parameter data stored in the node's set memory all have a first primary key.

[0118] like Figure 5 As shown, the parameter synchronization method includes the following steps:

[0119] Step 501: In response to the master node startup, obtain the service list from the registry center.

[0120] The service list is used to record information about the nodes that provide services.

[0121] Step 502: Store the service list locally, and update the locally stored service list when the set conditions are met.

[0122] The set conditions include at least one of the following: every first set interval; in response to a new node coming online; in response to a node going offline in the service list.

[0123] The first set duration can be any duration; that is, the present invention does not limit the setting of the first set duration. Optionally, the first set duration can be set based on human experience, for example, it can be set to 30 seconds. Alternatively, the first set duration can be dynamically adjusted according to actual application needs; this embodiment does not limit this.

[0124] Because the service list stored locally can be updated under certain conditions, the accuracy of the service list is effectively guaranteed.

[0125] It should be noted that in this invention, any node in the node cluster can obtain the service list from the registry center when the node starts up, store the service list locally, and update the locally stored service list when the set conditions are met.

[0126] As an example, the service list is stored locally. When a node starts up, it retrieves the service list from the registry center and notifies other nodes of the new node's arrival. Other nodes also update their stored service lists synchronously. Furthermore, nodes automatically update their service lists every 30 seconds. Additionally, nodes clear their locally stored service lists when they detect failures. This ensures the consistency of the service list.

[0127] Step 503: Obtain the first parameter data to be synchronized sent by the parameter platform, and store the first parameter data in the target cache database.

[0128] It should be noted that the execution process of this step can be referred to step 101 in the above embodiment, and the principle is the same, so it will not be repeated here.

[0129] Step 504: Check whether at least one node in the node cluster other than the master node is online, so that if any node is online, the node is determined as the first node.

[0130] In this embodiment, the node cluster includes multiple nodes. When the master node in the node cluster determines multiple first nodes from the node cluster, it can check whether at least one node in the node cluster other than the master node is online, so that if any node is online, that node is determined as the first node.

[0131] Optionally, a message can be sent to at least one node in the node cluster recorded in the service list, excluding the master node. Thus, if a response message is received from any node in the node cluster other than the master node, it can be determined that the node is online.

[0132] Step 505: For any first node, based on the comparison result of the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data, determine whether there is second parameter data in the designated memory of the first node that matches the first parameter data, and if there is second parameter data in the designated memory of the first node, determine the first node as the second node.

[0133] Step 506: Set the second parameter data in the setting memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an active state when the second parameter data in the setting memory of each second node has been set to an invalid state.

[0134] Step 507: Notify each second node to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and set the replaced second parameter data as the effective status.

[0135] It should be noted that the execution process of steps 505-507 can be referred to steps 103-105 in the above embodiment, as the principle is the same, and will not be repeated here.

[0136] The parameter synchronization method provided in this embodiment can, in response to the startup of the master node, obtain a service list from the registry center, store the service list locally, and update the locally stored service list when set conditions are met. Furthermore, when checking whether at least one node in the node cluster other than the master node is online, it can determine whether a node is online by sending a message to at least one node in the node cluster other than the master node recorded in the service list. If any node is online, that node is identified as the first node. Therefore, even when the node cluster includes multiple nodes, multiple first nodes can be determined from the node cluster based on whether each node is online.

[0137] In this invention, there may also be cases where synchronization fails, which will be discussed below. Figure 6 This process will be explained.

[0138] Figure 6 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention.

[0139] Similarly, the parameter synchronization method in this embodiment is applied to any node in the node cluster, and this node is the master node. Each node in the node cluster is additionally provided with a set memory for storing parameter data, and the parameter data stored in the node's set memory all have a first primary key.

[0140] like Figure 6 As shown, the parameter synchronization method includes the following steps:

[0141] Step 601: Obtain the first parameter data to be synchronized sent by the parameter platform, and store the first parameter data in the target cache database.

[0142] Step 602: Identify at least one first node from the node cluster.

[0143] Step 603: For any first node, based on the comparison result of the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data, determine whether there is second parameter data in the designated memory of the first node that matches the first parameter data, and if there is second parameter data in the designated memory of the first node, determine the first node as the second node.

[0144] Step 604: Set the second parameter data in the setting memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an active state when the second parameter data in the setting memory of each second node has been set to an invalid state.

[0145] Step 605: Notify each second node to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and set the replaced second parameter data as the effective status.

[0146] It should be noted that the execution process of steps 601-605 can be referred to steps 101-105 in the above embodiment, as the principle is the same, and will not be repeated here.

[0147] Step 606: In response to the fact that the first parameter data has been stored in the target cache database for a period of time exceeding the second set time, the synchronization is determined to have failed, and the first parameter data is deleted from the target cache database.

[0148] In some embodiments, if the duration for which the first parameter data is stored in the target cache database exceeds a second preset duration, synchronization failure can be determined, and the first parameter data can be deleted from the target cache database. The second preset duration can be any duration; that is, this embodiment of the invention does not limit the setting of the second preset duration. Optionally, the second preset duration can be set based on human experience; for example, it can be set to 2 minutes. Alternatively, the second preset duration can be dynamically adjusted according to actual application needs; this embodiment does not limit this.

[0149] Optionally, while setting the status of the first parameter data stored in the target cache to an inactive state, a second set duration can be set. If the second set duration is exceeded, it means that the synchronization has failed and the data will be automatically cleaned up.

[0150] The parameter synchronization method provided in this embodiment can also determine synchronization failure and delete the first parameter data from the target cache database if the first parameter data has been stored in the target cache database for a period exceeding a second preset time. This avoids the impact of long synchronization times on subsequent synchronization operations.

[0151] In this invention, in addition to synchronizing the first parameter data to be synchronized to the designated memory of multiple second nodes and / or at least one third node, the first parameter data to be synchronized can also be synchronized to the master node. The following describes how... Figure 7 This process will be explained.

[0152] Figure 7 This is a flowchart illustrating another parameter synchronization method provided in an embodiment of the present invention.

[0153] Similarly, the parameter synchronization method in this embodiment is applied to any node in the node cluster, and this node is the master node. Each node in the node cluster is additionally provided with a set memory for storing parameter data, and the parameter data stored in the node's set memory all have a first primary key.

[0154] like Figure 7 As shown, the parameter synchronization method includes the following steps:

[0155] Step 701: Obtain the first parameter data to be synchronized sent by the parameter platform, and store the first parameter data in the target cache database.

[0156] Step 702: Identify at least one first node from the node cluster.

[0157] Step 703: For any first node, based on the comparison result of the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data, determine whether there is second parameter data in the designated memory of the first node that matches the first parameter data, and if there is second parameter data in the designated memory of the first node, determine the first node as the second node.

[0158] Step 704: Set the second parameter data in the setting memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an active state when the second parameter data in the setting memory of each second node has been set to an invalid state.

[0159] Step 705: Notify each second node to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and set the replaced second parameter data as the effective status.

[0160] It should be noted that the execution process of steps 701-705 can be referred to steps 101-105 in the above embodiment, as the principle is the same, and will not be repeated here.

[0161] Step 706: Synchronize the first parameter data to the master node.

[0162] In some embodiments, the first parameter data can be synchronized to the master node after the synchronization of other nodes in the node cluster (other nodes besides the master node) is completed.

[0163] Optionally, if a fourth parameter matching the first parameter exists in the master node's designated memory, the fourth parameter can be set to an invalid state. Then, the first parameter can be used to replace the fourth parameter, and the replaced fourth parameter can be set to an active state. Alternatively, if a fourth parameter matching the first parameter does not exist in the master node's designated memory, the first parameter can be directly stored in the master node's designated memory, and the stored first parameter can be set to an active state.

[0164] The parameter synchronization method provided in this embodiment also synchronizes the first parameter data to the master node. This ensures that all nodes in the node cluster complete parameter synchronization.

[0165] To clearly illustrate the above embodiments, examples are given below.

[0166] Figure 8 This is a flowchart illustrating a parameter synchronization method in a given scenario, as provided in an embodiment of the present invention.

[0167] like Figure 8 As shown, the parameter platform can communicate with the node cluster via HTTP or message consumption, sending the parameter data to be synchronized to the master node of the node cluster. After receiving the parameter data, the master node registers it in its local database and sends back the execution result (returning an HTTP request or a publication receipt).

[0168] Next, the master node temporarily stores the parameter data to be synchronized in Redis (target cache) and sets it to an inactive state. An expiration time (a second set duration) can be set; if the timeout occurs, synchronization fails and the data is automatically cleaned up. Then, the master node retrieves the service list, which allows it to obtain node status information from the registry. The service list is stored locally and retrieved from the registry when a service starts, simultaneously notifying other nodes of the new node's arrival. Other nodes will also synchronize and update their service lists, with automatic updates every 30 seconds. Next, the master node checks if each node in the cluster is online. If it is offline, it retryes. If it is online, it sets the node's JVM memory data to an invalid state (setting the data under the same key in the JVM of the online node in the cluster to "invalid" (both Redis and JVM store data as key-value pairs)), and synchronously updates other nodes in the cluster. Then, it sets the Redis data to an effective state (if old data exists in Redis (the key is the same as the key of the parameter data to be synchronized), the old Redis data needs to be cleaned up first, and then the parameter data to be synchronized in Redis needs to be set to "effective"). This notifies the nodes to retrieve the Redis data and activates the JVM memory data (notifying the online nodes in the cluster to retrieve the parameter data to be synchronized in Redis and setting the data under the same key in the JVM to "effective" (previously set to "invalid", here it needs to be changed from "invalid" to "effective" after replacing the data), and synchronously updates other nodes in the cluster.

[0169] Therefore, when parameters are synchronized to cluster nodes, if node data fails, data is retrieved from the central storage (Redis) to ensure data consistency during the synchronization process. Simultaneously, data storage employs a combination of local and central storage, with synchronization using state switching to switch between local and central storage. This enables synchronous or asynchronous communication between the parameter platform and the node cluster. The master node of the node cluster retrieves and synchronizes parameter information from the parameter platform. Thus, when using configuration parameter information, there's no longer a need to query databases, tables, or cached middleware as in traditional methods; instead, the information is retrieved directly locally, significantly improving execution efficiency.

[0170] To achieve the above embodiments, the present invention also proposes a parameter synchronization device.

[0171] Figure 9 This is a schematic diagram of a parameter synchronization device provided in an embodiment of the present invention.

[0172] It should be noted that the parameter synchronization device in this embodiment is applied to any node in the node cluster, and this node is the master node. Each node in the node cluster is additionally equipped with a setting memory for storing parameter data, and the parameter data stored in the setting memory of the node all have a first primary key.

[0173] like Figure 9 As shown, the parameter synchronization device includes: a first processing module 11, a first determining module 12, a second processing module 13, a third processing module 14, and a fourth processing module 15.

[0174] The first processing module 11 is used to obtain the first parameter data to be synchronized sent by the parameter platform and store the first parameter data in the target cache database. The parameter data stored in the target cache database all have a second primary key, and the status of the first parameter data stored in the target cache database is set to an inactive state. The first parameter data is the latest version of the parameter data.

[0175] The first determining module 12 is used to determine at least one first node from the node cluster, wherein the first node is an online node;

[0176] The second processing module 13 is used to determine, for any first node, whether there is second parameter data matching the first parameter data in the set memory of the first node based on the comparison result of the first primary key of the parameter data stored in the set memory of the first node and the second primary key of the first parameter data, and if the second parameter data exists in the set memory of the first node, determine the first node as the second node, wherein the second parameter data is the parameter data of the previous version.

[0177] The third processing module 14 is used to set the second parameter data in the set memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an effective state when the second parameter data in the set memory of each second node has been set to an invalid state.

[0178] The fourth processing module 15 is used to notify each of the second nodes to obtain the first parameter data of the effective status from the target cache database to replace the second parameter data, and to set the replaced second parameter data as the effective status.

[0179] Furthermore, in one possible implementation of this invention, the second processing module 13 is further configured to:

[0180] For any of the first nodes, the first primary key of the parameter data stored in the designated memory of the first node is compared with the second primary key of the first parameter data;

[0181] If the first primary key of any parameter data stored in the designated memory of the first node is consistent with the second primary key of the first parameter data, the parameter data is determined to be the second parameter data that matches the first parameter data, and it is determined that there is second parameter data that matches the first parameter data in the designated memory of the first node.

[0182] If the first primary key of any parameter data stored in the designated memory of the first node is not consistent with the second primary key of the first parameter data, it is determined that there is no second parameter data in the designated memory of the first node that matches the first parameter data.

[0183] Furthermore, in one possible implementation of the present invention, the above-described apparatus further includes:

[0184] The second determining module is used to determine the first node as the third node if there is no second parameter data matching the first parameter data in the designated memory of the first node.

[0185] Furthermore, in one possible implementation of this invention, the first node includes the second node and / or the third node, and the third processing module 14 is further configured to:

[0186] When the first node includes at least one second node, the second parameter data in the set memory of at least one second node is set to an invalid state, and when the second parameter data in the set memory of each second node has been set to an invalid state, the first parameter data in the target cache database is set to an active state.

[0187] If the first node only includes the third node, the first parameter data in the target cache database is set to an active state.

[0188] Furthermore, in one possible implementation of the present invention, the above-described apparatus further includes:

[0189] The fifth processing module is configured to, when the first node includes at least one of the third nodes, notify at least one of the third nodes to retrieve the first parameter data of the effective state from the target cache database and store it in the designated memory of at least one of the third nodes, and set the state of the first parameter data stored in the designated memory of at least one of the third nodes to the effective state.

[0190] Furthermore, in one possible implementation of the present invention, the above-described apparatus further includes:

[0191] The comparison module is used to compare the second primary key of the effective status parameter data stored in the target cache database with the second primary key of the first parameter data to determine whether there is a third parameter data in the target cache database that matches the first parameter data, wherein the third parameter data is the parameter data of the previous version stored in the target cache database;

[0192] The deletion module is used to delete the third parameter data if the third parameter data exists in the target cache database.

[0193] Furthermore, in one possible implementation of this invention, the third processing module 14 is further configured to:

[0194] In response to the first node including at least one second node, if the second parameter data in the designated memory of each second node has been set to an invalid state, and the third parameter data does not exist in the target cache database, the first parameter data in the target cache database is set to an active state.

[0195] Furthermore, in one possible implementation of this invention, the third processing module 14 is further configured to:

[0196] In response to the first node including only the third node, if the third parameter data does not exist in the target cache database, the first parameter data in the target cache database is set to an active state.

[0197] Furthermore, in one possible implementation of this embodiment of the invention, the node cluster includes multiple nodes, wherein any one node is the master node, and the first determining module 12 is further configured to:

[0198] In response to the startup of the master node, a service list is obtained from the registry center, wherein the service list is used to record node information that provides services;

[0199] The service list is stored locally, and the locally stored service list is updated when certain conditions are met, wherein the conditions include at least one of the following: every first set interval; in response to a new node coming online; in response to a node going offline in the service list;

[0200] Send a message to at least one node in the node cluster recorded in the service list, excluding the master node;

[0201] Upon receiving a response message from any node in the node cluster other than the master node, the node is determined to be online and identified as the first node.

[0202] Furthermore, in one possible implementation of the present invention, the above-described apparatus further includes:

[0203] The sixth processing module is configured to, in response to the first parameter data being stored in the target cache database for a duration exceeding a second preset duration, determine that synchronization has failed and delete the first parameter data from the target cache database; or,

[0204] If a fourth parameter data matching the first parameter data exists in the designated memory of the master node, the fourth parameter data is set to an invalid state, the fourth parameter data is replaced with the first parameter data, and the replaced fourth parameter data is set to an active state; if no fourth parameter data matching the first parameter data exists in the designated memory of the master node, the first parameter data is stored in the designated memory of the master node, and the status of the first parameter data stored in the designated memory of the master node is set to an active state.

[0205] It should be noted that the foregoing explanation of the parameter synchronization method embodiment also applies to the parameter synchronization device of this embodiment, and will not be repeated here.

[0206] The parameter synchronization device provided in this embodiment acquires the first parameter data to be synchronized, stores the first parameter data in a target cache database, and sets its state to inactive. Then, it determines at least one first node from the node cluster. If second parameter data matching the number of first parameters exists in the designated memory of any first node, that first node is determined as a second node, and the second parameter data in the designated memory of at least one second node is set to inactive. Once the second parameter data in the designated memory of all second nodes has been set to inactive, the first parameter data in the target cache database is set to active. Each second node is then notified to retrieve the active first parameter data from the target cache database to replace the second parameter data, and the replaced second parameter data is set to active. Therefore, during parameter synchronization, data consistency is ensured through state switching. Furthermore, by adding designated memory for each node in the node cluster to store parameter data, parameter data retrieval can be performed directly by accessing the node's designated memory, eliminating the need for database lookups, table lookups, or cache middleware queries, thus improving execution efficiency and reducing network overhead.

[0207] To implement the above embodiments, the present invention also proposes an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to execute the parameter synchronization method proposed in any of the above embodiments of the present invention.

[0208] To implement the above embodiments, the present invention also proposes a computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the parameter synchronization method proposed in any of the above embodiments of the present invention.

[0209] To implement the above embodiments, the present invention also proposes a computer program product, including a computer program that, when executed by a processor, implements the parameter synchronization method proposed in any of the above embodiments of the present invention.

[0210] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.

[0211] It should be noted that, Figure 10 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0212] like Figure 10 As shown, the electronic device includes:

[0213] Memory 21, processor 22, and computer program stored on memory 21 and executable on processor 22.

[0214] When processor 22 executes the program, it implements the parameter synchronization method provided in any of the above embodiments.

[0215] Furthermore, electronic devices also include:

[0216] Communication interface 23 is used for communication between memory 21 and processor 22.

[0217] The memory 21 is used to store computer programs that can run on the processor 22.

[0218] The memory 21 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage.

[0219] The processor 22 is used to implement the parameter synchronization method described in any of the above embodiments when executing the program.

[0220] If the memory 21, processor 22, and communication interface 23 are implemented independently, then the communication interface 23, memory 21, and processor 22 can be interconnected via a bus to complete communication between them. 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 address bus, data bus, control bus, etc. For ease of representation, Figure 10 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0221] Optionally, in a specific implementation, if the memory 21, processor 22, and communication interface 23 are integrated on a single chip, then the memory 21, processor 22, and communication interface 23 can communicate with each other through an internal interface.

[0222] Processor 22 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0223] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0224] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0225] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of the invention pertain.

[0226] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0227] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any of the following techniques known in the art, or a combination thereof: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0228] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0229] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0230] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. A parameter synchronization method, characterized in that, The method is applied to any node in a node cluster, wherein the node is the master node, and each node in the node cluster is additionally provided with a designated memory for storing parameter data, and the parameter data stored in the designated memory of the node all have a first primary key; the method includes: The system obtains the first parameter data to be synchronized sent by the parameter platform and stores the first parameter data in the target cache database. The parameter data stored in the target cache database all have a second primary key, and the status of the first parameter data stored in the target cache database is set to an inactive state. The first parameter data is the latest version of the parameter data. At least one first node is determined from the node cluster, wherein the first node is an online node; For any of the first nodes, based on the comparison result between the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data, it is determined whether there is second parameter data in the designated memory of the first node that matches the first parameter data. If the second parameter data exists in the designated memory of the first node, the first node is determined to be the second node, wherein the second parameter data is the parameter data of the previous version. Set the second parameter data in the designated memory of at least one second node to an invalid state, and set the first parameter data in the target cache database to an active state when the second parameter data in the designated memory of each second node has been set to an invalid state. The second node is notified to retrieve the first parameter data of the effective status from the target cache database to replace the second parameter data, and the replaced second parameter data is set as the effective status.

2. The method according to claim 1, characterized in that, For any of the first nodes, determining whether there is second parameter data matching the first parameter data in the designated memory of the first node based on the comparison result between the first primary key of the parameter data stored in the designated memory of the first node and the second primary key of the first parameter data includes: For any of the first nodes, the first primary key of the parameter data stored in the designated memory of the first node is compared with the second primary key of the first parameter data; If the first primary key of any parameter data stored in the designated memory of the first node is consistent with the second primary key of the first parameter data, the parameter data is determined to be the second parameter data that matches the first parameter data, and it is determined that there is second parameter data that matches the first parameter data in the designated memory of the first node. If the first primary key of any parameter data stored in the designated memory of the first node is not consistent with the second primary key of the first parameter data, it is determined that there is no second parameter data in the designated memory of the first node that matches the first parameter data.

3. The method according to claim 1, characterized in that, The method further includes: If there is no second parameter data matching the first parameter data in the designated memory of the first node, the first node is determined to be the third node.

4. The method according to claim 3, characterized in that, The first node includes the second node and / or the third node. Setting the second parameter data in the designated memory of at least one second node to an invalid state, and setting the first parameter data in the target cache database to an active state when the second parameter data in the designated memory of all second nodes has been set to an invalid state, includes: When the first node includes at least one second node, the second parameter data in the set memory of at least one second node is set to an invalid state, and when the second parameter data in the set memory of each second node has been set to an invalid state, the first parameter data in the target cache database is set to an active state. If the first node only includes the third node, the first parameter data in the target cache database is set to an active state.

5. The method according to claim 4, characterized in that, The method further includes: In the case where the first node includes at least one of the third nodes, the first parameter data of the effective state is retrieved from the target cache database and stored in the designated memory of the first third node, and the state of the first parameter data stored in the designated memory of the first third node is set to the effective state.

6. The method according to claim 4, characterized in that, Before setting the first parameter data in the target cache database to an effective state, the method further includes: The second primary key of the parameter data of the effective status stored in the target cache database is compared with the second primary key of the first parameter data to determine whether there is a third parameter data of the effective status that matches the first parameter data in the target cache database, wherein the third parameter data is the parameter data of the previous version stored in the target cache database; If the third parameter data exists in the target cache database, the third parameter data will be deleted.

7. The method according to claim 6, characterized in that, When the first node includes at least one second node, and the second parameter data in the designated memory of each second node has been set to an invalid state, setting the first parameter data in the target cache database to an active state includes: In response to the first node including at least one second node, if the second parameter data in the designated memory of each second node has been set to an invalid state, and the third parameter data does not exist in the target cache database, the first parameter data in the target cache database is set to an active state.

8. The method according to claim 6, characterized in that, When the first node only includes the third node, setting the first parameter data in the target cache database to an active state includes: In response to the first node including only the third node, if the third parameter data does not exist in the target cache database, the first parameter data in the target cache database is set to an active state.

9. The method according to claim 1, characterized in that, The node cluster includes multiple nodes, wherein any one node is the master node, and determining at least one first node from the node cluster includes: In response to the startup of the master node, a service list is obtained from the registry center, wherein the service list is used to record node information that provides services; The service list is stored locally, and the locally stored service list is updated when certain conditions are met, wherein the conditions include at least one of the following: every first set interval; in response to a new node coming online; in response to a node going offline in the service list; Send a message to at least one node in the node cluster recorded in the service list, excluding the master node; Upon receiving a response message from any node in the node cluster other than the master node, the node is determined to be online and identified as the first node.

10. The method according to claim 1, characterized in that, The method further includes: If the duration for which the first parameter data is stored in the target cache database exceeds a second preset duration, a synchronization failure is determined, and the first parameter data is deleted from the target cache database; or... If a fourth parameter data matching the first parameter data exists in the designated memory of the master node, the fourth parameter data is set to an invalid state, the fourth parameter data is replaced with the first parameter data, and the replaced fourth parameter data is set to an active state; if no fourth parameter data matching the first parameter data exists in the designated memory of the master node, the first parameter data is stored in the designated memory of the master node, and the status of the first parameter data stored in the designated memory of the master node is set to an active state.

Citation Information

Patent Citations

  • Method and system for updating indorsement algorithm

    CN101404575A

  • Data reading method, data reading device, computer equipment and storage medium

    CN111190935A