WO2024021746A1 - Data processing method, communication system, and related device - Google Patents
Data processing method, communication system, and related device Download PDFInfo
- Publication number
- WO2024021746A1 WO2024021746A1 PCT/CN2023/092513 CN2023092513W WO2024021746A1 WO 2024021746 A1 WO2024021746 A1 WO 2024021746A1 CN 2023092513 W CN2023092513 W CN 2023092513W WO 2024021746 A1 WO2024021746 A1 WO 2024021746A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- node
- content
- message
- synchronization
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/06—Management of faults, events, alarms or notifications
- H04L41/0654—Management of faults, events, alarms or notifications using network fault recovery
- H04L41/0663—Performing the actions predefined by failover planning, e.g. switching to standby network elements
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
Definitions
- This application relates to the field of communications, and in particular to data processing methods, communications systems and related equipment.
- the function of the distributed lock manager is implemented in the network lock (net lock).
- the lock request initiated by the client is forwarded to the corresponding lock manager via the top-shelf switch to provide lock management services.
- a backup switch is selected to provide services.
- the backup switch does not synchronize data with the top-shelf switch, the original data is lost after the backup switch is started, and the service needs to be provided from scratch, which cannot maintain the system state before the failure, reducing the reliability of the system.
- the present application provides a data processing method, a communication system and related equipment.
- the data processing method applied to the first node includes: the first node modifies the first data into the second data according to the first data modification message of the first client. . Then the first data synchronization message is sent to the second node, so that the second data is synchronized. Then, the second data is processed according to the data synchronization result indicated by the first response information of the second node, and the first target data with the same content as the data in the second node is obtained. Through information exchange between the first node and the second node, data synchronization between the first node and the second node is achieved. Even if one node fails, the other node can continue to provide services, which improves the reliability of the system.
- the first aspect of this application provides a data processing method, which is applied to the first node and includes:
- the first node and the second node can also perform role assignment. If the first node is the master node, then the second node is the backup node; accordingly, if the second node is the master node, then the second node is the backup node. The second node is the backup node.
- the first node establishes a communication connection with the first client and can obtain a first data modification message from the first client.
- the first data modification message indicates modification of the first data stored in the first node. After obtaining the first data modification message, the first node will modify the first data into the second data according to the first data modification message, and send a first data synchronization message to the second node.
- the first data synchronization message indicates The second node performs data synchronization, and the first data synchronization message corresponds to the second data. That is to say, the second node determines whether to modify the content of its own stored data to the content of the second data according to the first data synchronization message. Afterwards, the first node will receive a first response message from the second node. The first response message corresponds to the first data synchronization message and indicates the data synchronization result of the second node. According to the first response message, the first node processes the second data to obtain the first target data.
- the content of the first target data is the same as the content of the data currently stored in the second node (that is, the fourth data).
- the content indicated by the data stored in the first node is different.
- the content indicated by the data stored in the first node The content includes the status of distributed locks, specifically including lock release or lock occupation;
- the data processing method is applied in a distributed arbitration scenario, the content indicated by the data stored in the first node includes the status after arbitration in the distributed system, specifically Including new master node information; in addition, the data stored in the first node can also indicate other contents, which are not limited here.
- the data processing method is applied in a distributed cache consistency scenario
- the content indicated by the data stored in the first node includes cache information of a certain data, and the cache information indicates the client that caches a copy of the data.
- this application has the following advantages: after the first node modifies the first data into the second data according to the first data modification message of the first client, it will also send a first data synchronization message to the second node. , so that the second data can be synchronized. And based on the data synchronization result of the second node, the second data is further processed to obtain synchronization between the data in the first node and the data in the second node. Simply put, through information exchange between the first node and the second node, data synchronization between the first node and the second node is achieved. Even if one node fails, the other node can continue to provide services, improving the system reliability.
- the first response message corresponds to fourth data in the second node
- the fourth data is obtained after the second node performs data synchronization on the third data according to the first data synchronization message. the data obtained.
- the first node will process the second data according to the content of the second data and the content of the fourth data indicated by the first response message. Specifically, if the content of the fourth data has been synchronized to the content of the second data, it means that the second node has performed data synchronization, then the content of the first target data is the content of the second data, that is to say, the first node The second data can be kept unchanged.
- the second node has performed data synchronization, including that the third data of the second node has the same content as the first data of the first node, or, although the content of the third data is different from the content of the first data, the content of the second node's third data is the same as that of the first data.
- the priority is not higher than the priority of the first node. If the content of the fourth data is different from the content of the second data, it means that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, so the second node maintains the priority of the first node.
- the content of the third data remains unchanged, that is, the content of the third data and the fourth data are the same. In this case, the first node will update the content of the second data to the content of the fourth data to obtain the first target data.
- the first node after the data is modified, the first node will send a data synchronization message to the second node, and determine whether the modified data still needs to be processed based on the response message of the second node, thereby ensuring that the first node communicates with the second node.
- Data synchronization between nodes further improves the reliability of the system.
- the value of the synchronization flag bit of the first node will also change. If the first node modifies the first data into the second data, the first node will set the value of the synchronization flag bit to the first value, and the first value indicates that the data stored in the first node has been modified. After the first node processes the second data to obtain the first target data, the value of the synchronization flag bit of the first node is updated to a second value. The second value indicates the data stored in the first node (that is, the first Target data) is synchronized with the data stored in the second node (ie, fourth data).
- the first node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized.
- the identification method is simple.
- the second node can also receive a data modification message from the client and send a data synchronization message to the first node.
- the first node may also obtain a second data synchronization message from the second node.
- the second data instructs the first node to perform data synchronization
- the second data synchronization message corresponds to the fifth data stored in the second node.
- the fifth data is data obtained by the second node modifying the first historical data in the second node according to the second data modification message from the second client.
- the second client and the first client may be the same client or different clients, and the details are not limited here.
- the first node will process the data currently stored in the first node according to the second data synchronization message and the first data status of the first node to obtain the first data.
- both the first node and the second node can receive the client's data modification message and respond to the message. If the first node and the second node are used as the master node and backup node respectively, this application can achieve " "Hyperactive active-standby synchronization strategy" improves the flexibility of the technical solution of this application.
- the first data status of the first node may indicate multiple contents, so that the first node processes currently stored data in different ways. Specifically, if the first data status indicates that the content of the data currently stored in the first node is the same as the content of the first historical data, it means that the first node needs to perform synchronous modification to change the content of the data currently stored in the first node.
- the priority of the node means that the first node needs to be synchronously modified to update the content of the data currently stored in the first node to the content of the fifth data to obtain the first data; if the first data status indicates that the current data in the first node
- the content of the stored data is different from the content of the first historical data, and the priority of the first node is higher than the priority of the second node, which means that the first node does not need to be modified and the first node can determine the content of the first data.
- the first node determines whether data synchronization is required based on its own data status.
- the first node will modify the data to ensure data consistency between the two nodes; when the data currently stored by the first node
- the first node When the data content of the second node is different from the first historical data content of the second node, the first node will combine the priorities of the two nodes to determine whether to modify the currently stored data to ensure that the data of the low-priority node follows
- the data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
- a second response message corresponding to the second data synchronization message is sent to the second node.
- the second response message indicates the data synchronization result of the first node, that is, the content of the first data, so that the second node processes the fifth data according to the second response message, so that the processed fifth data is
- the content is the same as the content of the first data, that is, the data of the first node and the second node are synchronized.
- the first node processes the data currently stored by the first node to obtain the first data according to the data synchronization message of the second node, and then feeds back the data synchronization result to the second node, so that the second node further processes its own storage. data, thereby ensuring data synchronization between the first node and the second node, further improving the reliability of the system.
- the data status of the first node is modified, and the value of the synchronization flag bit is set to the second value to represent the first The data of the node and the second node have been synchronized.
- the first node may also obtain a third data synchronization message from the second node, the third data synchronization message indicating the first The node performs data synchronization, and the third data synchronization message corresponds to the sixth data stored in the second node.
- the sixth data is data obtained by the second node modifying the second historical data in the second node according to the third data modification message from the third client.
- any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
- the first node processes the first target data according to the third data synchronization message and the second data status of the first node to obtain the second target data.
- both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. In addition, compared with the solution where only the master node can receive the client's message and then the backup node responds, the technical solution of this application reduces the response delay.
- the second data status of the first node may indicate multiple contents, so that the first node processes the first target data in different ways. Specifically, if the second data status indicates that the content of the first target data in the first node is the same as the content of the second historical data, it means that the first node needs to perform synchronous modification to change the content of the first target data in the first node.
- the priority of the second node means that the first node needs to be modified synchronously to update the content of the first target data in the first node to the content of the sixth data to obtain the second target data; if the second data status indicates that the first node
- the content of the first target data is different from the content of the second historical data, and the priority of the first node is higher than the priority of the second node, which means that the first node does not need to be modified and the first node can determine the second target.
- the content of the data is the same as the content of the first target data in the first node.
- the first node determines whether data synchronization is required based on its own data status.
- the first node will modify the data to ensure data consistency between the two nodes; when the first node first
- the first node will combine the priorities of the two nodes to determine whether the first target data has been modified, thereby ensuring that the data of the low-priority node follows.
- the data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
- a third response message corresponding to the third data synchronization message is sent to the second node.
- the third response message indicates the data synchronization result of the first node, that is, the content of the second target data, so that the second node processes the sixth data according to the third response message, so that the processed sixth data
- the content of is the same as the content of the second target data, that is, the data of the first node and the second node are synchronized.
- the first node after the first node processes the first target data of the first node to obtain the second target data according to the data synchronization message of the second node, it can also feed back the data synchronization result to the second node, so that the second node can further process it.
- the data stored by itself ensures the data synchronization between the first node and the second node, further improving the reliability of the system.
- the first node after the first node obtains the second target data, the first node The data status of the node will be modified, and the value of the synchronization flag bit will be set to the second value to indicate that the data of the first node and the second node have been synchronized.
- the first node after the first node obtains the first target data, the first node also sends a fourth response message to the first client, and the fourth response message carries the first target data. .
- the first node can not only obtain the client's data modification message, but also feed back to the client the final result after modification and synchronization.
- the second node can also obtain the client's data modification message and feed back the final result after modification and synchronization to the client. That is to say, in this application, both the first node and the second node can obtain the request and feedback the results, thereby realizing the "dual-active active and backup synchronization strategy", further improving the flexibility and practicality of the technical solution of this application.
- the second aspect of this application provides a data processing method, which is applied to the second node and includes:
- the second node establishes a communication connection with the first node and can obtain the first data synchronization message from the first node.
- the first data synchronization message is used to instruct the second node to perform data synchronization.
- the first data synchronization message corresponds to the second data in the first node.
- the second data is the first node modifying the message according to the first data from the first client. Data obtained by modifying the first data in the first node.
- the first node and the second node can also perform role assignment. If the first node is the master node, then the second node is the backup node. Correspondingly, if the second node is the master node, then the second node is the backup node.
- the second node After the second node obtains the first data synchronization message, it will process the third data stored in the second node according to the first data synchronization message and the first data status of the second node to obtain fourth data.
- the second node will send a first response message to the first node.
- the first response message indicates the data synchronization result of the second node, so that the first node processes the second data according to the data synchronization result to obtain the first target data.
- the second node The first target data in one node and the fourth data in the second node have the same data content, thus realizing data synchronization between different nodes.
- the content indicated by the data stored in the second node is different.
- the content indicated by the data stored in the second node includes the status of the distributed lock, specifically including lock release or lock occupation; if the data processing method is applied in a distributed lock scenario, In the arbitration scenario, the data stored in the second node indicates the status after arbitration in the distributed system, specifically including the new master node information; in addition, the data stored in the second node can also indicate other
- the content is not specifically limited here.
- the content indicated by the data stored in the second node includes cache information of a certain data, and the cache information indicates the client that caches a copy of the data.
- the first node after the data of the first node is modified, it will send a data synchronization message to the second node, so that the second node determines the data synchronization result based on its own data status, and feeds the result back to the first node, so that the first node further processes itself.
- data ultimately achieving data synchronization between the first node and the second node, improving the reliability of the system.
- the data synchronization results of the second node also have multiple possibilities. Specifically, if the first data status of the second node indicates that the content of the third data in the second node is the same as the content of the first data in the first node, it means that the first node and the second node were in data synchronization before. status, when the data of the first node is modified, the second node needs to be modified synchronously and update the content of the third data to the content of the second data to obtain the fourth data synchronized with the second data.
- the second node will The content of the third data is updated to the content of the second data to obtain the fourth data synchronized with the second data.
- the second node determines whether data synchronization is required based on its own data status.
- the third data of the second node is the same as the first data of the first node
- the second node will modify the data to ensure data consistency between the two nodes; when the third data is the same as the first data
- the second node will combine the priorities of the two nodes to determine whether to modify the third data, thereby ensuring that the data of the low-priority node follows the data of the high-priority node, avoiding high priority
- the data in level nodes is frequently modified or misoperated.
- the first data status indicates that the content of the third data is different from the content of the first data
- the priority of the second node is higher than the priority of the first node
- One node and the second node were not in a data synchronization state before, and the data of the first node needs to follow the data of the second node.
- the third data in the second node remains unchanged, that is, it is determined that the content of the fourth data is the same as that of the second node.
- the contents of the three data are the same.
- the second node when the content of the third data is different from that of the first data, and the priority of the second node is higher than the priority of the first node, the second node will not modify the content of the third data, so that the lower priority
- the data of high-level nodes follows the data of high-priority nodes, preventing data in high-priority nodes from being frequently modified or misoperated.
- the second node after obtaining the fourth data, the second node will also update the first data state to a second data state, where the second data state indicates the relationship between the second node and the first node. data synchronization.
- the value of the synchronization flag bit of the second node may be set to the second value.
- the second node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized.
- the identification method is simple.
- the second node can also receive a data modification message from the client and send a data synchronization message to the first node.
- the second node may also obtain a second data modification message from the second client.
- the second data modification message indicates modifying the data stored in the second node.
- First historical data The second node will modify the first historical data according to the second data modification message, obtain the fifth data, and then send the second data synchronization message to the first node, so that the first node can perform data synchronization on the data currently stored by the first node. Get the first data. After performing data synchronization, the first node will send a second response message to the second node.
- the second node receives a second response message from the first node, the second response message indicates the data synchronization result of the first node, and processes the fifth data according to the second response message, so that the processed fifth data is consistent with the first node.
- the second client and the first client may be the same client or different clients, and the details are not limited here.
- the second node after the second node obtains the processed fifth data, it also sends a response message to the second client, and the response message carries the processed fifth data.
- both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. In addition, compared with the solution where only the master node can receive the client's message and then the backup node responds, the technical solution of this application reduces the response delay.
- the way in which the second node processes the fifth data is also different. If the second response message indicates that the content of the first data is synchronized to the content of the fifth data, then the second node will keep the content of the fifth data unchanged, that is, the content of the processed fifth data is the same as the fifth data. If the second response message indicates that the content of the first data is different from the content of the fifth data, it means that the priority of the first node is higher than the priority of the second node, and the second node needs to update the fifth data and change the fifth data. The content of the fifth data is updated to the content of the first data, and the modified fifth data is obtained.
- the second node after the second node modifies the data according to the data modification message of the second client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message according to the synchronization result of the first node. data, thereby ensuring that the data in the first node and the second node are synchronized, further improving the reliability of the system.
- the second node after obtaining the modified fifth data, the second node will set the value of the synchronization flag bit to a second value, and the second value indicates that the first node and the second node Node data synchronization.
- the second node may receive data modification messages from multiple clients at different points in time.
- the second node may obtain a third data modification message from the third client.
- the third data modification message indicates modifying the second historical data stored in the second node. .
- any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
- the second historical data is modified to obtain the sixth data.
- the second node will send a third data synchronization message to the first node, so that the first node performs data synchronization on the first target data to obtain the second target data.
- the first node After obtaining the second target data, the first node sends a third response message to the second node.
- the third response message indicates the data synchronization result of the first node.
- the second node receives the third response message from the first node, and processes the sixth data according to the third response message, so that the processed fifth data is synchronized with the second target data.
- the second node after obtaining the processed sixth data, the second node also sends a response message to the third client, and the response message carries the processed sixth data.
- the second node can receive data modification messages from clients at different times and respond; it can also receive data modification messages from different clients, which enriches the application scenarios of the technical solution of this application and improves the practicality of the technical solution. .
- the way in which the second node processes the sixth data is also different. If the third response message indicates that the content of the second target data is synchronized to the content of the sixth data, then the second node will keep the content of the sixth data unchanged, that is, the content of the processed sixth data is the same as the sixth data. If the third response message indicates that the content of the second target data is different from the content of the sixth data, it means that the priority of the first node is higher than the priority of the second node, and the second node needs to update the sixth data. The content of the sixth data is updated to the content of the second target data, and the modified sixth data is obtained.
- the second node after the second node modifies the data according to the data modification message of the third client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message according to the synchronization result of the first node. data, thereby ensuring that the data in the first node and the second node are synchronized, further improving the reliability of the system.
- the second node after obtaining the modified sixth data, the second node will set the value of the synchronization flag bit to a second value, and the second value indicates that the first node and the second node Node data synchronization.
- the third aspect of the embodiment of the present application provides a communication system.
- the communication system includes a first node and a second node.
- the first node is used to perform the aforementioned first aspect and any of the possible implementations of the first aspect.
- Method, the second node is configured to execute the method shown in the aforementioned second aspect and any possible implementation manner of the second aspect.
- a fourth aspect of this application provides a network device.
- the network device includes a first node, including:
- a transceiver unit configured to obtain a first data modification message from the first client, where the first data modification message indicates modification of the first data stored in the first node.
- a processing unit configured to modify the first data according to the first data modification message to obtain the second data.
- the transceiver unit is also configured to send a first data synchronization message to the second node, where the first data synchronization message carries the second data, so that the second node performs data synchronization.
- the transceiver unit is also configured to receive a first response message from the second node, where the first response message indicates the data synchronization result of the second node.
- the processing unit is also configured to process the second data according to the first response message to obtain the first target data.
- the network device is configured to perform the method shown in the aforementioned first aspect and any possible implementation manner of the first aspect.
- the fifth aspect of this application provides a network device.
- the network device includes a second node, including:
- a transceiver unit configured to obtain a first data synchronization message from a first node.
- the first data synchronization message instructs the second node to perform data synchronization.
- the first data synchronization message corresponds to the second data in the first node.
- the second data It is the data obtained by the first node modifying the first data in the first node according to the first data modification message from the first client.
- the processing unit is configured to process the third data stored in the second node according to the first data synchronization message and the first data status of the second node to obtain fourth data.
- the transceiver unit is also configured to send a first response message to the first node.
- the first response message indicates the data synchronization result of the second node, so that the first node processes the second data to obtain the first target data according to the data synchronization result.
- the network device is configured to perform the method shown in the aforementioned second aspect and any possible implementation manner of the second aspect.
- the sixth aspect of this application provides a network device, including a processor, a memory and a communication interface.
- the processor, the memory and the communication interface are connected.
- the processor is configured to execute the aforementioned first aspect and any possible implementation of the first aspect. method shown.
- the seventh aspect of this application provides a network device, including a processor, a memory and a communication interface.
- the processor, the memory and the communication interface are connected.
- the processor is configured to execute the aforementioned second aspect and any possible implementation of the second aspect. method shown.
- the eighth aspect of the present application provides a computer-readable storage medium.
- the computer-readable storage medium stores a program.
- the computer executes the program, the first aspect, any possible implementation manner of the first aspect, and the third aspect are executed.
- a ninth aspect of the present application provides a computer program product, which is characterized in that when the computer program product is executed on a computer, the computer executes the first aspect, any possible implementation of the first aspect, the second aspect, and The method shown in any possible implementation of the second aspect.
- Figure 1a is a schematic diagram of the system architecture provided by the embodiment of the present application.
- Figure 1b is another schematic diagram of the system architecture provided by the embodiment of the present application.
- Figure 2 is a schematic flow chart of the data processing method provided by the embodiment of the present application.
- FIG. 3 is a schematic diagram of the data processing method provided by the embodiment of the present application.
- FIG. 4 is another schematic diagram of the data processing method provided by the embodiment of the present application.
- Figure 5a is a schematic diagram of the read-write scenario provided by the embodiment of the present application.
- Figure 5b is a schematic diagram of the write-write scenario provided by the embodiment of the present application.
- FIG. 6 is another schematic diagram of the data processing method provided by the embodiment of the present application.
- Figure 7 is another schematic diagram of the data processing method provided by the embodiment of the present application.
- Figure 8 is another schematic flow chart of the data processing method provided by the embodiment of the present application.
- Figure 9 is another schematic flow chart of the data processing method provided by the embodiment of the present application.
- Figure 10 is a schematic diagram of a communication system provided by an embodiment of the present application.
- Figure 11 is a schematic structural diagram of a network device provided by an embodiment of the present application.
- Figure 12 is another schematic structural diagram of a network device provided by an embodiment of the present application.
- the present application provides a data processing method, a communication system and related equipment.
- the data processing method applied to the first node includes: the first node modifies the first data into the second data according to the first data modification message of the first client. . Then the first data synchronization message is sent to the second node, so that the second data is synchronized. Then, the second data is processed according to the data synchronization result indicated by the first response information of the second node, and the first target data with the same content as the data in the second node is obtained. Through information exchange between the first node and the second node, data synchronization between the first node and the second node is achieved. Even if one node fails, the other node can continue to provide services, which improves the reliability of the system.
- a and/or B describes the association of associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A exists alone, A and B exist simultaneously, and B exists alone, where A, B can be singular or plural.
- the character "/” generally indicates that the related objects are in an "or” relationship.
- At least one of the following” or similar expressions refers to any combination of these items, Including any combination of single items (items) or plural items (items). For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple .
- Figure 1a and Figure 1b are both schematic diagrams of system architecture provided by embodiments of the present application.
- nodes S0 to S6 are deployed in a spine-leaf topology.
- the master node is deployed in the spine layer (i.e., the upper layer in Figure 1a), and in the leaf layer (i.e., the upper layer in Figure 1a). lower layer) to deploy backup nodes.
- Nodes in the spine layer are connected to nodes in the leaf layer in a full grid manner, that is, a connection relationship is established between any node in the spine layer and any node in the leaf layer.
- the server cluster includes servers A1 to A9, the corresponding master node is node S1, and the corresponding backup node is node S6.
- the nodes directly connected to different servers in the server cluster can be the same or different, and there is no specific limit here.
- server A1, server A2 and server A3 are all directly connected to node S3; server A4 is directly connected to node S4.
- Figure 1a is only a diagram of the system architecture provided in this application.
- the architecture composed of each node can also have many situations, for example, the number of upper-layer nodes is consistent with the number of lower-layer nodes; or Each node forms a more or less hierarchical architecture, which is not limited here.
- the primary node S1 and the backup node S2 are included in a single-layer architecture, and a direct connection relationship is established between any two nodes.
- a direct connection relationship is established between any two nodes.
- each server can also be directly connected to a larger number of nodes, which is not limited here.
- each server can also be directly connected to a larger number of nodes, which is not limited here.
- a client can also be deployed on each server, and the client sends a data modification request to the primary node or backup node.
- the data processing method provided by the embodiment of the present application is applied to the first node or the second node.
- the first node and the second node may be switches or other network devices capable of data synchronization, such as servers.
- the first node and the second node may be the same type of equipment, or may be different types of equipment, and there is no specific limitation here.
- the first node and the second node can perform role allocation. If the first node is the master node, then the second node is the backup node; accordingly, if the second node is the master node, then the first node is the backup node. Specifically, here No restrictions.
- the first node is the master node and the second node is the backup node
- the first node is node S1 and the second node is node S6.
- the first node is the master node and the second node is the backup node, and assuming that the data processing method provided by this application is applied in a distributed lock scenario, the data processing method provided by the embodiment of this application will be described.
- the data type stored in the first node as the master node and the second node as the backup node includes the lock status.
- the process of the first node or the second node processing the client's lock request can be regarded as the process of the client initiating a read or write request to the first node or the second node.
- the data processing method provided by this application includes three different scenarios, namely read-read scenario, read-write scenario, and write-write scenario.
- the operation of the primary node or the backup node does not involve the modification of the lock status, that is, the modification of the data stored on itself. Therefore, the data consistency of the primary and backup nodes can be guaranteed.
- the read-read scenario will not be explained here. .
- FIG. 2 is a schematic flowchart of a data processing method provided by an embodiment of the present application, including the following steps:
- the first data modification message indicates modifying the first data stored in the first node.
- the first client sends a first data modification message to the first node with the intention of modifying the first data stored in the first node, that is, a write operation is performed on the first node.
- the first data modification message may be sent to the first node in the form of a message.
- the first node obtains the first data modification message and modifies the first data to obtain the second data.
- the first node Since the first data is modified, the first node will send a first data synchronization message to the second node to inform the second node that the data stored in the first node has been modified, so that the second node can perform data synchronization to maintain the first data synchronization message. Data consistency between one node and the second node.
- the first data synchronization message may be sent to the second node in the form of a message.
- the second node After receiving the first data synchronization message, the second node will determine whether its own data needs to be modified based on its own data status, and send a first response message to the first node to inform the first node of the data synchronization result.
- the second node may receive a read request from the client, that is, the operations of the first node and the second node correspond to the read-write scenario.
- the second node will consider the priorities of the two nodes to determine whether to modify the content of the third data. If the priority of the first node is higher than the priority of the second node, the second node will modify the content of the third data to the content of the second data to obtain the fourth data. If the priority of the first node is not is higher than the priority of the second node, then the second node will not modify the content of the third data. That is to say, the content of the fourth data obtained by the second node after data synchronization according to the first data synchronization message is the same as the content of the third data. The content is the same.
- the reason why the first data and the third data are different may be that the second node receives a data modification message from the client and modifies the data that was originally synchronized with the first data into the third data, that is, the first node and the third data are different.
- the operation of the second node corresponds to the write-write scenario.
- the priority between the first node and the second node can be determined according to the roles of the first node and the second node. For example, the priority of the primary node is higher than the priority of the backup node; it can also be determined in other ways, For example, it is determined based on the identity number (ID) of each node. For example, a node with a larger ID value has a higher priority. There is no specific limit here.
- the second node After the second node obtains the fourth data, it will send a first response message corresponding to the first data synchronization message to the first node, so that the first node processes the second data according to the first response message and obtains synchronization with the fourth data.
- the first target data That is to say, the first response message corresponds to the fourth data in the second node, and the fourth data is the data obtained after the second node performs data synchronization on the third data according to the first data synchronization message.
- the first node After obtaining the first response message, the first node will process the second data according to the content of the second data and the content of the fourth data indicated by the first response message. Specifically, if the content of the fourth data has been synchronized to the content of the second data, it means that the second node has performed data synchronization, then the content of the first target data is the content of the second data, that is to say, the first node The second data can be kept unchanged. Among them, the second node has performed data synchronization, including that the third data of the second node has the same content as the first data of the first node, or, although the content of the third data is different from the content of the first data, the content of the second node's third data is the same as that of the first data. The priority is not higher than the priority of the first node.
- the content of the fourth data is different from the content of the second data, it means that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, so the second node maintains the priority of the first node.
- the content of the third data remains unchanged, that is, the content of the third data and the fourth data are the same.
- the first node will update the content of the second data to the content of the fourth data to obtain the first target data.
- the first node modifies the first data into the second data according to the first data modification message of the first client, it also sends a first data synchronization message to the second node, so that the second data is synchronized. And based on the data synchronization result of the second node, the second data is further processed to obtain synchronization between the data in the first node and the data in the second node.
- the first node modifies the first data into the second data according to the first data modification message of the first client
- it also sends a first data synchronization message to the second node, so that the second data is synchronized.
- the second data is further processed to obtain synchronization between the data in the first node and the data in the second node.
- the first node will send a data synchronization message to the second node, and determine whether the modified data still needs to be processed based on the response message of the second node, thereby ensuring the communication between the first node and the second node.
- Data synchronization between devices further improves the reliability of the system.
- the first node after the first node obtains the first target data, that is, after step 205, the first node will also send a fourth response message to the first client.
- the fourth response message corresponds to The first data modification message and the fourth response message of the first client carry the first target data, thereby informing the first client of the final result of the data modification.
- the first node can not only obtain the client's data modification message, but also feedback modification synchronization to the client. The final result after.
- the second node can also obtain the client's data modification message and feedback the final result after modification and synchronization to the client (the operation of the second node will be expanded upon when describing the data processing method using the second node as the execution subject). That is to say, in this application, both the first node and the second node can obtain the request and feedback the results, thereby realizing the "dual-active active and backup synchronization strategy", further improving the flexibility and practicality of the technical solution of this application.
- Figure 3 is a schematic diagram of the data processing method provided by the embodiment of the present application.
- the so-called “dual-active master-backup synchronization strategy” means that both the master node and the backup node can receive requests from clients and respond to requests. Compared with In the chain synchronization scheme, only the master node can receive the request and the backup node can respond, which reduces the response delay. In addition, data synchronization is performed between the primary node and the backup node to ensure data consistency. In general, the technical solution of this application can not only improve system reliability but also reduce latency, providing a data processing method with high reliability and low latency.
- the value of the synchronization flag bit (synchronize, sync) of the first node will also change. If the first node modifies the first data into the second data, the first node will set the value of the synchronization flag bit to the first value, and the first value indicates that the data stored in the first node has been modified. After the first node processes the second data to obtain the first target data, the value of the synchronization flag bit of the first node is updated to a second value. The second value indicates the data stored in the first node (that is, the first Target data) is synchronized with the data stored in the second node (ie, fourth data).
- first value can be set to 1 and the second value can be set to 0.
- Figure 4 is a schematic diagram provided by an embodiment of the present application.
- the first node modifies the first data into the second data according to the first data modification message, and sets the value of the synchronization flag bit to 1 to indicate that the data of the first node has occurred. Modified.
- the first node sends a first data synchronization message to the second node, so that the second node synchronizes the third data into the fourth data and sets the synchronization flag bit.
- the value is set to 0 to indicate that the data of the second node is synchronized with the data of the first node.
- the first node receives a first response message indicating the data synchronization result of the second node.
- the first response message corresponds to the fourth data, so that the first node further processes the second data, obtains the first target data, and sets the synchronization flag
- the value of the bit is set to 0 to indicate that the first target data in the first node is synchronized with the fourth data in the second node.
- Figure 5a is a schematic diagram of a read-write scenario provided by an embodiment of the present application
- Figure 5b is a schematic diagram of a write-write scenario provided by an embodiment of the present application.
- the backup node When a write operation occurs, the backup node sets the sync bit to 1 and sends a data synchronization message to the primary node. due to main section The sync at this point is 0, therefore, the data synchronization message takes effect, and the master node performs data modification to be consistent with the data of the backup node. After the backup node obtains the response message from the primary node, it modifies the value of its own synchronization flag and sets sync to 0.
- the active and standby nodes receive write requests at the same time, and the active and standby nodes receive different write requests.
- the master node and the backup node will send data synchronization requests to each other.
- the first node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized.
- the identification method is simple.
- the first node and the second node obtain the data modification request from the client at the same time.
- the time points at which the first node and the second node obtain the data modification request from the client can also be different. , this situation is explained below.
- the first node may obtain a second data synchronization message from the second node.
- the second data synchronization message instructs the first node to perform data synchronization.
- the second data synchronization message corresponds to The fifth data stored in the second node (that is, the second data synchronization message carries the fifth data).
- the fifth data is data obtained by the second node modifying the first historical data in the second node according to the second data modification message from the second client.
- the first node processes the data currently stored in the first node according to the second data synchronization message and the first data status of the first node to obtain the first data.
- the second client and the first client may be the same client or different clients, and the details are not limited here.
- the first node may also process the currently stored data in different ways.
- the first data status indicates that the content of the data currently stored in the first node is the same as the content of the first historical data, it means that the first node needs to perform synchronous modification, and the current data in the first node The content of the stored data is updated to the content of the fifth data to obtain the first data.
- the first data status indicates that the content of the data currently stored in the first node is different from the content of the first historical data, and the priority of the first node is not higher than the priority of the second node , means that the first node needs to be modified synchronously, and the content of the data currently stored in the first node is updated to the content of the fifth data to obtain the first data.
- the first data status indicates that the content of the data currently stored in the first node is different from the content of the first historical data, and the priority of the first node is higher than the priority of the second node, This means that the first node does not need to be modified, and the first node can determine that the content of the first data is the same as the content of the data currently stored in the first node.
- both the first node and the second node can receive the client's data modification message and respond to the message. If the first node and the second node are used as the master node and backup node respectively, this application can achieve " “Hyperactive active-standby synchronization strategy" improves the flexibility of the technical solution of this application. In addition, after receiving the data synchronization message from the second node, the first node will determine whether data synchronization is required based on its own data status.
- the first node When the data currently stored by the first node is the same as the first historical data content of the second node, the first node will modify the data to ensure data consistency between the two nodes; when the data currently stored by the first node When the data content of the second node is different from the first historical data content of the second node, the first node will combine the priorities of the two nodes to determine whether to modify the currently stored data to ensure that the data of the low-priority node follows The data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
- a second response message corresponding to the second data synchronization message is sent to the second node.
- the second response message indicates the data synchronization result of the first node, that is, the content of the first data, so that the second node processes the fifth data according to the second response message, so that the processed fifth data
- the content is the same as the content of the first data, that is, the data of the first node and the second node are synchronized.
- the first node processes the data currently stored by the first node to obtain the first data according to the data synchronization message of the second node, and then feeds back the data synchronization result to the second node, so that the second node further processes its own storage. data, thereby ensuring data synchronization between the first node and the second node, further improving the reliability of the system.
- the data status of the first node will be modified, and the value of the synchronization flag bit will be set to a second value to indicate that the first node and the second Node data synchronization.
- Figure 6 is a schematic diagram provided by an embodiment of the present application.
- the second node modifies the first historical data to the fifth data according to the second data modification message, and sets the value of the synchronization flag bit to 1 to represent the data of the second node. Modifications have occurred.
- the second node sends a second data synchronization message to the first node, so that the first node synchronizes the currently stored data into the first data and sets the synchronization flag bit.
- the value is set to 0 to indicate that the data of the first node is synchronized with the data of the second node.
- the second node receives a second response message indicating the data synchronization result of the first node.
- the second response message corresponds to the first data, so that the second node further processes the sixth data to obtain the processed sixth data, and
- the value of the synchronization flag bit is set to 0 to indicate that the processed sixth data in the second node is synchronized with the first data in the first node.
- the first node may also obtain a third data synchronization message from the second node.
- the third data synchronization message instructs the first node to perform data synchronization
- the third data synchronization message instructs the first node to perform data synchronization.
- the third data synchronization message corresponds to the sixth data stored in the second node (that is, the third data synchronization message carries the sixth data).
- the sixth data is the second historical data in the second node according to the third data modification message from the third client. The data obtained after modification.
- the first node processes the first target data according to the third data synchronization message and the second data status of the first node to obtain the second target data.
- any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
- the first node may also process the first target data in different ways.
- the second data status indicates that the content of the first target data in the first node is the same as the content of the second historical data, it means that the first node needs to perform synchronous modification, and the first node in the first node needs to perform synchronous modification.
- the content of the first target data is updated to the content of the sixth data to obtain the second target data.
- the second data status indicates that the content of the first target data in the first node is different from the content of the second historical data, and the priority of the first node is not higher than the priority of the second node , means that the first node needs to be modified synchronously, and the content of the first target data in the first node is updated to the content of the sixth data to obtain the second target data.
- the second data status indicates that the content of the first target data in the first node is different from the content of the second historical data, and the priority of the first node is higher than the priority of the second node, This means that the first node does not need to be modified, and the first node can determine that the content of the second target data is the same as the content of the first target data in the first node.
- both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. In addition, compared with the solution where only the master node can receive the client's message and then the backup node responds, the technical solution of this application reduces the response delay. In addition, after receiving the data synchronization message from the second node, the first node will determine whether data synchronization is required based on its own data status.
- the first node When the first target data of the first node is the same as the second historical data content of the second node, the first node will modify the data to ensure data consistency between the two nodes; when the first node first When the content of the target data is different from the second historical data of the second node, the first node will combine the priorities of the two nodes to determine whether the first target data has been modified, thereby ensuring that the data of the low-priority node follows.
- the data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
- a third response message corresponding to the third data synchronization message is sent to the second node.
- the third response message indicates the data synchronization result of the first node, that is, the content of the second target data, so that the second node processes the sixth data according to the third response message, so that the processed sixth data
- the content of is the same as the content of the second target data, that is, the data of the first node and the second node are synchronized.
- the first node after the first node processes the first target data of the first node to obtain the second target data according to the data synchronization message of the second node, it can also feed back the data synchronization result to the second node, so that the second node can further process it.
- the data stored by itself ensures the data synchronization between the first node and the second node, further improving the reliability of the system.
- the data status of the first node will Make modifications to set the value of the synchronization flag bit to the second value to indicate data synchronization between the first node and the second node.
- Figure 7 is a schematic diagram provided by an embodiment of the present application.
- the second node modifies the second historical data to the sixth data according to the third data modification message, and sets the value of the synchronization flag bit to 1 to represent the data of the second node. Modifications have occurred.
- the second node sends a third data synchronization message to the first node, so that the first node synchronizes the first target data to the second target data and sets the synchronization flag bit.
- the value of is set to 0 to indicate that the data of the first node is synchronized with the data of the second node.
- the second node receives a third response message indicating the data synchronization result of the first node.
- the second response message corresponds to the second target data, so that the second node further processes the sixth data to obtain the processed sixth data, and
- the value of the synchronization flag bit is set to 0 to indicate that the processed sixth data in the second node is synchronized with the second target data in the first node.
- Figure 8 is a schematic flow chart of a data processing method provided by an embodiment of the present application, including the following steps:
- the first data synchronization message instructs the second node to perform data synchronization.
- the first data synchronization message corresponds to the second data in the first node.
- the second data is the first data synchronization message.
- the second node establishes a communication connection with the first node and can obtain the first data synchronization message from the first node.
- the data synchronization results of the second node also have multiple possibilities.
- the first data status of the second node indicates that the content of the third data in the second node is the same as the content of the first data in the first node, it means that the first node is the same as the second node.
- the second node needs to modify it synchronously and update the content of the third data to the content of the second data to obtain the fourth data synchronized with the second data. data.
- the second node will update the content of the third data to the content of the second data, so as to Fourth data synchronized with the second data is obtained.
- the first data status indicates that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, it means that the first node is different from the first node.
- the two nodes were not in a data synchronization state before, and the data of the first node needs to follow the data of the second node.
- the third data in the second node remains unchanged, that is, the content of the fourth data and the content of the third data are determined. same.
- the second node determines whether data synchronization is required based on its own data status.
- the third data at the second node has the same content as the first data at the first node.
- the second node will modify the data to ensure data consistency between the two nodes; in the case where the content of the third data is different from the first data, the second node will combine the priorities of the two nodes , determine whether to modify the third data, thereby ensuring that the data of the low-priority node follows the data of the high-priority node, and avoiding frequent modification or misoperation of the data in the high-priority node.
- the first response message indicates the data synchronization result of the second node, so that the first node processes the second data to obtain the first target data according to the data synchronization result.
- the data content of the first target data in the first node and the fourth data in the second node are the same, thereby realizing data synchronization between different nodes.
- the first node after the data of the first node is modified, it will send a data synchronization message to the second node, so that the second node determines the data synchronization result based on its own data status, and feeds the result back to the first node, so that the first node further processes itself.
- data ultimately achieving data synchronization between the first node and the second node, improving the reliability of the system.
- the second node after step 803, that is, after obtaining the fourth data, the second node will update the first data state to a second data state, and the second data state indicates that the second node is in contact with the first data state. Node data synchronization. Specifically, the value of the synchronization flag bit of the second node may be set to the second value.
- step 801 to step 803 the data change process of the second node is as shown in the aforementioned Figure 4.
- the second node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized.
- the identification method is simple.
- the second node can also receive a data modification message from the client and send a data synchronization message to the first node.
- the second node may also obtain a second data modification message from the second client, and the second data modification message indicates modification.
- the first historical data stored in the second node The second node will modify the first historical data according to the second data modification message, obtain the fifth data, and then send the second data synchronization message to the first node, so that the first node can perform data synchronization on the data currently stored by the first node. Get the first data. After performing data synchronization, the first node will send a second response message to the second node.
- the second node receives a second response message from the first node, the second response message indicates the data synchronization result of the first node, and processes the fifth data according to the second response message, so that the processed fifth data is consistent with the first node.
- the second client and the first client may be the same client or different clients, and the details are not limited here.
- the second node if the second response message indicates that the content of the first data is synchronized to the content of the fifth data, then the second node will keep the content of the fifth data unchanged, that is, the processed fifth data The content is the same as the fifth data.
- the second response message indicates that the content of the first data is different from the content of the fifth data, it means that the priority of the first node is higher than the priority of the second node, and the second node needs The fifth data is updated, and the content of the fifth data is updated to the content of the first data to obtain the modified fifth data.
- the content of the fifth data is updated to the content of the first data.
- the second node processes the first historical data and finally obtains the processed fifth data, as shown in the aforementioned Figure 6 .
- the second node after obtaining the processed fifth data, the second node also sends a response message to the second client, where the response message carries the processed fifth data.
- both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. Compared with the chain synchronization solution, in which only the master node can receive the client's message, and then the backup node responds, the technical solution of this application reduces the response delay.
- the second node after the second node modifies the data according to the data modification message of the second client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message based on the synchronization result of the first node. This ensures data synchronization between the first node and the second node, further improving the reliability of the system.
- the second node may receive data modification messages from multiple clients at different points in time.
- the second node may obtain the third data modification message from the third client.
- the third data modification message indicates modifying the second node.
- the second historical data stored in .
- the third data modification message the second historical data is modified to obtain the sixth data.
- the second node will send a third data synchronization message to the first node, so that the first node performs data synchronization on the first target data to obtain the second target data.
- the first node sends a third response message to the second node.
- the third response message indicates the data synchronization result of the first node.
- the second node receives the third response message from the first node, and processes the sixth data according to the third response message, so that the processed fifth data is synchronized with the second target data.
- any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
- the second node after obtaining the processed sixth data, the second node also sends a response message to the third client, where the response message carries the processed sixth data.
- the second node will keep the content of the sixth data unchanged, that is, the processed sixth data
- the content of the data is the same as the sixth data.
- the third response message indicates that the content of the second target data is different from the content of the sixth data, it means that the priority of the first node is higher than the priority of the second node, and the second node It is necessary to update the sixth data, update the content of the sixth data to the content of the second target data, and obtain the modified sixth data.
- the second node can receive data modification messages from clients at different times and respond; it can also receive data modification messages from different clients, which enriches the application scenarios of the technical solution of this application and improves the practicality of the technical solution. .
- the second node modifies the data according to the data modification message of the third client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message according to the synchronization result of the first node, thereby ensuring The data in the first node and the second node are synchronized, further improving the reliability of the system.
- the process in which the second node processes the second historical data and finally obtains the processed sixth data is as shown in the aforementioned Figure 7 .
- the time point at which the first node and the second node receive the data modification message from the client is not limited.
- the first node and the second node may receive the data modification message from different clients at the same time, or at different times. Data modification messages from the same or different clients are received at the time point, and the details are not limited here.
- Figure 9 is a schematic flow chart of a data processing method provided by an embodiment of the present application, including the following steps:
- the first node obtains the first data modification message from the first client.
- the first node modifies the first data and obtains the second data.
- the first node sends the first data synchronization message to the second node.
- Steps 901 to 903 are similar to steps 201 to 203 in the embodiment shown in FIG. 2 and will not be described again here.
- the second node processes the third data and obtains the fourth data.
- the first node receives the first response message from the second node.
- the first node processes the second data and obtains the first target data.
- Steps 905 and 906 are similar to steps 204 and 205 in the embodiment shown in FIG. 2 and will not be described again here.
- the first node sends a fourth response message to the first client.
- the fourth response message corresponds to the first data modification message of the first client, and the fourth response message carries the first target data, thereby informing the first client of the final result of the data modification.
- the client sends a lock request (including lock acquisition or lock release, etc.). If the data packet corresponding to the lock request reaches the first node first (the processing logic of the second node arriving first is the same as that of the first node), the One node starts to provide distributed lock services.
- the first node directly returns the operation failure to the client.
- the first node modifies its lock status to occupied and modifies the synchronization identifier sync to 1, indicating that the current lock status needs to be synchronized. At the same time, the first node sends a data synchronization message to the second node.
- the first node After receiving the results from the second node, the first node updates its own status, resets sync to 0, and feeds back the processing results of the first node to the client.
- the data processing method is applied in a distributed lock scenario.
- the content indicated by the data stored in the first node and the second node includes the status of the distributed lock, specifically including lock release or lock occupation.
- data processing methods can also be applied in other scenarios:
- the data processing method can be applied in a distributed arbitration scenario.
- the content indicated by the data stored in the first node and the second node includes the status after arbitration in the distributed system. , specifically including new master node information.
- a deployment model of one master and multiple backups is usually adopted.
- a distributed database there is one primary node and multiple backup nodes.
- the first node or the second node provided by the embodiment of this application can carry the function of the distributed arbitration manager.
- this application provides the first node or the second node to process the election request, thereby determining the generation of the database. Create a new master node and store the new master node information.
- the content indicated by the data stored in the second node includes cache information of a certain data, and the cache information indicates caching a copy of the data. client.
- remote data is usually cached locally to facilitate read and write operations. Therefore, there may be multiple copies of a certain piece of data.
- the client When a client needs to modify data, the client first needs to send invalid information to all clients that cache the data to tell them that the data object has been modified.
- the first node or the second node provided by the embodiment of the present application can store cache information of a certain data, that is, which clients have copies of the data.
- the first node or the second node can find the location of all replicas and send a data invalidation message. Route to other clients through connections between nodes.
- Figure 10 is a schematic structural diagram of a communication system provided by an embodiment of the present application.
- the communication system 1000 includes a first node 1001 and a second node 1002.
- the first node 1001 can perform the operations performed by the first node in the embodiments shown in Figures 2 to 9, and the second node 1002 can The operations performed by the second node in the aforementioned embodiments shown in FIGS. 2 to 9 are performed, and details will not be described again here.
- Figure 11 is a schematic structural diagram of a network device provided by an embodiment of the present application.
- the network device 1100 includes a transceiver unit 1101 and a processing unit 1102.
- the transceiver unit 1101 is configured to obtain a first data modification message from the first client, where the first data modification message indicates modification of the first data stored in the first node.
- the processing unit 1102 is configured to modify the first data according to the first data modification message to obtain the second data.
- the transceiver unit 1101 is also configured to send a first data synchronization message to the second node, where the first data synchronization message carries the second data, so that the second node performs data synchronization.
- the transceiver unit 1101 is also configured to receive a first response message from the second node, where the first response message indicates the data synchronization result of the second node.
- the processing unit 1102 is also configured to process the second data according to the first response message to obtain the first target data.
- the first response message corresponds to fourth data in the second node
- the fourth data is data obtained after the second node performs data synchronization on the third data according to the first data synchronization message.
- the processing unit 1102 is specifically configured to: if the first response message indicates that the content of the fourth data is synchronized to the content of the second data, Then it is determined that the content of the first target data is the same as the content of the second data; if the first response message indicates that the content of the fourth data is different from the content of the second data, then the content of the second data is updated to the content of the fourth data. , get the first target data.
- the processing unit 1102 is also configured to set the value of the synchronization flag bit of the first node to a first value, and the first value indicates that the data stored in the first node is modified;
- the value of the synchronization flag bit of the node is updated to a second value, and the second value indicates that the data stored in the first node is synchronized with the data stored in the second node.
- the transceiver unit 1101 is also used to obtain a second data synchronization message from the second node.
- the second data synchronization message instructs the first node to perform data synchronization.
- the second data synchronization message corresponds to the second data synchronization message.
- the fifth data stored in the second node is data obtained by the second node modifying the first historical data in the second node according to the second data modification message from the second client.
- the second client and the first client may be the same client or different clients, and the details are not limited here.
- the processing unit 1102 is also configured to process the data currently stored in the first node according to the second data synchronization message and the first data status of the first node to obtain the first data.
- the processing unit 1102 is specifically configured to, if the first data status indicates that the content of the data currently stored in the first node is the same as the content of the first historical data, then convert the content of the data currently stored in the first node to The content of the data is updated to the content of the fifth data to obtain the first data; if the first data status indicates that the content of the data currently stored in the first node is different from the content of the first historical data, and the priority of the first node is not high to the priority of the second node, then update the content of the data currently stored in the first node to the content of the fifth data to obtain the first data; if the first data status indicates that the content of the data currently stored in the first node is the same as The content of the first historical data is different, and the priority of the first node is higher than the priority of the second node, then it is determined that the content of the first data is the same as the content of the data currently stored in the first node.
- the transceiver unit 1101 is also configured to send a second response message corresponding to the second data synchronization message to the second node, where the second response message indicates the data synchronization result of the first node.
- the processing unit 1102 is further configured to, if the first node obtains the first data, set the value of the synchronization flag bit of the first node to a second value to indicate that the first node and the second The node's data has been synchronized.
- the transceiver unit 1101 is also used to obtain a third data synchronization message from the second node.
- the first target data synchronization message instructs the first node to perform data synchronization.
- the first target data synchronization message corresponds to
- the sixth data stored in the second node is data obtained by the second node after modifying the second historical data in the second node according to the third data modification message from the third client.
- the processing unit 1102 is also configured to process the first target data according to the third data synchronization message and the second data status of the first node to obtain the second target data.
- any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
- the processing unit 1102 is specifically configured to update the content of the first target data to the sixth data if the second data status indicates that the content of the first target data is the same as the content of the second historical data.
- the content of the second target data is obtained; if the second data status indicates that the content of the first target data is different from the content of the second historical data, and the priority of the first node is not higher than the priority of the second node, then the The content of one target data is updated to the content of the sixth data to obtain the second target data; if the second data status indicates that the content of the first target data is different from the second historical data If the content is different and the priority of the first node is higher than the priority of the second node, it is determined that the content of the second target data is the same as the content of the first target data.
- the transceiver unit 1101 is also configured to send a third response message corresponding to the third data synchronization message to the second node, where the third response message indicates the data synchronization result of the first node.
- the processing unit 1102 is also configured to modify the data status of the first node if the first node obtains the second target data, and set the value of the synchronization flag bit to the second value to represent the second target data.
- the data of the first node and the second node have been synchronized.
- the transceiver unit 1101 is also configured to send a fourth response message to the first client, where the fourth response message carries the first target data.
- the network device 1100 can perform the operations performed by the second node in the embodiments shown in FIGS. 2 to 9 , which will not be described again here.
- the network device 1100 includes a transceiver unit 1101 and a processing unit 1102.
- the transceiver unit 1101 is used to obtain a first data synchronization message from the first node.
- the first data synchronization message instructs the second node to perform data synchronization.
- the first data synchronization message corresponds to the second data in the first node.
- the second data synchronization message instructs the second node to perform data synchronization.
- the data is data obtained by the first node modifying the first data in the first node according to the first data modification message from the first client.
- the processing unit 1102 is configured to process the third data stored in the second node according to the first data synchronization message and the first data status of the second node to obtain fourth data.
- the transceiver unit 1101 is also configured to send a first response message to the first node.
- the first response message indicates the data synchronization result of the second node, so that the first node processes the second data to obtain the first target data according to the data synchronization result.
- the processing unit 1102 is specifically configured to, if the first data status indicates that the content of the third data is the same as the content of the first data, change the content of the third data to Update the content of the second data to obtain the fourth data; if the first data status indicates that the content of the third data is different from the content of the first data, and the priority of the second node level is not higher than the priority level of the first node, then the content of the third data is updated to the content of the second data to obtain the fourth data.
- the processing unit 1102 is specifically configured to: if the first data status indicates that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, it is determined that the content of the fourth data is the same as the content of the third data.
- the processing unit 1102 is also configured to update the first data state to a second data state, where the second data state indicates the data of the second node and the first node. Synchronize.
- the transceiver unit 1101 is also configured to obtain a second data modification message from the second client, where the second data modification message indicates modification of the first historical data stored in the second node. .
- the processing unit 1102 is also configured to modify the first historical data according to the second data modification message to obtain fifth data.
- the transceiver unit 1101 is also configured to send a second data synchronization message to the first node, so that the first node performs data synchronization on the data currently stored in the first node to obtain the first data; receiving from the The first node's Two response messages, the second response message indicates the data synchronization result of the first node.
- the processing unit 1102 is also configured to process the fifth data according to the second response message.
- the processing unit 1102 is specifically configured to maintain the content of the fifth data if the second response message indicates that the content of the first data is synchronized to the content of the fifth data. constant. If the second response message indicates that the content of the first data is different from the content of the fifth data, the content of the fifth data is updated to the content of the first data.
- the transceiver unit 1101 is also configured to obtain a third data modification message from a third client, where the third data modification message indicates modification of the second historical data stored in the second node. .
- the processing unit 1102 is also configured to modify the second historical data according to the third data modification message to obtain sixth data.
- the transceiver unit 1101 is also configured to send a third data synchronization message to the first node, so that the first node performs data synchronization on the first target data to obtain the second target data; and receives a third data synchronization message from the first node.
- a third response message indicating the data synchronization result of the first node.
- the processing unit 1102 is also configured to process the sixth data according to the third response message.
- the processing unit 1102 is specifically configured to maintain the content of the sixth data if the third response message indicates that the content of the second target data is synchronized to the content of the sixth data. The content remains unchanged; if the third response message indicates that the content of the second target data is different from the content of the sixth data, then the content of the sixth data is updated to the content of the second target data.
- the network device 1100 can perform the operations performed by the second node in the embodiments shown in FIGS. 2 to 10 , which will not be described again here.
- Figure 12 is a schematic structural diagram of a network device provided by an embodiment of the present application.
- the network device 1200 includes: a processor 1201 and a memory 1202. One or more application programs or data are stored in the memory 1202.
- the memory 1202 may be volatile storage or persistent storage.
- the program stored in memory 1202 may include one or more modules, and each module may be used to perform a series of operations performed by network device 1200 .
- the processor 1201 can communicate with the memory 1202 to execute a series of instruction operations in the memory 1202 on the network device 1200 .
- the processor 1201 can be a central processing unit (CPU) or a single-core processor. In addition, it can also be other types of processors, such as a dual-core processor, and the details are not limited here.
- the network device 1200 may also include one or more communication interfaces 1203, and one or more operating systems, such as Windows Server TM , MacOSX TM , Unix TM , Linux TM , FreeBSD TM , etc.
- operating systems such as Windows Server TM , MacOSX TM , Unix TM , Linux TM , FreeBSD TM , etc.
- the network device 1200 can perform the operations performed by the first node or the second node in the embodiment shown in FIG. 2 to FIG. 9 , and the operations performed by the network device in the embodiment shown in FIG. 10 , which will not be described again here.
- the disclosed systems, devices and methods can be implemented in other ways.
- the device embodiments described above are merely illustrative, for example, the unit Division is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
- the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
- each functional unit in each embodiment of the present application can be integrated into one processing unit, each unit can exist physically alone, or two or more units can be integrated into one unit.
- the above integrated units can be implemented in the form of hardware or software functional units.
- the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium.
- the technical solution of the present application is essentially or contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application.
- the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program code. .
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本申请要求于2022年07月29日提交中国国家知识产权局、申请号为CN202210909739.9、发明名称为“数据处理方法、通信系统和相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application submitted to the State Intellectual Property Office of China on July 29, 2022, with the application number CN202210909739.9 and the invention name "Data processing method, communication system and related equipment", and its entire content has been approved This reference is incorporated into this application.
本申请涉及通信领域,尤其涉及数据处理方法、通信系统和相关设备。This application relates to the field of communications, and in particular to data processing methods, communications systems and related equipment.
分布式系统中存在大量的并发读、写操作,对同一个对象的并发读取或者修改可能会造成数据不一致,设置分布式锁使得一个进程同时对某个对象进行读、写操作时,需要先获取对应的读锁、写锁,从而保证了数据一致性。There are a large number of concurrent read and write operations in a distributed system. Concurrent reading or modification of the same object may cause data inconsistency. When setting a distributed lock so that a process can read and write an object at the same time, you need to first Obtain the corresponding read lock and write lock to ensure data consistency.
在网络锁(net lock)中实现了分布式锁管理器的功能,客户端发起的锁请求经由顶架交换机转发到对应的锁管理器上,提供锁管理服务。当顶架交换机出现故障时,选取备份交换机提供服务。但是,由于备份交换机并没有与顶架交换机同步数据,备份交换机启动之后原有的数据丢失,需要从零开始提供服务,无法为维持故障前的系统状态,降低了系统的可靠性。The function of the distributed lock manager is implemented in the network lock (net lock). The lock request initiated by the client is forwarded to the corresponding lock manager via the top-shelf switch to provide lock management services. When the top-shelf switch fails, a backup switch is selected to provide services. However, since the backup switch does not synchronize data with the top-shelf switch, the original data is lost after the backup switch is started, and the service needs to be provided from scratch, which cannot maintain the system state before the failure, reducing the reliability of the system.
发明内容Contents of the invention
本申请提供了数据处理方法、通信系统和相关设备,其中,应用于第一节点的数据处理方法包括,第一节点根据第一客户端的第一数据修改消息,将第一数据修改为第二数据。然后向第二节点发送第一数据同步消息,使得第二数据进行数据同步。再根据第二节点的第一响应信息所指示的数据同步结果,对第二数据进行处理,得到与第二节点中的数据内容相同的第一目标数据。通过第一节点与第二节点之间的信息交互,实现第一节点与第二节点之间的数据同步,即使其中一个节点故障,另一个节点也可以继续提供服务,提升了系统的可靠性。The present application provides a data processing method, a communication system and related equipment. The data processing method applied to the first node includes: the first node modifies the first data into the second data according to the first data modification message of the first client. . Then the first data synchronization message is sent to the second node, so that the second data is synchronized. Then, the second data is processed according to the data synchronization result indicated by the first response information of the second node, and the first target data with the same content as the data in the second node is obtained. Through information exchange between the first node and the second node, data synchronization between the first node and the second node is achieved. Even if one node fails, the other node can continue to provide services, which improves the reliability of the system.
本申请第一方面提供了一种数据处理方法,该方法应用于第一节点,包括:The first aspect of this application provides a data processing method, which is applied to the first node and includes:
第一节点与第二节点除了能够建立通信连接之外,还可以进行角色分配,如果第一节点为主节点,那么第二节点为备份节点;相应地,如果第二节点为主节点,那么第二节点为备份节点。第一节点与第一客户端建立通信连接,能够获取来自第一客户端的第一数据修改消息,该第一数据修改消息指示修改第一节点中存储的第一数据。第一节点在获取到第一数据修改消息之后,会根据第一数据修改消息,将第一数据修改为第二数据,并向第二节点发送第一数据同步消息,该第一数据同步消息指示第二节点进行数据同步,且第一数据同步消息对应于第二数据。也就是说,第二节点会根据第一数据同步消息确定是否将自身存储的数据的内容修改为第二数据的内容。之后,第一节点会接收来自于第二节点的第一响应消息,第一响应消息对应于第一数据同步消息,指示的是第二节点的数据同步结果。根据第一响应消息,第一节点会对第二数据处理,得到第一目标数据,第一目标数据的内容与第二节点当前存储的数据(也即第四数据)的内容相同。In addition to establishing communication connections, the first node and the second node can also perform role assignment. If the first node is the master node, then the second node is the backup node; accordingly, if the second node is the master node, then the second node is the backup node. The second node is the backup node. The first node establishes a communication connection with the first client and can obtain a first data modification message from the first client. The first data modification message indicates modification of the first data stored in the first node. After obtaining the first data modification message, the first node will modify the first data into the second data according to the first data modification message, and send a first data synchronization message to the second node. The first data synchronization message indicates The second node performs data synchronization, and the first data synchronization message corresponds to the second data. That is to say, the second node determines whether to modify the content of its own stored data to the content of the second data according to the first data synchronization message. Afterwards, the first node will receive a first response message from the second node. The first response message corresponds to the first data synchronization message and indicates the data synchronization result of the second node. According to the first response message, the first node processes the second data to obtain the first target data. The content of the first target data is the same as the content of the data currently stored in the second node (that is, the fourth data).
需要注意的是,随着应用场景的不同,第一节点中存储的数据所指示的内容有所不同。示例性的,如果数据处理方法应用在分布式锁场景中,第一节点中存储的数据所指示的内 容包括分布式锁的状态,具体包括锁释放或者锁占用;如果数据处理方法应用在分布式仲裁场景中,第一节点中存储的数据所指示的内容包括分布式系统中仲裁后的状态,具体包括新的主节点信息;除此之外,第一节点中存储的数据还可以指示其他的内容,具体此处不做限定。示例性的,如果数据处理方法应用在分布式缓存一致性场景中,第一节点中存储的数据所指示的内容包括某个数据的缓存信息,缓存信息指示缓存该数据的副本的客户端。It should be noted that with different application scenarios, the content indicated by the data stored in the first node is different. For example, if the data processing method is applied in a distributed lock scenario, the content indicated by the data stored in the first node The content includes the status of distributed locks, specifically including lock release or lock occupation; if the data processing method is applied in a distributed arbitration scenario, the content indicated by the data stored in the first node includes the status after arbitration in the distributed system, specifically Including new master node information; in addition, the data stored in the first node can also indicate other contents, which are not limited here. For example, if the data processing method is applied in a distributed cache consistency scenario, the content indicated by the data stored in the first node includes cache information of a certain data, and the cache information indicates the client that caches a copy of the data.
从以上技术方案可以看出,本申请具有以下优点:第一节点根据第一客户端的第一数据修改消息将第一数据修改为第二数据之后,还会向第二节点发送第一数据同步消息,使得第二数据进行数据同步。并根据第二节点的数据同步结果,对第二数据进一步处理,得到第一节点中的数据与第二节点中的数据同步。简单来说,通过第一节点与第二节点之间的信息交互,实现第一节点与第二节点之间的数据同步,即使其中一个节点故障,另一个节点也可以继续提供服务,提升了系统的可靠性。It can be seen from the above technical solution that this application has the following advantages: after the first node modifies the first data into the second data according to the first data modification message of the first client, it will also send a first data synchronization message to the second node. , so that the second data can be synchronized. And based on the data synchronization result of the second node, the second data is further processed to obtain synchronization between the data in the first node and the data in the second node. Simply put, through information exchange between the first node and the second node, data synchronization between the first node and the second node is achieved. Even if one node fails, the other node can continue to provide services, improving the system reliability.
在第一方面的一种可能的实现方式中,第一响应消息对应于第二节点中的第四数据,该第四数据是第二节点根据第一数据同步消息对第三数据进行数据同步后得到的数据。第一节点获取到第一响应消息,会根据第二数据的内容第一响应消息指示的第四数据的内容,对第二数据进行处理。具体来说,如果第四数据的内容已经同步为第二数据的内容,说明第二节点进行了数据同步,那么第一目标数据的内容即为第二数据的内容,也就是说,第一节点可以保持第二数据不变。其中,第二节点已经进行了数据同步包括第二节点的第三数据与第一节点的第一数据内容相同,或者,第三数据的内容虽然与第一数据的内容不同,但是第二节点的优先级不高于第一节点的优先级。如果第四数据的内容与第二数据的内容不同,说明第三数据的内容与第一数据的内容不同,且第二节点的优先级高于第一节点的优先级,因此第二节点保持第三数据的内容不变,即第三数据与第四数据的内容相同。在这种情况下,第一节点会将第二数据的内容更新为第四数据的内容,以得到第一目标数据。In a possible implementation of the first aspect, the first response message corresponds to fourth data in the second node, and the fourth data is obtained after the second node performs data synchronization on the third data according to the first data synchronization message. the data obtained. After obtaining the first response message, the first node will process the second data according to the content of the second data and the content of the fourth data indicated by the first response message. Specifically, if the content of the fourth data has been synchronized to the content of the second data, it means that the second node has performed data synchronization, then the content of the first target data is the content of the second data, that is to say, the first node The second data can be kept unchanged. Among them, the second node has performed data synchronization, including that the third data of the second node has the same content as the first data of the first node, or, although the content of the third data is different from the content of the first data, the content of the second node's third data is the same as that of the first data. The priority is not higher than the priority of the first node. If the content of the fourth data is different from the content of the second data, it means that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, so the second node maintains the priority of the first node. The content of the third data remains unchanged, that is, the content of the third data and the fourth data are the same. In this case, the first node will update the content of the second data to the content of the fourth data to obtain the first target data.
本申请中,第一节点发生数据修改之后,会向第二节点发送数据同步消息,并根据第二节点的响应消息确定是否还需要对修改后的数据进行处理,从而保证第一节点与第二节点之间的数据同步,更进一步地提升了系统的可靠性。In this application, after the data is modified, the first node will send a data synchronization message to the second node, and determine whether the modified data still needs to be processed based on the response message of the second node, thereby ensuring that the first node communicates with the second node. Data synchronization between nodes further improves the reliability of the system.
在第一方面的一种可能的实现方式中,第一节点中的数据发生了修改的话,第一节点的同步标志位的取值也会发生变化。如果第一节点将第一数据修改为第二数据,那么第一节点会将同步标志位的取值置为第一值,第一值指示第一节点中存储的数据发生了修改。在第一节点将处理第二数据得到第一目标数据之后,会将第一节点的同步标志位的取值更新为第二值,第二值指示第一节点中存储的数据(也即第一目标数据)与第二节点存储的数据(也即第四数据)同步。In a possible implementation of the first aspect, if the data in the first node is modified, the value of the synchronization flag bit of the first node will also change. If the first node modifies the first data into the second data, the first node will set the value of the synchronization flag bit to the first value, and the first value indicates that the data stored in the first node has been modified. After the first node processes the second data to obtain the first target data, the value of the synchronization flag bit of the first node is updated to a second value. The second value indicates the data stored in the first node (that is, the first Target data) is synchronized with the data stored in the second node (ie, fourth data).
本申请中,第一节点还可以设置同步标志位,通过查询同步标志位的取值,就可以识别第一节点与第二节点中的数据是否同步,识别方式简单。In this application, the first node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized. The identification method is simple.
在第一方面的一种可能的实现方式中,第二节点也可以接收来自于客户端的数据修改消息,并向第一节点发出数据同步消息。示例性的,在第一节点获取来自于客户端的第一数据修改消息之前,第一节点还可以获取来自第二节点的第二数据同步消息,该第二数据 同步消息指示第一节点进行数据同步,并且第二数据同步消息对应于第二节点中存储的第五数据。第五数据是第二节点根据来自于第二客户端的第二数据修改消息对第二节点中的第一历史数据修改后得到的数据。其中,第二客户端与第一客户端可以是相同的客户端,也可以是不同的客户端,具体此处不做限定。接收到第二数据同步消息之后,第一节点会根据第二数据同步消息和第一节点的第一数据状态,对第一节点中当前存储的数据进行处理,得到第一数据。In a possible implementation of the first aspect, the second node can also receive a data modification message from the client and send a data synchronization message to the first node. Exemplarily, before the first node obtains the first data modification message from the client, the first node may also obtain a second data synchronization message from the second node. The second data The synchronization message instructs the first node to perform data synchronization, and the second data synchronization message corresponds to the fifth data stored in the second node. The fifth data is data obtained by the second node modifying the first historical data in the second node according to the second data modification message from the second client. The second client and the first client may be the same client or different clients, and the details are not limited here. After receiving the second data synchronization message, the first node will process the data currently stored in the first node according to the second data synchronization message and the first data status of the first node to obtain the first data.
本申请中,第一节点和第二节点均可以接收客户端的数据修改消息,并对该消息做出响应,如果将第一节点和第二节点分别作为主节点和备份节点,本申请能实现“双活的主备同步策略”,提升了本申请技术方案的灵活性。In this application, both the first node and the second node can receive the client's data modification message and respond to the message. If the first node and the second node are used as the master node and backup node respectively, this application can achieve " "Hyperactive active-standby synchronization strategy" improves the flexibility of the technical solution of this application.
在第一方面的一种可能的实现方式中,第一节点的第一数据状态所指示的内容可以有多种,使得第一节点处理当前存储的数据的方式也有不同。具体来说,如果第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容相同,意味着第一节点需要进行同步修改,将第一节点中当前存储的数据的内容更新为第五数据的内容,得到第一数据;如果第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容不同,且第一节点的优先级不高于第二节点的优先级,意味着第一节点需要进行同步修改,将第一节点中当前存储的数据的内容更新为第五数据的内容,得到第一数据;如果第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容不同,且第一节点的优先级高于第二节点的优先级,意味着第一节点不需要进行修改,第一节点能够确定第一数据的内容与第一节点中当前存储的数据的内容相同。In a possible implementation of the first aspect, the first data status of the first node may indicate multiple contents, so that the first node processes currently stored data in different ways. Specifically, if the first data status indicates that the content of the data currently stored in the first node is the same as the content of the first historical data, it means that the first node needs to perform synchronous modification to change the content of the data currently stored in the first node. Update the content of the fifth data to obtain the first data; if the first data status indicates that the content of the data currently stored in the first node is different from the content of the first historical data, and the priority of the first node is not higher than that of the second The priority of the node means that the first node needs to be synchronously modified to update the content of the data currently stored in the first node to the content of the fifth data to obtain the first data; if the first data status indicates that the current data in the first node The content of the stored data is different from the content of the first historical data, and the priority of the first node is higher than the priority of the second node, which means that the first node does not need to be modified and the first node can determine the content of the first data. The same content as the data currently stored in the first node.
本申请中,第一节点在接收到来自第二节点的数据同步消息之后,会根据自身的数据状态确定是否需要进行数据同步。在第一节点当前存储的数据与第二节点的第一历史数据内容相同的情况下,第一节点会进行数据修改,从而保证了两个节点之间的数据一致性;在第一节点当前存储的数据与第二节点的第一历史数据内容不同的情况下,第一节点会综合两个节点的优先级,确定是否要对当前存储的数据进行修改,从而保证低优先级的节点的数据跟随高优先级的节点的数据,避免了高优先级的节点中的数据被频繁修改或者误操作。In this application, after receiving the data synchronization message from the second node, the first node determines whether data synchronization is required based on its own data status. When the data currently stored by the first node is the same as the first historical data content of the second node, the first node will modify the data to ensure data consistency between the two nodes; when the data currently stored by the first node When the data content of the second node is different from the first historical data content of the second node, the first node will combine the priorities of the two nodes to determine whether to modify the currently stored data to ensure that the data of the low-priority node follows The data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
在第一方面的一种可能的实现方式中,在第一节点得到第一数据之后,会向第二节点发送对应于所述第二数据同步消息的第二响应消息。其中,第二响应消息指示第一节点的数据同步结果,也即指示第一数据的内容,使得第二节点根据第二响应消息,对第五数据进行处理,以使处理后的第五数据的内容与第一数据的内容相同,即使得第一节点和第二节点的数据同步。In a possible implementation of the first aspect, after the first node obtains the first data, a second response message corresponding to the second data synchronization message is sent to the second node. The second response message indicates the data synchronization result of the first node, that is, the content of the first data, so that the second node processes the fifth data according to the second response message, so that the processed fifth data is The content is the same as the content of the first data, that is, the data of the first node and the second node are synchronized.
本申请中,第一节点根据第二节点的数据同步消息,对第一节点当前存储的数据处理得到第一数据之后,还会向第二节点反馈数据同步结果,使得第二节点进一步处理自身存储的数据,从而保证了第一节点与第二节点的数据同步,进一步提升了系统的可靠性。In this application, the first node processes the data currently stored by the first node to obtain the first data according to the data synchronization message of the second node, and then feeds back the data synchronization result to the second node, so that the second node further processes its own storage. data, thereby ensuring data synchronization between the first node and the second node, further improving the reliability of the system.
在第一方面的一种可能的实现方式中,在第一节点得到第一数据之后,第一节点的数据状态会进行修改,将同步标志位的取值置为第二值,以表示第一节点和第二节点的数据已经同步。 In a possible implementation of the first aspect, after the first node obtains the first data, the data status of the first node is modified, and the value of the synchronization flag bit is set to the second value to represent the first The data of the node and the second node have been synchronized.
在第一方面的一种可能的实现方式中,在第一节点得到第一目标数据之后,第一节点还可以获取来自第二节点的第三数据同步消息,该第三数据同步消息指示第一节点进行数据同步,并且第三数据同步消息对应于第二节点中存储的第六数据。第六数据是第二节点根据来自于第三客户端的第三数据修改消息对第二节点中的第二历史数据修改后得到的数据。其中,第三客户端、第二客户端和第一客户端中的任意两个客户端,也可以是不同的客户端,具体此处不做限定。接收到第三数据同步消息之后,第一节点会根据第三数据同步消息和第一节点的第二数据状态,对第一目标数据进行处理,得到第二目标数据。In a possible implementation of the first aspect, after the first node obtains the first target data, the first node may also obtain a third data synchronization message from the second node, the third data synchronization message indicating the first The node performs data synchronization, and the third data synchronization message corresponds to the sixth data stored in the second node. The sixth data is data obtained by the second node modifying the second historical data in the second node according to the third data modification message from the third client. Among them, any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here. After receiving the third data synchronization message, the first node processes the first target data according to the third data synchronization message and the second data status of the first node to obtain the second target data.
本申请中,第一节点和第二节点均可以接收客户端的数据修改消息,并对该消息做出响应。如果将第一节点和第二节点分别作为主节点和备份节点,本申请能实现“双活的主备同步策略”,提升了本申请技术方案的灵活性。另外,相较于只能有主节点接收客户端的消息,再由备份节点进行响应的方案,本申请技术方案降低了响应的时延。In this application, both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. In addition, compared with the solution where only the master node can receive the client's message and then the backup node responds, the technical solution of this application reduces the response delay.
在第一方面的一种可能的实现方式中,第一节点的第二数据状态所指示的内容可以有多种,使得第一节点处理第一目标数据的方式也有不同。具体来说,如果第二数据状态指示第一节点中第一目标数据的内容与第二历史数据的内容相同,意味着第一节点需要进行同步修改,将第一节点中第一目标数据的内容更新为第六数据的内容,得到第二目标数据;如果第二数据状态指示第一节点中第一目标数据的内容与第二历史数据的内容不同,且第一节点的优先级不高于第二节点的优先级,意味着第一节点需要进行同步修改,将第一节点中第一目标数据的内容更新为第六数据的内容,得到第二目标数据;如果第二数据状态指示第一节点中第一目标数据的内容与第二历史数据的内容不同,且第一节点的优先级高于第二节点的优先级,意味着第一节点不需要进行修改,第一节点能够确定第二目标数据的内容与第一节点中第一目标数据的内容相同。In a possible implementation of the first aspect, the second data status of the first node may indicate multiple contents, so that the first node processes the first target data in different ways. Specifically, if the second data status indicates that the content of the first target data in the first node is the same as the content of the second historical data, it means that the first node needs to perform synchronous modification to change the content of the first target data in the first node. Update to the content of the sixth data to obtain the second target data; if the second data status indicates that the content of the first target data in the first node is different from the content of the second historical data, and the priority of the first node is not higher than that of the second historical data, The priority of the second node means that the first node needs to be modified synchronously to update the content of the first target data in the first node to the content of the sixth data to obtain the second target data; if the second data status indicates that the first node The content of the first target data is different from the content of the second historical data, and the priority of the first node is higher than the priority of the second node, which means that the first node does not need to be modified and the first node can determine the second target. The content of the data is the same as the content of the first target data in the first node.
本申请中,第一节点在接收到来自第二节点的数据同步消息之后,会根据自身的数据状态确定是否需要进行数据同步。在第一节点第一目标数据与第二节点的第二历史数据内容相同的情况下,第一节点会进行数据修改,从而保证了两个节点之间的数据一致性;在第一节点第一目标数据与第二节点的第二历史数据内容不同的情况下,第一节点会综合两个节点的优先级,确定是否对第一目标数据进行修改了,从而保证低优先级的节点的数据跟随高优先级的节点的数据,避免了高优先级的节点中的数据被频繁修改或者误操作。In this application, after receiving the data synchronization message from the second node, the first node determines whether data synchronization is required based on its own data status. When the first target data of the first node is the same as the second historical data content of the second node, the first node will modify the data to ensure data consistency between the two nodes; when the first node first When the content of the target data is different from the second historical data of the second node, the first node will combine the priorities of the two nodes to determine whether the first target data has been modified, thereby ensuring that the data of the low-priority node follows. The data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
在第一方面的一种可能的实现方式中,在第一节点得到第二目标数据之后,会向第二节点发送对应于所述第三数据同步消息的第三响应消息。其中,第三响应消息指示第一节点的数据同步结果,也即指示第二目标数据的内容,使得第二节点根据第三响应消息,对第六数据进行处理,以使处理后的第六数据的内容与第二目标数据的内容相同,即使得第一节点和第二节点的数据同步。In a possible implementation of the first aspect, after the first node obtains the second target data, a third response message corresponding to the third data synchronization message is sent to the second node. The third response message indicates the data synchronization result of the first node, that is, the content of the second target data, so that the second node processes the sixth data according to the third response message, so that the processed sixth data The content of is the same as the content of the second target data, that is, the data of the first node and the second node are synchronized.
本申请中,第一节点根据第二节点的数据同步消息,对第一节点的第一目标数据处理得到第二目标数据之后,还可以向第二节点反馈数据同步结果,使得第二节点进一步处理自身存储的数据,从而保证了第一节点与第二节点的数据同步,进一步提升了系统的可靠性。In this application, after the first node processes the first target data of the first node to obtain the second target data according to the data synchronization message of the second node, it can also feed back the data synchronization result to the second node, so that the second node can further process it. The data stored by itself ensures the data synchronization between the first node and the second node, further improving the reliability of the system.
在第一方面的一种可能的实现方式中,在第一节点得到第二目标数据之后,第一节点 的数据状态会进行修改,将同步标志位的取值置为第二值,以表示第一节点和第二节点的数据已经同步。In a possible implementation of the first aspect, after the first node obtains the second target data, the first node The data status of the node will be modified, and the value of the synchronization flag bit will be set to the second value to indicate that the data of the first node and the second node have been synchronized.
在第一方面的一种可能的实现方式中,在第一节点得到第一目标数据之后,第一节点还会向第一客户端发送第四响应消息,第四响应消息中携带第一目标数据。In a possible implementation of the first aspect, after the first node obtains the first target data, the first node also sends a fourth response message to the first client, and the fourth response message carries the first target data. .
本申请中,第一节点不仅能获取客户端的数据修改消息,还能向客户端反馈修改同步后的最终结果。类似的,第二节点也可以获取客户端的数据修改消息,并向客户端反馈修改同步后的最终结果。也就是说,本申请中,第一节点和第二节点,均可以获取请求并反馈结果,从而实现“双活的主备同步策略”,进一步提升了本申请技术方案的灵活性和实用性。In this application, the first node can not only obtain the client's data modification message, but also feed back to the client the final result after modification and synchronization. Similarly, the second node can also obtain the client's data modification message and feed back the final result after modification and synchronization to the client. That is to say, in this application, both the first node and the second node can obtain the request and feedback the results, thereby realizing the "dual-active active and backup synchronization strategy", further improving the flexibility and practicality of the technical solution of this application.
本申请第二方面提供了一种数据处理方法,该方法应用于第二节点,包括:The second aspect of this application provides a data processing method, which is applied to the second node and includes:
第二节点与第一节点建立通信连接,能够获取来自于第一节点的第一数据同步消息。第一数据同步消息用于指示第二节点进行数据同步,第一数据同步消息对应于第一节点中的第二数据,第二数据是第一节点根据来自于第一客户端的第一数据修改消息将第一节点中的第一数据修改后得到的数据。第一节点与第二节点还可以进行角色分配,如果第一节点为主节点,那么第二节点为备份节点;相应地,如果第二节点为主节点,那么第二节点为备份节点。第二节点得到第一数据同步消息之后,会根据第一数据同步消息和第二节点的第一数据状态,对第二节点中存储的第三数据进行处理,得到第四数据。第二节点会向第一节点发送第一响应消息,该第一响应消息指示第二节点的数据同步结果,以使第一节点根据数据同步结果,处理第二数据得到第一目标数据,最终第一节点中的第一目标数据与第二节点中的第四数据的数据内容相同,实现了不同节点之间的数据同步。The second node establishes a communication connection with the first node and can obtain the first data synchronization message from the first node. The first data synchronization message is used to instruct the second node to perform data synchronization. The first data synchronization message corresponds to the second data in the first node. The second data is the first node modifying the message according to the first data from the first client. Data obtained by modifying the first data in the first node. The first node and the second node can also perform role assignment. If the first node is the master node, then the second node is the backup node. Correspondingly, if the second node is the master node, then the second node is the backup node. After the second node obtains the first data synchronization message, it will process the third data stored in the second node according to the first data synchronization message and the first data status of the second node to obtain fourth data. The second node will send a first response message to the first node. The first response message indicates the data synchronization result of the second node, so that the first node processes the second data according to the data synchronization result to obtain the first target data. Finally, the second node The first target data in one node and the fourth data in the second node have the same data content, thus realizing data synchronization between different nodes.
需要注意的是,随着应用场景的不同,第二节点中存储的数据所指示的内容有所不同。示例性的,如果数据处理方法应用在分布式锁场景中,第二节点中存储的数据所指示的内容包括分布式锁的状态,具体包括锁释放或者锁占用;如果数据处理方法应用在分布式仲裁场景中,第二节点中存储的数据所指示的内容包括分布式系统中仲裁后的状态,具体包括新的主节点信息;除此之外,第二节点中存储的数据还可以指示其他的内容,具体此处不做限定。示例性的,如果数据处理方法应用在分布式缓存一致性场景中,第二节点中存储的数据所指示的内容包括某个数据的缓存信息,缓存信息指示缓存该数据的副本的客户端。It should be noted that with different application scenarios, the content indicated by the data stored in the second node is different. For example, if the data processing method is applied in a distributed lock scenario, the content indicated by the data stored in the second node includes the status of the distributed lock, specifically including lock release or lock occupation; if the data processing method is applied in a distributed lock scenario, In the arbitration scenario, the data stored in the second node indicates the status after arbitration in the distributed system, specifically including the new master node information; in addition, the data stored in the second node can also indicate other The content is not specifically limited here. For example, if the data processing method is applied in a distributed cache consistency scenario, the content indicated by the data stored in the second node includes cache information of a certain data, and the cache information indicates the client that caches a copy of the data.
本申请中,第一节点数据修改之后会向第二节点发送数据同步消息,使得第二节点结合自身的数据状态确定数据同步结果,并将结果反馈给第一节点,使得第一节点进一步处理自身数据,最终实现第一节点与第二节点之间的数据同步,提升系统的可靠性。In this application, after the data of the first node is modified, it will send a data synchronization message to the second node, so that the second node determines the data synchronization result based on its own data status, and feeds the result back to the first node, so that the first node further processes itself. data, ultimately achieving data synchronization between the first node and the second node, improving the reliability of the system.
在第二方面的一种可能的实现方式中,由于第二节点的第一数据状态有多种可能,因此第二节点的数据同步结果也有多种情况。具体来说,如果第二节点的第一数据状态指示了第二节点中第三数据的内容与第一节点中第一数据的内容相同,说明第一节点与第二节点之前就处于数据同步的状态,在第一节点的数据发生修改的情况下,第二节点需要同步修改,将第三数据的内容更新为第二数据的内容,以得到与第二数据同步的第四数据。如果第二节点的第一数据状态指示第三数据的内容与第一数据的内容不同,且第二节点的优 先级不高于第一节点的优先级,说明第一节点与第二节点之前并不处于数据同步状态,并且第二节点的数据需要跟随第一节点的数据,因此,第二节点会将第三数据的内容更新为第二数据的内容,以得到与第二数据同步的第四数据。In a possible implementation of the second aspect, since the first data status of the second node has multiple possibilities, the data synchronization results of the second node also have multiple possibilities. Specifically, if the first data status of the second node indicates that the content of the third data in the second node is the same as the content of the first data in the first node, it means that the first node and the second node were in data synchronization before. status, when the data of the first node is modified, the second node needs to be modified synchronously and update the content of the third data to the content of the second data to obtain the fourth data synchronized with the second data. If the first data status of the second node indicates that the content of the third data is different from the content of the first data, and the priority of the second node The priority is not higher than the priority of the first node, which means that the first node and the second node were not in a data synchronization state before, and the data of the second node needs to follow the data of the first node. Therefore, the second node will The content of the third data is updated to the content of the second data to obtain the fourth data synchronized with the second data.
本申请中,第二节点在接收到来自第一节点的数据同步消息之后,会根据自身的数据状态确定是否需要进行数据同步。在第二节点的第三数据与第一节点的第一数据内容相同的情况下,第二节点会进行数据修改,从而保证了两个节点之间的数据一致性;在第三数据与第一数据内容不同的情况下,第二节点会综合两个节点的优先级,确定是否对第三数据进行修改,从而保证低优先级的节点的数据跟随高优先级的节点的数据,避免了高优先级的节点中的数据被频繁修改或者误操作。In this application, after receiving the data synchronization message from the first node, the second node determines whether data synchronization is required based on its own data status. When the third data of the second node is the same as the first data of the first node, the second node will modify the data to ensure data consistency between the two nodes; when the third data is the same as the first data When the data content is different, the second node will combine the priorities of the two nodes to determine whether to modify the third data, thereby ensuring that the data of the low-priority node follows the data of the high-priority node, avoiding high priority The data in level nodes is frequently modified or misoperated.
在第二方面的一种可能的实现方式中,如果第一数据状态指示第三数据的内容与第一数据的内容不同,并且第二节点的优先级高于第一节点的优先级,说明第一节点与第二节点之前并不处于数据同步状态,并且第一节点的数据需要跟随第二节点的数据,第二节点中的第三数据保持不变,也即确定第四数据的内容与第三数据的内容相同。In a possible implementation of the second aspect, if the first data status indicates that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, it means that the content of the third data is different from the content of the first data. One node and the second node were not in a data synchronization state before, and the data of the first node needs to follow the data of the second node. The third data in the second node remains unchanged, that is, it is determined that the content of the fourth data is the same as that of the second node. The contents of the three data are the same.
本申请中,在第三数据与第一数据内容不同,且第二节点的优先级高于第一节点的优先级的情况下,第二节点并不会修改第三数据的内容,使得低优先级的节点的数据跟随高优先级的节点的数据,避免了高优先级的节点中的数据被频繁修改或者误操作。In this application, when the content of the third data is different from that of the first data, and the priority of the second node is higher than the priority of the first node, the second node will not modify the content of the third data, so that the lower priority The data of high-level nodes follows the data of high-priority nodes, preventing data in high-priority nodes from being frequently modified or misoperated.
在第二方面的一种可能的实现方式中,第二节点在得到第四数据之后还会将第一数据状态更新为第二数据状态,该第二数据状态指示第二节点与第一节点的数据同步。具体来说,可以是将第二节点的同步标志位的取值置为第二值。In a possible implementation of the second aspect, after obtaining the fourth data, the second node will also update the first data state to a second data state, where the second data state indicates the relationship between the second node and the first node. data synchronization. Specifically, the value of the synchronization flag bit of the second node may be set to the second value.
本申请中,第二节点还可以设置同步标志位,通过查询同步标志位的取值,就可以识别第一节点与第二节点中的数据是否同步,识别方式简单。In this application, the second node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized. The identification method is simple.
在第二方面的一种可能的实现方式中,第二节点也可以接收来自于客户端的数据修改消息,并向第一节点发出数据同步消息。示例性的,在获取来自于第一节点的第一数据同步消息之前,第二节点还可以获取来自于第二客户端的第二数据修改消息,第二数据修改消息指示修改第二节点中存储的第一历史数据。第二节点会根据第二数据修改消息,修改第一历史数据,得到第五数据,然后向第一节点发送第二数据同步消息,以使第一节点对第一节点当前存储的数据进行数据同步得到第一数据。第一节点进行数据同步之后会向第二节点发送第二响应消息。第二节点接收来自于第一节点的第二响应消息,该第二响应消息指示第一节点的数据同步结果,并根据第二响应消息,处理第五数据,使得处理后的第五数据与第一数据同步。其中,第二客户端与第一客户端可以是相同的客户端,也可以是不同的客户端,具体此处不做限定。In a possible implementation of the second aspect, the second node can also receive a data modification message from the client and send a data synchronization message to the first node. Exemplarily, before obtaining the first data synchronization message from the first node, the second node may also obtain a second data modification message from the second client. The second data modification message indicates modifying the data stored in the second node. First historical data. The second node will modify the first historical data according to the second data modification message, obtain the fifth data, and then send the second data synchronization message to the first node, so that the first node can perform data synchronization on the data currently stored by the first node. Get the first data. After performing data synchronization, the first node will send a second response message to the second node. The second node receives a second response message from the first node, the second response message indicates the data synchronization result of the first node, and processes the fifth data according to the second response message, so that the processed fifth data is consistent with the first node. One data synchronization. The second client and the first client may be the same client or different clients, and the details are not limited here.
在第二方面的一种可能的实现方式中,第二节点得到处理后的第五数据之后,还会向第二客户端发送响应消息,该响应消息中携带处理后的第五数据。In a possible implementation manner of the second aspect, after the second node obtains the processed fifth data, it also sends a response message to the second client, and the response message carries the processed fifth data.
本申请中,第一节点和第二节点均可以接收客户端的数据修改消息,并对该消息做出响应。如果将第一节点和第二节点分别作为主节点和备份节点,本申请能实现“双活的主备同步策略”,提升了本申请技术方案的灵活性。另外,相较于只能有主节点接收客户端的消息,再由备份节点进行响应的方案,本申请技术方案降低了响应的时延。 In this application, both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. In addition, compared with the solution where only the master node can receive the client's message and then the backup node responds, the technical solution of this application reduces the response delay.
在第二方面的一种可能的实现方式中,由于第二响应消息指示的内容不同,第二节点处理第五数据的方式也有所不同。如果第二响应消息指示第一数据的内容同步为第五数据的内容,那么第二节点会保持第五数据的内容不变,也即处理后的第五数据与第五数据的内容相同。如果第二响应消息指示第一数据的内容与第五数据的内容不同,那么意味着第一节点的优先级高于第二节点的优先级,第二节点需要对第五数据进行更新,将第五数据的内容更新为第一数据的内容,得到修改后的第五数据。In a possible implementation manner of the second aspect, since the content indicated by the second response message is different, the way in which the second node processes the fifth data is also different. If the second response message indicates that the content of the first data is synchronized to the content of the fifth data, then the second node will keep the content of the fifth data unchanged, that is, the content of the processed fifth data is the same as the fifth data. If the second response message indicates that the content of the first data is different from the content of the fifth data, it means that the priority of the first node is higher than the priority of the second node, and the second node needs to update the fifth data and change the fifth data. The content of the fifth data is updated to the content of the first data, and the modified fifth data is obtained.
本申请中,在第二节点根据第二客户端的数据修改消息修改数据之后,会向第一节点发送数据同步消息,并根据第一节点的同步结果,确定是否进一步处理根据数据修改消息修改得到的数据,从而保证第一节点与第二节点中的数据同步,进一步提升了系统的可靠性。In this application, after the second node modifies the data according to the data modification message of the second client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message according to the synchronization result of the first node. data, thereby ensuring that the data in the first node and the second node are synchronized, further improving the reliability of the system.
在第二方面的一种可能的实现方式中,第二节点在得到修改后的第五数据之后,会将同步标志位的取值置为第二值,第二值指示第一节点与第二节点的数据同步。In a possible implementation of the second aspect, after obtaining the modified fifth data, the second node will set the value of the synchronization flag bit to a second value, and the second value indicates that the first node and the second node Node data synchronization.
在第二方面的一种可能的实现方式中,第二节点可以在不同的时间点接收多个客户端的数据修改消息。示例性的,在向第一节点发送第一响应消息之后,第二节点可以获取来自于第三客户端的第三数据修改消息,第三数据修改消息指示修改第二节点中存储的第二历史数据。其中,第三客户端、第二客户端和第一客户端中的任意两个客户端,也可以是不同的客户端,具体此处不做限定。根据第三数据修改消息,修改第二历史数据,得到第六数据。第二节点会向第一节点发送第三数据同步消息,以使第一节点对第一目标数据进行数据同步得到第二目标数据。第一节点得到第二目标数据之后,会向第二节点发送第三响应消息,该第三响应消息指示第一节点的数据同步结果。第二节点接收来自于第一节点的第三响应消息,并根据第三响应消息,处理第六数据,使得处理后的第五数据与第二目标数据同步。In a possible implementation of the second aspect, the second node may receive data modification messages from multiple clients at different points in time. Exemplarily, after sending the first response message to the first node, the second node may obtain a third data modification message from the third client. The third data modification message indicates modifying the second historical data stored in the second node. . Among them, any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here. According to the third data modification message, the second historical data is modified to obtain the sixth data. The second node will send a third data synchronization message to the first node, so that the first node performs data synchronization on the first target data to obtain the second target data. After obtaining the second target data, the first node sends a third response message to the second node. The third response message indicates the data synchronization result of the first node. The second node receives the third response message from the first node, and processes the sixth data according to the third response message, so that the processed fifth data is synchronized with the second target data.
在第二方面的一种可能的实现方式中,第二节点得到处理后的第六数据之后,还会向第三客户端发送响应消息,该响应消息中携带处理后的第六数据。In a possible implementation of the second aspect, after obtaining the processed sixth data, the second node also sends a response message to the third client, and the response message carries the processed sixth data.
本申请中,第二节点能够在不同时刻接收客户端的数据修改消息,并做出响应;也可以接收不同客户端的数据修改消息,丰富了本申请技术方案的应用场景,提升了技术方案的实用性。In this application, the second node can receive data modification messages from clients at different times and respond; it can also receive data modification messages from different clients, which enriches the application scenarios of the technical solution of this application and improves the practicality of the technical solution. .
在第二方面的一种可能的实现方式中,由于第三响应消息指示的内容不同,第二节点处理第六数据的方式也有所不同。如果第三响应消息指示第二目标数据的内容同步为第六数据的内容,那么第二节点会保持第六数据的内容不变,也即处理后的第六数据与第六数据的内容相同。如果第三响应消息指示第二目标数据的内容与第六数据的内容不同,那么意味着第一节点的优先级高于第二节点的优先级,第二节点需要对第六数据进行更新,将第六数据的内容更新为第二目标数据的内容,得到修改后的第六数据。In a possible implementation manner of the second aspect, since the content indicated by the third response message is different, the way in which the second node processes the sixth data is also different. If the third response message indicates that the content of the second target data is synchronized to the content of the sixth data, then the second node will keep the content of the sixth data unchanged, that is, the content of the processed sixth data is the same as the sixth data. If the third response message indicates that the content of the second target data is different from the content of the sixth data, it means that the priority of the first node is higher than the priority of the second node, and the second node needs to update the sixth data. The content of the sixth data is updated to the content of the second target data, and the modified sixth data is obtained.
本申请中,在第二节点根据第三客户端的数据修改消息修改数据之后,会向第一节点发送数据同步消息,并根据第一节点的同步结果,确定是否进一步处理根据数据修改消息修改得到的数据,从而保证第一节点与第二节点中的数据同步,进一步提升了系统的可靠性。 In this application, after the second node modifies the data according to the data modification message of the third client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message according to the synchronization result of the first node. data, thereby ensuring that the data in the first node and the second node are synchronized, further improving the reliability of the system.
在第二方面的一种可能的实现方式中,第二节点在得到修改后的第六数据之后,会将同步标志位的取值置为第二值,第二值指示第一节点与第二节点的数据同步。In a possible implementation of the second aspect, after obtaining the modified sixth data, the second node will set the value of the synchronization flag bit to a second value, and the second value indicates that the first node and the second node Node data synchronization.
本申请实施例第三方面提供了一种通信系统,通信系统包括第一节点和第二节点,第一节点用于执行前述第一方面以及第一方面中任一种可能的实现方式所示的方法,第二节点用于执行前述第二方面以及第二方面的任一种可能的实现方式所示的方法。The third aspect of the embodiment of the present application provides a communication system. The communication system includes a first node and a second node. The first node is used to perform the aforementioned first aspect and any of the possible implementations of the first aspect. Method, the second node is configured to execute the method shown in the aforementioned second aspect and any possible implementation manner of the second aspect.
本申请第四方面提供了一种网络设备,该网络设备包括第一节点,包括:A fourth aspect of this application provides a network device. The network device includes a first node, including:
收发单元,用于获取来自于第一客户端的第一数据修改消息,第一数据修改消息指示修改第一节点中存储的第一数据。A transceiver unit configured to obtain a first data modification message from the first client, where the first data modification message indicates modification of the first data stored in the first node.
处理单元,用于根据第一数据修改消息,修改第一数据,得到第二数据。A processing unit, configured to modify the first data according to the first data modification message to obtain the second data.
收发单元,还用于向第二节点发送第一数据同步消息,第一数据同步消息携带第二数据,以使第二节点进行数据同步。The transceiver unit is also configured to send a first data synchronization message to the second node, where the first data synchronization message carries the second data, so that the second node performs data synchronization.
收发单元,还用于接收来自于第二节点的第一响应消息,第一响应消息指示第二节点的数据同步结果。The transceiver unit is also configured to receive a first response message from the second node, where the first response message indicates the data synchronization result of the second node.
处理单元,还用于根据第一响应消息,处理第二数据,得到第一目标数据。The processing unit is also configured to process the second data according to the first response message to obtain the first target data.
该网络设备用于执行前述第一方面以及第一方面的任一种可能的实现方式所示的方法。The network device is configured to perform the method shown in the aforementioned first aspect and any possible implementation manner of the first aspect.
本申请第五方面提供了一种网络设备,该网络设备包括第二节点,包括:The fifth aspect of this application provides a network device. The network device includes a second node, including:
收发单元,用于获取来自于第一节点的第一数据同步消息,第一数据同步消息指示第二节点进行数据同步,第一数据同步消息对应于第一节点中的第二数据,第二数据是第一节点根据来自于第一客户端的第一数据修改消息将第一节点中的第一数据修改后得到的数据。A transceiver unit configured to obtain a first data synchronization message from a first node. The first data synchronization message instructs the second node to perform data synchronization. The first data synchronization message corresponds to the second data in the first node. The second data It is the data obtained by the first node modifying the first data in the first node according to the first data modification message from the first client.
处理单元,用于根据第一数据同步消息和第二节点的第一数据状态,处理第二节点中存储的第三数据,得到第四数据。The processing unit is configured to process the third data stored in the second node according to the first data synchronization message and the first data status of the second node to obtain fourth data.
收发单元,还用于向第一节点发送第一响应消息,第一响应消息指示第二节点的数据同步结果,以使第一节点根据数据同步结果,处理第二数据得到第一目标数据。The transceiver unit is also configured to send a first response message to the first node. The first response message indicates the data synchronization result of the second node, so that the first node processes the second data to obtain the first target data according to the data synchronization result.
该网络设备用于执行前述第二方面以及第二方面的任一种可能的实现方式所示的方法。The network device is configured to perform the method shown in the aforementioned second aspect and any possible implementation manner of the second aspect.
本申请第六方面提供了一种网络设备,包括处理器,存储器和通信接口,处理器,存储器和通信接口相连,处理器用于执行前述第一方面以及第一方面的任一种可能的实现方式所示的方法。The sixth aspect of this application provides a network device, including a processor, a memory and a communication interface. The processor, the memory and the communication interface are connected. The processor is configured to execute the aforementioned first aspect and any possible implementation of the first aspect. method shown.
本申请第七方面提供了一种网络设备,包括处理器,存储器和通信接口,处理器,存储器和通信接口相连,处理器用于执行前述第二方面以及第二方面的任一种可能的实现方式所示的方法。The seventh aspect of this application provides a network device, including a processor, a memory and a communication interface. The processor, the memory and the communication interface are connected. The processor is configured to execute the aforementioned second aspect and any possible implementation of the second aspect. method shown.
本申请第八方面提供了一种计算机可读存储介质,计算机可读存储介质中保存有程序,当计算机执行该程序时,执行第一方面、第一方面的任一种可能的实现方式、第二方面以及第二方面的任一种可能的实现方式所示的方法。The eighth aspect of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a program. When the computer executes the program, the first aspect, any possible implementation manner of the first aspect, and the third aspect are executed. The method shown in the second aspect and any possible implementation manner of the second aspect.
本申请第九方面提供了一种计算机程序产品,其特征在于,当计算机程序产品在计算机上执行时,该计算机执行第一方面、第一方面的任一种可能的实现方式、第二方面以及第二方面的任一种可能的实现方式所示的方法。 A ninth aspect of the present application provides a computer program product, which is characterized in that when the computer program product is executed on a computer, the computer executes the first aspect, any possible implementation of the first aspect, the second aspect, and The method shown in any possible implementation of the second aspect.
本申请第四方面至第九方面中任一方面所示的有益效果,如第一方面及第一方面的任一种实现方式,和/或,第二方面及第二方面的任一种实现方式所示,此处不再赘述。The beneficial effects shown in any one of the fourth to ninth aspects of the present application are the first aspect and any implementation of the first aspect, and/or the second aspect and any implementation of the second aspect. The method is shown and will not be described again here.
图1a为本申请实施例提供的系统架构的一个示意图;Figure 1a is a schematic diagram of the system architecture provided by the embodiment of the present application;
图1b为本申请实施例提供的系统架构的另一个示意图;Figure 1b is another schematic diagram of the system architecture provided by the embodiment of the present application;
图2为本申请实施例提供的数据处理方法的一个流程示意图;Figure 2 is a schematic flow chart of the data processing method provided by the embodiment of the present application;
图3为本申请实施例提供的数据处理方法的一个示意图;Figure 3 is a schematic diagram of the data processing method provided by the embodiment of the present application;
图4为本申请实施例提供的数据处理方法的另一个示意图;Figure 4 is another schematic diagram of the data processing method provided by the embodiment of the present application;
图5a为本申请实施例提供的读-写场景的一个示意图;Figure 5a is a schematic diagram of the read-write scenario provided by the embodiment of the present application;
图5b为本申请实施例提供的写-写场景的一个示意图;Figure 5b is a schematic diagram of the write-write scenario provided by the embodiment of the present application;
图6为本申请实施例提供的数据处理方法的另一个示意图;Figure 6 is another schematic diagram of the data processing method provided by the embodiment of the present application;
图7为本申请实施例提供的数据处理方法的另一个示意图;Figure 7 is another schematic diagram of the data processing method provided by the embodiment of the present application;
图8为本申请实施例提供的数据处理方法的另一个流程示意图;Figure 8 is another schematic flow chart of the data processing method provided by the embodiment of the present application;
图9为本申请实施例提供的数据处理方法的另一个流程示意图;Figure 9 is another schematic flow chart of the data processing method provided by the embodiment of the present application;
图10为本申请实施例提供的通信系统的一个示意图;Figure 10 is a schematic diagram of a communication system provided by an embodiment of the present application;
图11为本申请实施例提供的网络设备的一个结构示意图;Figure 11 is a schematic structural diagram of a network device provided by an embodiment of the present application;
图12为本申请实施例提供的网络设备的另一个结构示意图。Figure 12 is another schematic structural diagram of a network device provided by an embodiment of the present application.
本申请提供了数据处理方法、通信系统和相关设备,其中,应用于第一节点的数据处理方法包括,第一节点根据第一客户端的第一数据修改消息,将第一数据修改为第二数据。然后向第二节点发送第一数据同步消息,使得第二数据进行数据同步。再根据第二节点的第一响应信息所指示的数据同步结果,对第二数据进行处理,得到与第二节点中的数据内容相同的第一目标数据。通过第一节点与第二节点之间的信息交互,实现第一节点与第二节点之间的数据同步,即使其中一个节点故障,另一个节点也可以继续提供服务,提升了系统的可靠性。The present application provides a data processing method, a communication system and related equipment. The data processing method applied to the first node includes: the first node modifies the first data into the second data according to the first data modification message of the first client. . Then the first data synchronization message is sent to the second node, so that the second data is synchronized. Then, the second data is processed according to the data synchronization result indicated by the first response information of the second node, and the first target data with the same content as the data in the second node is obtained. Through information exchange between the first node and the second node, data synchronization between the first node and the second node is achieved. Even if one node fails, the other node can continue to provide services, which improves the reliability of the system.
下面结合附图,对本申请的实施例进行描述。本领域普通技术人员可知,随着技术的发展和新场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The embodiments of the present application are described below with reference to the accompanying drawings. Persons of ordinary skill in the art know that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的术语在适当情况下可以互换,这仅仅是描述本申请的实施例中对相同属性的对象在描述时所采用的区分方式。此外,术语“包括”和“具有”以及他们的任何变形,其目的在于覆盖不排他的包含,以便包含一系列单元的过程、方法、系统、产品或设备不必限于那些单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它单元。另外,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合, 包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。The terms "first", "second", etc. in the description and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the terms so used are interchangeable under appropriate circumstances, and are merely a way of distinguishing objects with the same attributes in describing the embodiments of the present application. Furthermore, the terms "include" and "have" and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product or apparatus comprising a series of elements need not be limited to those elements but may include none Other elements that are clearly listed or inherent to such processes, methods, products or equipment. In addition, "at least one" means one or more, and "plurality" means two or more. "And/or" describes the association of associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A exists alone, A and B exist simultaneously, and B exists alone, where A, B can be singular or plural. The character "/" generally indicates that the related objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, Including any combination of single items (items) or plural items (items). For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple .
首先,请参阅图1a和图1b,图1a和图1b均为本申请实施例提供的系统架构示意图。First, please refer to Figure 1a and Figure 1b. Figure 1a and Figure 1b are both schematic diagrams of system architecture provided by embodiments of the present application.
如图1a所示,节点S0至节点S6部署在叶脊(spine-leaf)拓扑架构的中,在spine层(也即图1a中的上层)部署主节点,在leaf层(也即图1a中的下层)部署备份节点。spine层的节点与leaf层的节点以全网格的方式建立连接,也即spine层的任意一个节点与leaf层的任意一个节点之间建立了连接关系。As shown in Figure 1a, nodes S0 to S6 are deployed in a spine-leaf topology. The master node is deployed in the spine layer (i.e., the upper layer in Figure 1a), and in the leaf layer (i.e., the upper layer in Figure 1a). lower layer) to deploy backup nodes. Nodes in the spine layer are connected to nodes in the leaf layer in a full grid manner, that is, a connection relationship is established between any node in the spine layer and any node in the leaf layer.
示例性,在图1a所示实施例中,假设包含了服务器A1至服务器A9的服务器集群,所对应的主节点为节点S1,所对应的备份节点为节点S6。服务器集群中不同的服务器直接连接的节点可以相同,也可以不同,具体此处不做限定。在图1a所示实施例中,服务器A1、服务器A2和服务器A3均与节点S3直接连接;服务器A4与节点S4直接连接。For example, in the embodiment shown in Figure 1a, assume that the server cluster includes servers A1 to A9, the corresponding master node is node S1, and the corresponding backup node is node S6. The nodes directly connected to different servers in the server cluster can be the same or different, and there is no specific limit here. In the embodiment shown in Figure 1a, server A1, server A2 and server A3 are all directly connected to node S3; server A4 is directly connected to node S4.
需要注意的是,图1a只是对本申请提供的系统架构的一个示意,在实际应用中,各个节点所组成的架构还可以有多种情况,例如,上层节点的数量与下层节点的数量一致;或者各个节点组成更多或者更少层级的架构,具体此处不做限定。It should be noted that Figure 1a is only a diagram of the system architecture provided in this application. In actual applications, the architecture composed of each node can also have many situations, for example, the number of upper-layer nodes is consistent with the number of lower-layer nodes; or Each node forms a more or less hierarchical architecture, which is not limited here.
在图1b所示的实施例中,主节点S1和备份节点S2包含于单层架构中,且任意两个节点之间均建立直接的连接关系。在实际应用中,各个节点的连接关系还有更多可能,只要能够保证主节点和备份节点连接即可,具体此处不做限定。In the embodiment shown in Figure 1b, the primary node S1 and the backup node S2 are included in a single-layer architecture, and a direct connection relationship is established between any two nodes. In actual applications, there are more possibilities for the connection relationship between each node, as long as the connection between the primary node and the backup node can be guaranteed, there is no specific limit here.
在图1a所示实施例中,每个服务器所直接连接的节点的数量为1个,在实际应用中,每个服务器还可以直接连接更多数量的节点,具体此处不做限定。例如,在图1b所示实施例中,服务器A1和服务器A2直接连接的节点数量有2个,分别为节点S0和节点S1;与服务器A5直接连接的节点则有3个。In the embodiment shown in Figure 1a, the number of nodes directly connected to each server is one. In practical applications, each server can also be directly connected to a larger number of nodes, which is not limited here. For example, in the embodiment shown in Figure 1b, there are two nodes directly connected to server A1 and server A2, namely node S0 and node S1 respectively; there are three nodes directly connected to server A5.
本申请中,每个服务器上还可以部署客户端,客户端向主节点或者备份节点发送数据修改请求。In this application, a client can also be deployed on each server, and the client sends a data modification request to the primary node or backup node.
需要注意的是,本申请实施例提供的数据处理方法应用在第一节点,或者第二节点,第一节点和第二节点可以是交换机,也可以是能够进行数据同步其他的网络设备,例如服务器,第一节点和第二节点可以是相同类型的设备,也可以是不同类型的设备,具体此处不做限定。第一节点和第二节点可以进行角色分配,如果第一节点为主节点,那么第二节点为备份节点;相应地,如果第二节点为主节点,那么第一节点为备份节点,具体此处不做限定。It should be noted that the data processing method provided by the embodiment of the present application is applied to the first node or the second node. The first node and the second node may be switches or other network devices capable of data synchronization, such as servers. , the first node and the second node may be the same type of equipment, or may be different types of equipment, and there is no specific limitation here. The first node and the second node can perform role allocation. If the first node is the master node, then the second node is the backup node; accordingly, if the second node is the master node, then the first node is the backup node. Specifically, here No restrictions.
示例性的,假设第一节点为主节点,那么第二节点为备份节点,在图1a所示实施例中,第一节点即为节点S1,第二节点即为节点S6。For example, assuming that the first node is the master node and the second node is the backup node, in the embodiment shown in Figure 1a, the first node is node S1 and the second node is node S6.
接下来,假设第一节点为主节点,第二节点为备份节点,并假设本申请提供的数据处理方法应用在分布式锁场景,对本申请实施例提供的数据处理方法进行说明。Next, assuming that the first node is the master node and the second node is the backup node, and assuming that the data processing method provided by this application is applied in a distributed lock scenario, the data processing method provided by the embodiment of this application will be described.
在分布式锁场景中,作为主节点的第一节点和作为备份节点的第二节点中存储的数据类型包括锁状态。第一节点或者第二节点对客户端的锁请求进行处理的过程可以看作是客户端对第一节点或者第二节点发起读写请求的过程。在本申请中,定义锁获取成功时,第一节点和第二节点会修改自身的锁状态,进行了写操作;当客户端锁获取失败时,第一节 点和第二节点均不需要修改自身的锁状态,进行了读操作。基于此。为了方便描述,在后续的说明中,以读和写来表示客户端锁获取成功和失败的场景。In a distributed lock scenario, the data type stored in the first node as the master node and the second node as the backup node includes the lock status. The process of the first node or the second node processing the client's lock request can be regarded as the process of the client initiating a read or write request to the first node or the second node. In this application, it is defined that when the lock acquisition is successful, the first node and the second node will modify their own lock status and perform a write operation; when the client lock acquisition fails, Section 1 Neither the node nor the second node needs to modify its own lock status to perform a read operation. Based on. For the convenience of description, in the subsequent description, reading and writing are used to represent the successful and failed scenarios of client lock acquisition.
针对客户端的不同请求,本申请提供的数据处理方法包括三种不同的场景,分别为读-读场景,读-写场景,写-写场景。In response to different requests from clients, the data processing method provided by this application includes three different scenarios, namely read-read scenario, read-write scenario, and write-write scenario.
在读-读场景中,主节点或者备份节点的操作都不涉及对锁状态,也即自身存储的数据的修改,因此可以保证主备节点的数据一致性,在此不对读-读场景进行展开说明。In the read-read scenario, the operation of the primary node or the backup node does not involve the modification of the lock status, that is, the modification of the data stored on itself. Therefore, the data consistency of the primary and backup nodes can be guaranteed. The read-read scenario will not be explained here. .
在读-写场景或者写-写场景中,都会涉及对主备节点的数据修改,下面以第一节点为执行主体,对读-写场景和写-写场景进行说明。请参阅图2,图2为本申请实施例提供的数据处理方法的流程示意图,包括以下步骤:In a read-write scenario or a write-write scenario, data modification on the active and backup nodes will be involved. The following uses the first node as the execution subject to explain the read-write scenario and the write-write scenario. Please refer to Figure 2. Figure 2 is a schematic flowchart of a data processing method provided by an embodiment of the present application, including the following steps:
201.获取来自于第一客户端的第一数据修改消息,第一数据修改消息指示修改第一节点中存储的第一数据。201. Obtain the first data modification message from the first client. The first data modification message indicates modifying the first data stored in the first node.
假设第一节点发生了写操作,也就是说,第一客户端向第一节点发送第一数据修改消息,意图修改第一节点中存储的第一数据,也即对第一节点进行写操作。其中,第一数据修改消息可以通过报文的形式发送给第一节点。Assume that a write operation occurs on the first node, that is, the first client sends a first data modification message to the first node with the intention of modifying the first data stored in the first node, that is, a write operation is performed on the first node. The first data modification message may be sent to the first node in the form of a message.
202.根据第一数据修改消息,修改第一数据,得到第二数据。202. Modify the first data according to the first data modification message to obtain the second data.
第一节点获取到第一数据修改消息,会对第一数据进行修改,得到第二数据。The first node obtains the first data modification message and modifies the first data to obtain the second data.
203.向第二节点发送第一数据同步消息,第一数据同步消息携带第二数据,以使第二节点进行数据同步。203. Send a first data synchronization message to the second node, where the first data synchronization message carries the second data, so that the second node performs data synchronization.
由于第一数据发生了修改,第一节点会向第二节点发送第一数据同步消息,以告知第二节点,第一节点中存储的数据已经修改,使得第二节点进行数据同步,从而保持第一节点与第二节点之间的数据一致性。其中,第一数据同步消息可以按照报文的形式发送给第二节点。Since the first data is modified, the first node will send a first data synchronization message to the second node to inform the second node that the data stored in the first node has been modified, so that the second node can perform data synchronization to maintain the first data synchronization message. Data consistency between one node and the second node. The first data synchronization message may be sent to the second node in the form of a message.
204.接收来自于第二节点的第一响应消息,第一响应消息指示第二节点的数据同步结果。204. Receive a first response message from the second node, where the first response message indicates the data synchronization result of the second node.
第二节点接收到第一数据同步消息之后,会结合自身的数据状态确定是否需要修改自身的数据,并向第一节点发送第一响应消息,以告知第一节点数据同步结果。After receiving the first data synchronization message, the second node will determine whether its own data needs to be modified based on its own data status, and send a first response message to the first node to inform the first node of the data synchronization result.
由于第二节点的数据状态有多种可能,因此第二节点的数据同步结果也有多种可能,下面分别进行说明。示例性的,假设第一节点中存储第一数据的时候,第二节点中存储的是第三数据。Since there are many possibilities for the data status of the second node, there are also many possibilities for the data synchronization results of the second node, which are explained below. For example, it is assumed that when the first data is stored in the first node, the third data is stored in the second node.
如果第三数据的内容与第一数据的内容相同,那么意味着第一节点和第二节点之前处于数据同步的状态,如果第二节点没有接收来自于客户端的数据修改消息,那么第二节点中的数据会根据第一节点中的数据发生修改,也即将第三数据的内容修改为第二数据的内容,从而得到第四数据。在这种情况下,第二节点可能接收到客户端的读请求,也即第一节点和第二节点的操作对应于读-写场景。If the content of the third data is the same as the content of the first data, it means that the first node and the second node were in a state of data synchronization before. If the second node does not receive the data modification message from the client, then the second node The data will be modified according to the data in the first node, that is, the content of the third data will be modified to the content of the second data, thereby obtaining the fourth data. In this case, the second node may receive a read request from the client, that is, the operations of the first node and the second node correspond to the read-write scenario.
如果第三数据的内容与第一数据的内容不同,第二节点会考虑两个节点的优先级确定是否对第三数据的内容进行修改。如果第一节点的优先级高于第二节点的优先级,第二节点会将第三数据的内容修改为第二数据的内容,得到第四数据。如果第一节点的优先级不 高于第二节点的优先级,那么第二节点不会修改第三数据的内容,也就是说第二节点根据第一数据同步消息进行数据同步之后得到的第四数据的内容与第三数据的内容相同。在这种情况下,第一数据与第三数据不同原因可能是第二节点接收到来自客户端的数据修改消息,将原来与第一数据同步的数据修改为第三数据,也即第一节点和第二节点的操作对应于写-写场景。If the content of the third data is different from the content of the first data, the second node will consider the priorities of the two nodes to determine whether to modify the content of the third data. If the priority of the first node is higher than the priority of the second node, the second node will modify the content of the third data to the content of the second data to obtain the fourth data. If the priority of the first node is not is higher than the priority of the second node, then the second node will not modify the content of the third data. That is to say, the content of the fourth data obtained by the second node after data synchronization according to the first data synchronization message is the same as the content of the third data. The content is the same. In this case, the reason why the first data and the third data are different may be that the second node receives a data modification message from the client and modifies the data that was originally synchronized with the first data into the third data, that is, the first node and the third data are different. The operation of the second node corresponds to the write-write scenario.
其中,第一节点和第二节点之间的优先级可以根据第一节点和第二节点的角色确定,例如,主节点的优先级高于备份节点的优先级;还可以通过其他的方式确定,例如,根据节点各自的身份标识号(identitynumber,ID)确定,比如ID取值大的节点优先级高,具体此处不做限定。The priority between the first node and the second node can be determined according to the roles of the first node and the second node. For example, the priority of the primary node is higher than the priority of the backup node; it can also be determined in other ways, For example, it is determined based on the identity number (ID) of each node. For example, a node with a larger ID value has a higher priority. There is no specific limit here.
205.根据第一响应消息,处理第二数据,得到第一目标数据。205. Process the second data according to the first response message to obtain the first target data.
第二节点得到第四数据之后,会向第一节点发送对应于第一数据同步消息的第一响应消息,使得第一节点根据第一响应消息对第二数据进行处理,得到与第四数据同步的第一目标数据。也就是说,第一响应消息对应于第二节点中的第四数据,第四数据为第二节点根据第一数据同步消息对第三数据进行数据同步后得到的数据。After the second node obtains the fourth data, it will send a first response message corresponding to the first data synchronization message to the first node, so that the first node processes the second data according to the first response message and obtains synchronization with the fourth data. the first target data. That is to say, the first response message corresponds to the fourth data in the second node, and the fourth data is the data obtained after the second node performs data synchronization on the third data according to the first data synchronization message.
第一节点获取到第一响应消息,会根据第二数据的内容第一响应消息指示的第四数据的内容,对第二数据进行处理。具体来说,如果第四数据的内容已经同步为第二数据的内容,说明第二节点进行了数据同步,那么第一目标数据的内容即为第二数据的内容,也就是说,第一节点可以保持第二数据不变。其中,第二节点已经进行了数据同步包括第二节点的第三数据与第一节点的第一数据内容相同,或者,第三数据的内容虽然与第一数据的内容不同,但是第二节点的优先级不高于第一节点的优先级。After obtaining the first response message, the first node will process the second data according to the content of the second data and the content of the fourth data indicated by the first response message. Specifically, if the content of the fourth data has been synchronized to the content of the second data, it means that the second node has performed data synchronization, then the content of the first target data is the content of the second data, that is to say, the first node The second data can be kept unchanged. Among them, the second node has performed data synchronization, including that the third data of the second node has the same content as the first data of the first node, or, although the content of the third data is different from the content of the first data, the content of the second node's third data is the same as that of the first data. The priority is not higher than the priority of the first node.
如果第四数据的内容与第二数据的内容不同,说明第三数据的内容与第一数据的内容不同,且第二节点的优先级高于第一节点的优先级,因此第二节点保持第三数据的内容不变,也即第三数据与第四数据的内容相同。在这种情况下,第一节点会将第二数据的内容更新为第四数据的内容,以得到第一目标数据。If the content of the fourth data is different from the content of the second data, it means that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, so the second node maintains the priority of the first node. The content of the third data remains unchanged, that is, the content of the third data and the fourth data are the same. In this case, the first node will update the content of the second data to the content of the fourth data to obtain the first target data.
本申请中,第一节点根据第一客户端的第一数据修改消息将第一数据修改为第二数据之后,还会向第二节点发送第一数据同步消息,使得第二数据进行数据同步。并根据第二节点的数据同步结果,对第二数据进一步处理,得到第一节点中的数据与第二节点中的数据同步。简单来说,通过第一节点与第二节点之间的信息交互,实现第一节点与第二节点之间的数据同步,即使其中一个节点故障,另一个节点也可以继续提供服务,提升了系统的可靠性。另外,第一节点发生数据修改之后,会向第二节点发送数据同步消息,并根据第二节点的响应消息确定是否还需要对修改后的数据进行处理,从而保证第一节点与第二节点之间的数据同步,更进一步地提升了系统的可靠性。In this application, after the first node modifies the first data into the second data according to the first data modification message of the first client, it also sends a first data synchronization message to the second node, so that the second data is synchronized. And based on the data synchronization result of the second node, the second data is further processed to obtain synchronization between the data in the first node and the data in the second node. Simply put, through information exchange between the first node and the second node, data synchronization between the first node and the second node is achieved. Even if one node fails, the other node can continue to provide services, improving the system reliability. In addition, after the data is modified, the first node will send a data synchronization message to the second node, and determine whether the modified data still needs to be processed based on the response message of the second node, thereby ensuring the communication between the first node and the second node. Data synchronization between devices further improves the reliability of the system.
在一些可选的实施方式中,在第一节点得到第一目标数据之后,也即在步骤205之后,第一节点还会向第一客户端发送第四响应消息,该第四响应消息对应于第一客户端的第一数据修改消息,第四响应消息携带第一目标数据,从而告知第一客户端数据修改的最终结果。In some optional implementations, after the first node obtains the first target data, that is, after step 205, the first node will also send a fourth response message to the first client. The fourth response message corresponds to The first data modification message and the fourth response message of the first client carry the first target data, thereby informing the first client of the final result of the data modification.
本申请中,第一节点不仅能获取客户端的数据修改消息,还能向客户端反馈修改同步 后的最终结果。类似的,第二节点也可以获取客户端的数据修改消息,并向客户端反馈修改同步后的最终结果(下文以第二节点为执行主体说明数据处理方法时,展开说明第二节点的操作)。也就是说,本申请中,第一节点和第二节点,均可以获取请求并反馈结果,从而实现“双活的主备同步策略”,进一步提升了本申请技术方案的灵活性和实用性。In this application, the first node can not only obtain the client's data modification message, but also feedback modification synchronization to the client. The final result after. Similarly, the second node can also obtain the client's data modification message and feedback the final result after modification and synchronization to the client (the operation of the second node will be expanded upon when describing the data processing method using the second node as the execution subject). That is to say, in this application, both the first node and the second node can obtain the request and feedback the results, thereby realizing the "dual-active active and backup synchronization strategy", further improving the flexibility and practicality of the technical solution of this application.
为了清楚地说明“双活的主备同步策略”,请参阅图3,图3为本申请实施例提供的数据处理方法的一个示意图。In order to clearly illustrate the "dual-active active-standby synchronization strategy", please refer to Figure 3. Figure 3 is a schematic diagram of the data processing method provided by the embodiment of the present application.
如图3所示,所谓“双活的主备同步策略”即是指,主节点和备份节点均可以接收来自于客户端的请求(request),并对请求做出响应(response),相较于链式同步的方案中只能由主节点接收请求,备份节点响应,降低了响应时延。另外,主节点和备份节点之间还会进行数据同步,以保证数据一致性。总的来说,本申请技术方案既能提升系统可靠性,又能降低时延,提供了一种可靠性高且时延低的数据处理方法。As shown in Figure 3, the so-called "dual-active master-backup synchronization strategy" means that both the master node and the backup node can receive requests from clients and respond to requests. Compared with In the chain synchronization scheme, only the master node can receive the request and the backup node can respond, which reduces the response delay. In addition, data synchronization is performed between the primary node and the backup node to ensure data consistency. In general, the technical solution of this application can not only improve system reliability but also reduce latency, providing a data processing method with high reliability and low latency.
在一些可选的实施例中,第一节点中的数据发生了修改的话,第一节点的同步标志位(synchronize,sync)的取值也会发生变化。如果第一节点将第一数据修改为第二数据,那么第一节点会将同步标志位的取值置为第一值,第一值指示第一节点中存储的数据发生了修改。在第一节点将处理第二数据得到第一目标数据之后,会将第一节点的同步标志位的取值更新为第二值,第二值指示第一节点中存储的数据(也即第一目标数据)与第二节点存储的数据(也即第四数据)同步。In some optional embodiments, if the data in the first node is modified, the value of the synchronization flag bit (synchronize, sync) of the first node will also change. If the first node modifies the first data into the second data, the first node will set the value of the synchronization flag bit to the first value, and the first value indicates that the data stored in the first node has been modified. After the first node processes the second data to obtain the first target data, the value of the synchronization flag bit of the first node is updated to a second value. The second value indicates the data stored in the first node (that is, the first Target data) is synchronized with the data stored in the second node (ie, fourth data).
其中,第一值和第二值的具体取值,可以根据实际应用的需要选择,本申请对此并不限定。示例性的,可以设置第一值为1,第二值为0。The specific values of the first value and the second value can be selected according to actual application needs, and are not limited in this application. For example, the first value can be set to 1 and the second value can be set to 0.
为了更加清楚地说明步骤201至步骤205中,第一节点中数据变化和sync的取值变化的过程,请参阅图4,图4为本申请实施例提供的示意图。In order to more clearly explain the process of data changes and sync value changes in the first node from steps 201 to 205, please refer to Figure 4, which is a schematic diagram provided by an embodiment of the present application.
简单来说,如图4所示,第一节点根据第一数据修改消息,将第一数据修改为第二数据,并将同步标志位的取值置为1,以表示第一节点的数据发生了修改。为了保证第一节点与第二节点之间的数据同步,第一节点向第二节点发送第一数据同步消息,使得第二节点将第三数据同步为第四数据,并将同步标志位的取值置为0,以表示第二节点的数据与第一节点的数据同步。第一节点接收指示第二节点的数据同步结果的第一响应消息,第一响应消息对应于第四数据,使得第一节点对第二数据进一步进行处理,得到第一目标数据,并将同步标志位的取值置为0,以表示第一节点中的第一目标数据与第二节点中的第四数据同步。To put it simply, as shown in Figure 4, the first node modifies the first data into the second data according to the first data modification message, and sets the value of the synchronization flag bit to 1 to indicate that the data of the first node has occurred. Modified. In order to ensure data synchronization between the first node and the second node, the first node sends a first data synchronization message to the second node, so that the second node synchronizes the third data into the fourth data and sets the synchronization flag bit. The value is set to 0 to indicate that the data of the second node is synchronized with the data of the first node. The first node receives a first response message indicating the data synchronization result of the second node. The first response message corresponds to the fourth data, so that the first node further processes the second data, obtains the first target data, and sets the synchronization flag The value of the bit is set to 0 to indicate that the first target data in the first node is synchronized with the fourth data in the second node.
在不同的场景中,数据变化的过程略有不同,下面结合示意图,分别对读-写场景和写-写场景进行说明。请参阅图5a和图5b,其中,图5a为本申请实施例提供的读-写场景的一个示意图,图5b为本申请实施例提供的写-写场景的一个示意图。In different scenarios, the data change process is slightly different. The following is a schematic diagram to illustrate the read-write scenario and write-write scenario respectively. Please refer to Figures 5a and 5b. Figure 5a is a schematic diagram of a read-write scenario provided by an embodiment of the present application, and Figure 5b is a schematic diagram of a write-write scenario provided by an embodiment of the present application.
如图5a所示,假设主节点和备份节点初始状态存储的数据一致,也即主节点和备份节点存储的值(value)为2,且同步标志位取值为0。然后写操作发生在备份节点,同时主节点响应读操作。此时,备份节点的写入的数值尚未同步到主节点。在主节点处发生的读操作返回了不是最新的数值,即为初始数值V=2。As shown in Figure 5a, it is assumed that the data stored in the initial state of the primary node and the backup node are consistent, that is, the value (value) stored by the primary node and the backup node is 2, and the synchronization flag value is 0. Write operations then occur on the backup node while the primary node responds to read operations. At this time, the values written by the backup node have not yet been synchronized to the primary node. The read operation that occurred at the primary node returned a value that was not the latest, that is, the initial value V=2.
写操作发生时,备份节点将sync置位为1,并发送数据同步报文到主节点。由于主节 点此时的sync为0,因此,数据同步报文生效,主节点进行数据修改,与备份节点的数据保持一致。备份节点获取主节点的响应报文之后,修改自身同步标志位的取值,将sync置位为0。When a write operation occurs, the backup node sets the sync bit to 1 and sends a data synchronization message to the primary node. due to main section The sync at this point is 0, therefore, the data synchronization message takes effect, and the master node performs data modification to be consistent with the data of the backup node. After the backup node obtains the response message from the primary node, it modifies the value of its own synchronization flag and sets sync to 0.
本申请中,读操作在分布式锁管理系统中表示的锁获取失败,因此对于主节点的锁获取失败后,客户端会重新发起锁请求从而获得最新的数据,也即V=3。In this application, the read operation indicates that the lock acquisition fails in the distributed lock management system. Therefore, after the lock acquisition of the master node fails, the client will re-initiate the lock request to obtain the latest data, that is, V=3.
如图5b所示,假设主备节点同时接收写请求,且主备节点收到了不同的写请求。在图5b所示实施例中,主节点根据写请求将数据修改为V=2,备份节点根据写请求将数据修改为V=3,主节点和备份节点会向对方发送数据同步请求。As shown in Figure 5b, it is assumed that the active and standby nodes receive write requests at the same time, and the active and standby nodes receive different write requests. In the embodiment shown in Figure 5b, the master node modifies the data to V=2 according to the write request, and the backup node modifies the data to V=3 according to the write request. The master node and the backup node will send data synchronization requests to each other.
主节点和备份节点中的任意一个节点,收到对方的数据同步请求之后,先确认自身的sync是否为1。如果sync=0,则表示该节点并未发生数据变更,因此可以直接接受数据同步请求,将自身的数据修改为数据同步请求所对应的数据。如果sync=1,则表示该节点本身也发生了数据变更,此时依据实现商定的优先级(例如主节点高于备份节点)来判定该数据同步请求是否生效。如果发送端的优先级高于本地,则应用该数据同步请求,否则拒绝该请求,结果反馈给发送端。按照上述的方式,主节点的写请求将被应用并同步到备份节点,因此主节点与备份节点的数据一致。After receiving the data synchronization request from the other party, any node among the primary node and the backup node first confirms whether its own sync is 1. If sync=0, it means that the node has not changed its data, so it can directly accept the data synchronization request and modify its own data to the data corresponding to the data synchronization request. If sync=1, it means that the data of the node itself has also changed. At this time, it is determined whether the data synchronization request takes effect based on the priority agreed upon by the implementation (for example, the primary node is higher than the backup node). If the priority of the sending end is higher than the local one, the data synchronization request is applied, otherwise the request is rejected and the result is fed back to the sending end. According to the above method, the write request of the primary node will be applied and synchronized to the backup node, so the data of the primary node and the backup node are consistent.
本申请中,第一节点还可以设置同步标志位,通过查询同步标志位的取值,就可以识别第一节点与第二节点中的数据是否同步,识别方式简单。In this application, the first node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized. The identification method is simple.
在图5b所示实施例中,第一节点和第二节点同时获取来自于客户端的数据修改请求,在实际应用中,第一节点和第二节点获取客户端的数据修改请求的时间点也可以不同,下面对这种情况进行说明。In the embodiment shown in Figure 5b, the first node and the second node obtain the data modification request from the client at the same time. In practical applications, the time points at which the first node and the second node obtain the data modification request from the client can also be different. , this situation is explained below.
在一些可选的实施例中,在步骤201之前,第一节点可以获取来自于第二节点的第二数据同步消息,第二数据同步消息指示第一节点进行数据同步,第二数据同步消息对应于第二节点中存储的第五数据(也即第二数据同步消息中携带第五数据)。第五数据是第二节点根据来自于第二客户端的第二数据修改消息对第二节点中的第一历史数据修改后得到的数据。第一节点根据第二数据同步消息和第一节点的第一数据状态,处理第一节点中当前存储的数据,得到第一数据。In some optional embodiments, before step 201, the first node may obtain a second data synchronization message from the second node. The second data synchronization message instructs the first node to perform data synchronization. The second data synchronization message corresponds to The fifth data stored in the second node (that is, the second data synchronization message carries the fifth data). The fifth data is data obtained by the second node modifying the first historical data in the second node according to the second data modification message from the second client. The first node processes the data currently stored in the first node according to the second data synchronization message and the first data status of the first node to obtain the first data.
其中,第二客户端与第一客户端可以是相同的客户端,也可以是不同的客户端,具体此处不做限定。The second client and the first client may be the same client or different clients, and the details are not limited here.
由于第一节点的第一数据状态所指示的内容可以有多种,使得第一节点处理当前存储的数据的方式也有不同。Since the first data status of the first node may indicate multiple contents, the first node may also process the currently stored data in different ways.
在一些可选的实施方式中,如果第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容相同,意味着第一节点需要进行同步修改,将第一节点中当前存储的数据的内容更新为第五数据的内容,得到第一数据。In some optional implementations, if the first data status indicates that the content of the data currently stored in the first node is the same as the content of the first historical data, it means that the first node needs to perform synchronous modification, and the current data in the first node The content of the stored data is updated to the content of the fifth data to obtain the first data.
在一些可选的实施方式中,如果第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容不同,且第一节点的优先级不高于第二节点的优先级,意味着第一节点需要进行同步修改,将第一节点中当前存储的数据的内容更新为第五数据的内容,得到第一数据。 In some optional implementations, if the first data status indicates that the content of the data currently stored in the first node is different from the content of the first historical data, and the priority of the first node is not higher than the priority of the second node , means that the first node needs to be modified synchronously, and the content of the data currently stored in the first node is updated to the content of the fifth data to obtain the first data.
在一些可选的实施方式中,如果第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容不同,且第一节点的优先级高于第二节点的优先级,意味着第一节点不需要进行修改,第一节点能够确定第一数据的内容与第一节点中当前存储的数据的内容相同。In some optional implementations, if the first data status indicates that the content of the data currently stored in the first node is different from the content of the first historical data, and the priority of the first node is higher than the priority of the second node, This means that the first node does not need to be modified, and the first node can determine that the content of the first data is the same as the content of the data currently stored in the first node.
本申请中,第一节点和第二节点均可以接收客户端的数据修改消息,并对该消息做出响应,如果将第一节点和第二节点分别作为主节点和备份节点,本申请能实现“双活的主备同步策略”,提升了本申请技术方案的灵活性。另外,第一节点在接收到来自第二节点的数据同步消息之后,会根据自身的数据状态确定是否需要进行数据同步。在第一节点当前存储的数据与第二节点的第一历史数据内容相同的情况下,第一节点会进行数据修改,从而保证了两个节点之间的数据一致性;在第一节点当前存储的数据与第二节点的第一历史数据内容不同的情况下,第一节点会综合两个节点的优先级,确定是否要对当前存储的数据进行修改,从而保证低优先级的节点的数据跟随高优先级的节点的数据,避免了高优先级的节点中的数据被频繁修改或者误操作。In this application, both the first node and the second node can receive the client's data modification message and respond to the message. If the first node and the second node are used as the master node and backup node respectively, this application can achieve " "Hyperactive active-standby synchronization strategy" improves the flexibility of the technical solution of this application. In addition, after receiving the data synchronization message from the second node, the first node will determine whether data synchronization is required based on its own data status. When the data currently stored by the first node is the same as the first historical data content of the second node, the first node will modify the data to ensure data consistency between the two nodes; when the data currently stored by the first node When the data content of the second node is different from the first historical data content of the second node, the first node will combine the priorities of the two nodes to determine whether to modify the currently stored data to ensure that the data of the low-priority node follows The data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
在一些可选的实施方式中,在第一节点得到第一数据之后,会向第二节点发送对应于所述第二数据同步消息的第二响应消息。其中,第二响应消息指示第一节点的数据同步结果,也即指示第一数据的内容,使得第二节点根据第二响应消息,对第五数据进行处理,以使处理后的第五数据的内容与第一数据的内容相同,即使得第一节点和第二节点的数据同步。In some optional implementations, after the first node obtains the first data, a second response message corresponding to the second data synchronization message is sent to the second node. The second response message indicates the data synchronization result of the first node, that is, the content of the first data, so that the second node processes the fifth data according to the second response message, so that the processed fifth data The content is the same as the content of the first data, that is, the data of the first node and the second node are synchronized.
本申请中,第一节点根据第二节点的数据同步消息,对第一节点当前存储的数据处理得到第一数据之后,还会向第二节点反馈数据同步结果,使得第二节点进一步处理自身存储的数据,从而保证了第一节点与第二节点的数据同步,进一步提升了系统的可靠性。In this application, the first node processes the data currently stored by the first node to obtain the first data according to the data synchronization message of the second node, and then feeds back the data synchronization result to the second node, so that the second node further processes its own storage. data, thereby ensuring data synchronization between the first node and the second node, further improving the reliability of the system.
在一些可选的实施方式中,在第一节点得到第一数据之后,第一节点的数据状态会进行修改,将同步标志位的取值置为第二值,以表示第一节点和第二节点的数据同步。In some optional implementations, after the first node obtains the first data, the data status of the first node will be modified, and the value of the synchronization flag bit will be set to a second value to indicate that the first node and the second Node data synchronization.
为了更加清楚地说明上述第一节点得到第一数据的过程,请参阅图6,图6为本申请实施例提供的示意图。In order to more clearly illustrate the process of the first node obtaining the first data, please refer to Figure 6 , which is a schematic diagram provided by an embodiment of the present application.
简单来说,如图6所示,第二节点根据第二数据修改消息,将第一历史数据修改为第五数据,并将同步标志位的取值置为1,以表示第二节点的数据发生了修改。为了保证第二节点与第一节点之间的数据同步,第二节点向第一节点发送第二数据同步消息,使得第一节点将当前存储的数据同步为第一数据,并将同步标志位的取值置为0,以表示第一节点的数据与第二节点的数据同步。第二节点接收指示第一节点的数据同步结果的第二响应消息,第二响应消息对应于第一数据,使得第二节点对第六数据进一步进行处理,得到处理后的第六数据,并将同步标志位的取值置为0,以表示第二节点中处理后第六数据与第一节点中的第一数据同步。To put it simply, as shown in Figure 6, the second node modifies the first historical data to the fifth data according to the second data modification message, and sets the value of the synchronization flag bit to 1 to represent the data of the second node. Modifications have occurred. In order to ensure data synchronization between the second node and the first node, the second node sends a second data synchronization message to the first node, so that the first node synchronizes the currently stored data into the first data and sets the synchronization flag bit. The value is set to 0 to indicate that the data of the first node is synchronized with the data of the second node. The second node receives a second response message indicating the data synchronization result of the first node. The second response message corresponds to the first data, so that the second node further processes the sixth data to obtain the processed sixth data, and The value of the synchronization flag bit is set to 0 to indicate that the processed sixth data in the second node is synchronized with the first data in the first node.
在一些可选的实施例中,在得到第一目标数据之后,第一节点还可以获取来自第二节点的第三数据同步消息,该第三数据同步消息指示第一节点进行数据同步,并且第三数据同步消息对应于第二节点中存储的第六数据(也即第三数据同步消息携带第六数据)。第六数据是第二节点根据来自于第三客户端的第三数据修改消息对第二节点中的第二历史数据 修改后得到的数据。接收到第三数据同步消息之后,第一节点会根据第三数据同步消息和第一节点的第二数据状态,对第一目标数据进行处理,得到第二目标数据。In some optional embodiments, after obtaining the first target data, the first node may also obtain a third data synchronization message from the second node. The third data synchronization message instructs the first node to perform data synchronization, and the third data synchronization message instructs the first node to perform data synchronization. The third data synchronization message corresponds to the sixth data stored in the second node (that is, the third data synchronization message carries the sixth data). The sixth data is the second historical data in the second node according to the third data modification message from the third client. The data obtained after modification. After receiving the third data synchronization message, the first node processes the first target data according to the third data synchronization message and the second data status of the first node to obtain the second target data.
其中,第三客户端、第二客户端和第一客户端中的任意两个客户端,也可以是不同的客户端,具体此处不做限定。Among them, any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
由于第一节点的第二数据状态所指示的内容可以有多种,使得第一节点处理第一目标数据的方式也有不同。Since the second data status of the first node may indicate multiple contents, the first node may also process the first target data in different ways.
在一些可选的实施例中,如果第二数据状态指示第一节点中第一目标数据的内容与第二历史数据的内容相同,意味着第一节点需要进行同步修改,将第一节点中第一目标数据的内容更新为第六数据的内容,得到第二目标数据。In some optional embodiments, if the second data status indicates that the content of the first target data in the first node is the same as the content of the second historical data, it means that the first node needs to perform synchronous modification, and the first node in the first node needs to perform synchronous modification. The content of the first target data is updated to the content of the sixth data to obtain the second target data.
在一些可选的实施例中,如果第二数据状态指示第一节点中第一目标数据的内容与第二历史数据的内容不同,且第一节点的优先级不高于第二节点的优先级,意味着第一节点需要进行同步修改,将第一节点中第一目标数据的内容更新为第六数据的内容,得到第二目标数据。In some optional embodiments, if the second data status indicates that the content of the first target data in the first node is different from the content of the second historical data, and the priority of the first node is not higher than the priority of the second node , means that the first node needs to be modified synchronously, and the content of the first target data in the first node is updated to the content of the sixth data to obtain the second target data.
在一些可选的实施例中,如果第二数据状态指示第一节点中第一目标数据的内容与第二历史数据的内容不同,且第一节点的优先级高于第二节点的优先级,意味着第一节点不需要进行修改,第一节点能够确定第二目标数据的内容与第一节点中第一目标数据的内容相同。In some optional embodiments, if the second data status indicates that the content of the first target data in the first node is different from the content of the second historical data, and the priority of the first node is higher than the priority of the second node, This means that the first node does not need to be modified, and the first node can determine that the content of the second target data is the same as the content of the first target data in the first node.
本申请中,第一节点和第二节点均可以接收客户端的数据修改消息,并对该消息做出响应。如果将第一节点和第二节点分别作为主节点和备份节点,本申请能实现“双活的主备同步策略”,提升了本申请技术方案的灵活性。另外,相较于只能有主节点接收客户端的消息,再由备份节点进行响应的方案,本申请技术方案降低了响应的时延。另外,第一节点在接收到来自第二节点的数据同步消息之后,会根据自身的数据状态确定是否需要进行数据同步。在第一节点第一目标数据与第二节点的第二历史数据内容相同的情况下,第一节点会进行数据修改,从而保证了两个节点之间的数据一致性;在第一节点第一目标数据与第二节点的第二历史数据内容不同的情况下,第一节点会综合两个节点的优先级,确定是否对第一目标数据进行修改了,从而保证低优先级的节点的数据跟随高优先级的节点的数据,避免了高优先级的节点中的数据被频繁修改或者误操作。In this application, both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. In addition, compared with the solution where only the master node can receive the client's message and then the backup node responds, the technical solution of this application reduces the response delay. In addition, after receiving the data synchronization message from the second node, the first node will determine whether data synchronization is required based on its own data status. When the first target data of the first node is the same as the second historical data content of the second node, the first node will modify the data to ensure data consistency between the two nodes; when the first node first When the content of the target data is different from the second historical data of the second node, the first node will combine the priorities of the two nodes to determine whether the first target data has been modified, thereby ensuring that the data of the low-priority node follows. The data of high-priority nodes avoids frequent modification or misoperation of data in high-priority nodes.
在一些可选的实施例中,在第一节点得到第二目标数据之后,会向第二节点发送对应于所述第三数据同步消息的第三响应消息。其中,第三响应消息指示第一节点的数据同步结果,也即指示第二目标数据的内容,使得第二节点根据第三响应消息,对第六数据进行处理,以使处理后的第六数据的内容与第二目标数据的内容相同,即使得第一节点和第二节点的数据同步。In some optional embodiments, after the first node obtains the second target data, a third response message corresponding to the third data synchronization message is sent to the second node. The third response message indicates the data synchronization result of the first node, that is, the content of the second target data, so that the second node processes the sixth data according to the third response message, so that the processed sixth data The content of is the same as the content of the second target data, that is, the data of the first node and the second node are synchronized.
本申请中,第一节点根据第二节点的数据同步消息,对第一节点的第一目标数据处理得到第二目标数据之后,还可以向第二节点反馈数据同步结果,使得第二节点进一步处理自身存储的数据,从而保证了第一节点与第二节点的数据同步,进一步提升了系统的可靠性。In this application, after the first node processes the first target data of the first node to obtain the second target data according to the data synchronization message of the second node, it can also feed back the data synchronization result to the second node, so that the second node can further process it. The data stored by itself ensures the data synchronization between the first node and the second node, further improving the reliability of the system.
在一些可选的实施例中,在第一节点得到第二目标数据之后,第一节点的数据状态会 进行修改,将同步标志位的取值置为第二值,以表示第一节点和第二节点的数据同步。In some optional embodiments, after the first node obtains the second target data, the data status of the first node will Make modifications to set the value of the synchronization flag bit to the second value to indicate data synchronization between the first node and the second node.
为了更加清楚地说明上述第一节点得到第二目标数据的过程,请参阅图7,图7为本申请实施例提供的示意图。In order to more clearly illustrate the process of the first node obtaining the second target data, please refer to Figure 7, which is a schematic diagram provided by an embodiment of the present application.
简单来说,如图7所示,第二节点根据第三数据修改消息,将第二历史数据修改为第六数据,并将同步标志位的取值置为1,以表示第二节点的数据发生了修改。为了保证第二节点与第一节点之间的数据同步,第二节点向第一节点发送第三数据同步消息,使得第一节点将第一目标数据同步为第二目标数据,并将同步标志位的取值置为0,以表示第一节点的数据与第二节点的数据同步。第二节点接收指示第一节点的数据同步结果的第三响应消息,第二响应消息对应于第二目标数据,使得第二节点对第六数据进一步进行处理,得到处理后的第六数据,并将同步标志位的取值置为0,以表示第二节点中处理后第六数据与第一节点中的第二目标数据同步。To put it simply, as shown in Figure 7, the second node modifies the second historical data to the sixth data according to the third data modification message, and sets the value of the synchronization flag bit to 1 to represent the data of the second node. Modifications have occurred. In order to ensure data synchronization between the second node and the first node, the second node sends a third data synchronization message to the first node, so that the first node synchronizes the first target data to the second target data and sets the synchronization flag bit. The value of is set to 0 to indicate that the data of the first node is synchronized with the data of the second node. The second node receives a third response message indicating the data synchronization result of the first node. The second response message corresponds to the second target data, so that the second node further processes the sixth data to obtain the processed sixth data, and The value of the synchronization flag bit is set to 0 to indicate that the processed sixth data in the second node is synchronized with the second target data in the first node.
接下来,假设第一节点为主节点,第二节点为备份节点,并假设本申请提供的数据处理方法应用在分布式锁场景,以第二节点为执行主体,对本申请实施例提供的数据处理方法进行说明。请参阅图8,图8为本申请实施例提供的数据处理方法的一个流程示意图,包括以下步骤:Next, assume that the first node is the master node and the second node is the backup node. It is also assumed that the data processing method provided by this application is applied in a distributed lock scenario, and the second node is used as the execution subject. The data processing method provided by the embodiment of this application is The method is explained. Please refer to Figure 8. Figure 8 is a schematic flow chart of a data processing method provided by an embodiment of the present application, including the following steps:
801.获取来自于第一节点的第一数据同步消息,第一数据同步消息指示第二节点进行数据同步,第一数据同步消息对应于第一节点中的第二数据,第二数据是第一节点根据来自于第一客户端的第一数据修改消息将第一节点中的第一数据修改后得到的数据。801. Obtain the first data synchronization message from the first node. The first data synchronization message instructs the second node to perform data synchronization. The first data synchronization message corresponds to the second data in the first node. The second data is the first data synchronization message. Data obtained by the node modifying the first data in the first node according to the first data modification message from the first client.
第二节点与第一节点建立通信连接,能够获取来自于第一节点的第一数据同步消息。The second node establishes a communication connection with the first node and can obtain the first data synchronization message from the first node.
802.根据第一数据同步消息和第二节点的第一数据状态,处理第二节点中存储的第三数据,得到第四数据。802. Process the third data stored in the second node according to the first data synchronization message and the first data status of the second node to obtain fourth data.
由于第二节点的第一数据状态有多种可能,因此第二节点的数据同步结果也有多种情况。Since the first data status of the second node has multiple possibilities, the data synchronization results of the second node also have multiple possibilities.
在一些可选的实施方式中,如果第二节点的第一数据状态指示了第二节点中第三数据的内容与第一节点中第一数据的内容相同,说明第一节点与第二节点之前就处于数据同步的状态,在第一节点的数据发生修改的情况下,第二节点需要同步修改,将第三数据的内容更新为第二数据的内容,以得到与第二数据同步的第四数据。In some optional implementations, if the first data status of the second node indicates that the content of the third data in the second node is the same as the content of the first data in the first node, it means that the first node is the same as the second node. In the state of data synchronization, when the data of the first node is modified, the second node needs to modify it synchronously and update the content of the third data to the content of the second data to obtain the fourth data synchronized with the second data. data.
在一些可选的实施方式中,如果第二节点的第一数据状态指示第三数据的内容与第一数据的内容不同,且第二节点的优先级不高于第一节点的优先级,说明第一节点与第二节点之前并不处于数据同步状态,并且第二节点的数据需要跟随第一节点的数据,因此,第二节点会将第三数据的内容更新为第二数据的内容,以得到与第二数据同步的第四数据。In some optional implementations, if the first data status of the second node indicates that the content of the third data is different from the content of the first data, and the priority of the second node is not higher than the priority of the first node, explain The first node and the second node were not in a data synchronization state before, and the data of the second node needs to follow the data of the first node. Therefore, the second node will update the content of the third data to the content of the second data, so as to Fourth data synchronized with the second data is obtained.
在一些可选的实施方式中,如果第一数据状态指示第三数据的内容与第一数据的内容不同,并且第二节点的优先级高于第一节点的优先级,说明第一节点与第二节点之前并不处于数据同步状态,并且第一节点的数据需要跟随第二节点的数据,第二节点中的第三数据保持不变,也即确定第四数据的内容与第三数据的内容相同。In some optional implementations, if the first data status indicates that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, it means that the first node is different from the first node. The two nodes were not in a data synchronization state before, and the data of the first node needs to follow the data of the second node. The third data in the second node remains unchanged, that is, the content of the fourth data and the content of the third data are determined. same.
本申请中,第二节点在接收到来自第一节点的数据同步消息之后,会根据自身的数据状态确定是否需要进行数据同步。在第二节点的第三数据与第一节点的第一数据内容相同 的情况下,第二节点会进行数据修改,从而保证了两个节点之间的数据一致性;在第三数据与第一数据内容不同的情况下,第二节点会综合两个节点的优先级,确定是否对第三数据进行修改,从而保证低优先级的节点的数据跟随高优先级的节点的数据,避免了高优先级的节点中的数据被频繁修改或者误操作。In this application, after receiving the data synchronization message from the first node, the second node determines whether data synchronization is required based on its own data status. The third data at the second node has the same content as the first data at the first node. In the case of , the second node will modify the data to ensure data consistency between the two nodes; in the case where the content of the third data is different from the first data, the second node will combine the priorities of the two nodes , determine whether to modify the third data, thereby ensuring that the data of the low-priority node follows the data of the high-priority node, and avoiding frequent modification or misoperation of the data in the high-priority node.
803.向第一节点发送第一响应消息,第一响应消息指示第二节点的数据同步结果,以使第一节点根据数据同步结果,处理第二数据得到第一目标数据。803. Send a first response message to the first node. The first response message indicates the data synchronization result of the second node, so that the first node processes the second data to obtain the first target data according to the data synchronization result.
经过第二节点与第一节点之间的信息交互,使得第一节点中的第一目标数据与第二节点中的第四数据的数据内容相同,实现了不同节点之间的数据同步。Through information interaction between the second node and the first node, the data content of the first target data in the first node and the fourth data in the second node are the same, thereby realizing data synchronization between different nodes.
本申请中,第一节点数据修改之后会向第二节点发送数据同步消息,使得第二节点结合自身的数据状态确定数据同步结果,并将结果反馈给第一节点,使得第一节点进一步处理自身数据,最终实现第一节点与第二节点之间的数据同步,提升系统的可靠性。In this application, after the data of the first node is modified, it will send a data synchronization message to the second node, so that the second node determines the data synchronization result based on its own data status, and feeds the result back to the first node, so that the first node further processes itself. data, ultimately achieving data synchronization between the first node and the second node, improving the reliability of the system.
在一些可选的实施方式中,在步骤803之后,也即在得到第四数据之后,第二节点会将第一数据状态更新为第二数据状态,第二数据状态指示第二节点与第一节点的数据同步。具体来说,可以是将第二节点的同步标志位的取值置为第二值。In some optional implementations, after step 803, that is, after obtaining the fourth data, the second node will update the first data state to a second data state, and the second data state indicates that the second node is in contact with the first data state. Node data synchronization. Specifically, the value of the synchronization flag bit of the second node may be set to the second value.
示例性的,步骤801至步骤803中,第二节点的数据变化的过程如前述图4所示。For example, from step 801 to step 803, the data change process of the second node is as shown in the aforementioned Figure 4.
本申请中,第二节点还可以设置同步标志位,通过查询同步标志位的取值,就可以识别第一节点与第二节点中的数据是否同步,识别方式简单。In this application, the second node can also set a synchronization flag bit. By querying the value of the synchronization flag bit, it can be identified whether the data in the first node and the second node are synchronized. The identification method is simple.
在一些可选的实施方式中,第二节点也可以接收来自于客户端的数据修改消息,并向第一节点发出数据同步消息。示例性的,在获取来自于第一节点的第一数据同步消息,也即在步骤801之前,第二节点还可以获取来自于第二客户端的第二数据修改消息,第二数据修改消息指示修改第二节点中存储的第一历史数据。第二节点会根据第二数据修改消息,修改第一历史数据,得到第五数据,然后向第一节点发送第二数据同步消息,以使第一节点对第一节点当前存储的数据进行数据同步得到第一数据。第一节点进行数据同步之后会向第二节点发送第二响应消息。第二节点接收来自于第一节点的第二响应消息,该第二响应消息指示第一节点的数据同步结果,并根据第二响应消息,处理第五数据,使得处理后的第五数据与第一数据同步。In some optional implementations, the second node can also receive a data modification message from the client and send a data synchronization message to the first node. Exemplarily, before obtaining the first data synchronization message from the first node, that is, before step 801, the second node may also obtain a second data modification message from the second client, and the second data modification message indicates modification. The first historical data stored in the second node. The second node will modify the first historical data according to the second data modification message, obtain the fifth data, and then send the second data synchronization message to the first node, so that the first node can perform data synchronization on the data currently stored by the first node. Get the first data. After performing data synchronization, the first node will send a second response message to the second node. The second node receives a second response message from the first node, the second response message indicates the data synchronization result of the first node, and processes the fifth data according to the second response message, so that the processed fifth data is consistent with the first node. One data synchronization.
其中,第二客户端与第一客户端可以是相同的客户端,也可以是不同的客户端,具体此处不做限定。The second client and the first client may be the same client or different clients, and the details are not limited here.
由于根据第二响应消息所指示的内容不同,第二节点处理第五数据的方式也有所不同:Since the content indicated by the second response message is different, the way the second node processes the fifth data is also different:
在一些可选的实施方式中,如果第二响应消息指示第一数据的内容同步为第五数据的内容,那么第二节点会保持第五数据的内容不变,也即处理后的第五数据与第五数据的内容相同。In some optional implementations, if the second response message indicates that the content of the first data is synchronized to the content of the fifth data, then the second node will keep the content of the fifth data unchanged, that is, the processed fifth data The content is the same as the fifth data.
在一些可选的实施方式中,如果第二响应消息指示第一数据的内容与第五数据的内容不同,那么意味着第一节点的优先级高于第二节点的优先级,第二节点需要对第五数据进行更新,将第五数据的内容更新为第一数据的内容,得到修改后的第五数据。In some optional implementations, if the second response message indicates that the content of the first data is different from the content of the fifth data, it means that the priority of the first node is higher than the priority of the second node, and the second node needs The fifth data is updated, and the content of the fifth data is updated to the content of the first data to obtain the modified fifth data.
在一些可选的实施方式中,若第二响应消息指示第一数据的内容与第五数据的内容不同,则将第五数据的内容更新为第一数据的内容。 In some optional implementations, if the second response message indicates that the content of the first data is different from the content of the fifth data, the content of the fifth data is updated to the content of the first data.
示例性的,第二节点将第一历史数据进行处理,最终得到处理后的第五数据的过程如前述图6所示。For example, the second node processes the first historical data and finally obtains the processed fifth data, as shown in the aforementioned Figure 6 .
在一些可选的实施方式中,第二节点得到处理后的第五数据之后,还会向第二客户端发送响应消息,该响应消息中携带处理后的第五数据。In some optional implementations, after obtaining the processed fifth data, the second node also sends a response message to the second client, where the response message carries the processed fifth data.
本申请中,第一节点和第二节点均可以接收客户端的数据修改消息,并对该消息做出响应。如果将第一节点和第二节点分别作为主节点和备份节点,本申请能实现“双活的主备同步策略”,提升了本申请技术方案的灵活性。相较于链式同步方案中,只能有主节点接收客户端的消息,再由备份节点进行响应的方案,本申请技术方案降低了响应的时延。另外,在第二节点根据第二客户端的数据修改消息修改数据之后,会向第一节点发送数据同步消息,并根据第一节点的同步结果,确定是否进一步处理根据数据修改消息修改得到的数据,从而保证第一节点与第二节点中的数据同步,进一步提升了系统的可靠性。In this application, both the first node and the second node can receive the data modification message from the client and respond to the message. If the first node and the second node are used as the master node and the backup node respectively, this application can realize the "dual-active master-backup synchronization strategy", which improves the flexibility of the technical solution of this application. Compared with the chain synchronization solution, in which only the master node can receive the client's message, and then the backup node responds, the technical solution of this application reduces the response delay. In addition, after the second node modifies the data according to the data modification message of the second client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message based on the synchronization result of the first node. This ensures data synchronization between the first node and the second node, further improving the reliability of the system.
在一些可选的实施方式中,第二节点可以在不同的时间点接收多个客户端的数据修改消息。示例性的,在向第一节点发送第一响应消息之后,也即在步骤803之后,第二节点可以获取来自于第三客户端的第三数据修改消息,第三数据修改消息指示修改第二节点中存储的第二历史数据。根据第三数据修改消息,修改第二历史数据,得到第六数据。第二节点会向第一节点发送第三数据同步消息,以使第一节点对第一目标数据进行数据同步得到第二目标数据。第一节点得到第二目标数据之后,会向第二节点发送第三响应消息,该第三响应消息指示第一节点的数据同步结果。第二节点接收来自于第一节点的第三响应消息,并根据第三响应消息,处理第六数据,使得处理后的第五数据与第二目标数据同步。In some optional implementations, the second node may receive data modification messages from multiple clients at different points in time. Exemplarily, after sending the first response message to the first node, that is, after step 803, the second node may obtain the third data modification message from the third client. The third data modification message indicates modifying the second node. The second historical data stored in . According to the third data modification message, the second historical data is modified to obtain the sixth data. The second node will send a third data synchronization message to the first node, so that the first node performs data synchronization on the first target data to obtain the second target data. After obtaining the second target data, the first node sends a third response message to the second node. The third response message indicates the data synchronization result of the first node. The second node receives the third response message from the first node, and processes the sixth data according to the third response message, so that the processed fifth data is synchronized with the second target data.
其中,第三客户端、第二客户端和第一客户端中的任意两个客户端,也可以是不同的客户端,具体此处不做限定。Among them, any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
在一些可选的实施方式中,第二节点得到处理后的第六数据之后,还会向第三客户端发送响应消息,该响应消息中携带处理后的第六数据。In some optional implementations, after obtaining the processed sixth data, the second node also sends a response message to the third client, where the response message carries the processed sixth data.
由于第三响应消息指示的内容不同,第二节点处理第六数据的方式也有所不同:Since the content indicated by the third response message is different, the way the second node processes the sixth data is also different:
在一些可选的实施方式中,如果第三响应消息指示第二目标数据的内容同步为第六数据的内容,那么第二节点会保持第六数据的内容不变,也即处理后的第六数据与第六数据的内容相同。In some optional implementations, if the third response message indicates that the content of the second target data is synchronized to the content of the sixth data, then the second node will keep the content of the sixth data unchanged, that is, the processed sixth data The content of the data is the same as the sixth data.
在一些可选的实施方式中,如果第三响应消息指示第二目标数据的内容与第六数据的内容不同,那么意味着第一节点的优先级高于第二节点的优先级,第二节点需要对第六数据进行更新,将第六数据的内容更新为第二目标数据的内容,得到修改后的第六数据。In some optional implementations, if the third response message indicates that the content of the second target data is different from the content of the sixth data, it means that the priority of the first node is higher than the priority of the second node, and the second node It is necessary to update the sixth data, update the content of the sixth data to the content of the second target data, and obtain the modified sixth data.
本申请中,第二节点能够在不同时刻接收客户端的数据修改消息,并做出响应;也可以接收不同客户端的数据修改消息,丰富了本申请技术方案的应用场景,提升了技术方案的实用性。在第二节点根据第三客户端的数据修改消息修改数据之后,会向第一节点发送数据同步消息,并根据第一节点的同步结果,确定是否进一步处理根据数据修改消息修改得到的数据,从而保证第一节点与第二节点中的数据同步,进一步提升了系统的可靠性。In this application, the second node can receive data modification messages from clients at different times and respond; it can also receive data modification messages from different clients, which enriches the application scenarios of the technical solution of this application and improves the practicality of the technical solution. . After the second node modifies the data according to the data modification message of the third client, it will send a data synchronization message to the first node, and determine whether to further process the data modified according to the data modification message according to the synchronization result of the first node, thereby ensuring The data in the first node and the second node are synchronized, further improving the reliability of the system.
示例性的,第二节点将第二历史数据进行处理,最终得到处理后的第六数据的过程如前述图7所示。 For example, the process in which the second node processes the second historical data and finally obtains the processed sixth data is as shown in the aforementioned Figure 7 .
需要注意的是,本申请中,并不限定第一节点和第二节点接收客户端的数据修改消息的时间点,第一节点和第二节点可能同时接收不同客户端的数据修改消息,也可以在不同时间点接收相同或者不同客户端的数据修改消息,具体此处不做限定。It should be noted that in this application, the time point at which the first node and the second node receive the data modification message from the client is not limited. The first node and the second node may receive the data modification message from different clients at the same time, or at different times. Data modification messages from the same or different clients are received at the time point, and the details are not limited here.
接下来,从通信系统的角度,以第一节点获取来自第一客户端的第一数据修改消息之后,进行数据处理的过程,且数据处理方法应用在分布式锁场景为例,对本申请实施例提供的数据处理方法进行说明。Next, from the perspective of the communication system, taking the first node to perform data processing after acquiring the first data modification message from the first client, and the data processing method applied in the distributed lock scenario as an example, the embodiments of the present application are provided The data processing method is explained.
请参阅图9,图9为本申请实施例提供的数据处理方法的一个流程示意图,包括以下步骤:Please refer to Figure 9. Figure 9 is a schematic flow chart of a data processing method provided by an embodiment of the present application, including the following steps:
901.第一节点获取来自于第一客户端的第一数据修改消息。901. The first node obtains the first data modification message from the first client.
902.第一节点修改第一数据,得到第二数据。902. The first node modifies the first data and obtains the second data.
903.第一节点向第二节点发送第一数据同步消息。903. The first node sends the first data synchronization message to the second node.
步骤901至步骤903与图2所示实施例中步骤201至步骤203类似,此处不再赘述。Steps 901 to 903 are similar to steps 201 to 203 in the embodiment shown in FIG. 2 and will not be described again here.
904.第二节点处理第三数据,得到第四数据。904. The second node processes the third data and obtains the fourth data.
905.第一节点接收来自于第二节点的第一响应消息。905. The first node receives the first response message from the second node.
906.第一节点处理第二数据,得到第一目标数据。906. The first node processes the second data and obtains the first target data.
步骤905和906与图2所示实施例中步骤204和205类似,此处不再赘述。Steps 905 and 906 are similar to steps 204 and 205 in the embodiment shown in FIG. 2 and will not be described again here.
907.第一节点向第一客户端发送第四响应消息。907. The first node sends a fourth response message to the first client.
该第四响应消息对应于第一客户端的第一数据修改消息,第四响应消息携带第一目标数据,从而告知第一客户端数据修改的最终结果。The fourth response message corresponds to the first data modification message of the first client, and the fourth response message carries the first target data, thereby informing the first client of the final result of the data modification.
总的来说,客户端发送锁请求(包括锁获取或锁释放等),若锁请求所对应的数据包首先到达第一节点(先到达第二节点的处理逻辑与第一节点相同),第一节点开始提供分布式锁服务。In general, the client sends a lock request (including lock acquisition or lock release, etc.). If the data packet corresponding to the lock request reaches the first node first (the processing logic of the second node arriving first is the same as that of the first node), the One node starts to provide distributed lock services.
如果当前的分布式锁不可获得(或释放失败),则第一节点直接返回操作失败到客户端。If the current distributed lock cannot be obtained (or the release fails), the first node directly returns the operation failure to the client.
如果当前锁可以成功获得,则第一节点修改自身的锁状态为占用,同时修改同步标识符sync为1,表示当前锁状态待同步。同时,第一节点发送数据同步报文至第二节点。If the current lock can be successfully obtained, the first node modifies its lock status to occupied and modifies the synchronization identifier sync to 1, indicating that the current lock status needs to be synchronized. At the same time, the first node sends a data synchronization message to the second node.
第二节点收到数据同步报文,查看自身sync是否为1,如果sync为0,则直接进行状态更新,结果反馈给第一节点。如果sync=1,则根据事先确定的优先级,判定数据同步报文的发送端的优先级是否大于自己,如果发送端有先级高,则进行数据更新;否则拒绝更新。并将数据同步结果反馈给发送端第一节点。The second node receives the data synchronization message and checks whether its sync is 1. If sync is 0, it directly updates the status and feeds the result back to the first node. If sync=1, based on the predetermined priority, it is determined whether the priority of the sender of the data synchronization message is greater than itself. If the sender has a higher priority, the data is updated; otherwise, the update is rejected. And the data synchronization result is fed back to the first node of the sending end.
第一节点收到第二节点的结果后更新自身的状态,将sync重置为0,第一节点处理结果反馈给客户端。After receiving the results from the second node, the first node updates its own status, resets sync to 0, and feeds back the processing results of the first node to the client.
需要注意的是,随着应用场景的不同,第一节点和第二节点中存储的数据所指示的内容有所不同。It should be noted that with different application scenarios, the content indicated by the data stored in the first node and the second node is different.
在上文的示例中,是以数据处理方法应用在分布式锁场景中进行的说明。在该场景下,第一节点和第二节点中存储的数据所指示的内容包括分布式锁的状态,具体包括锁释放或者锁占用。在实际应用中,数据处理方法还可以应用在其他场景中: In the above example, the data processing method is applied in a distributed lock scenario. In this scenario, the content indicated by the data stored in the first node and the second node includes the status of the distributed lock, specifically including lock release or lock occupation. In practical applications, data processing methods can also be applied in other scenarios:
在一些可选的实施方式中,数据处理方法可以应用在分布式仲裁场景中,在该场景下,第一节点和第二节点中存储的数据所指示的内容包括分布式系统中仲裁后的状态,具体包括新的主节点信息。In some optional implementations, the data processing method can be applied in a distributed arbitration scenario. In this scenario, the content indicated by the data stored in the first node and the second node includes the status after arbitration in the distributed system. , specifically including new master node information.
在分布式仲裁场景中,为了保障高可靠性,通常采用一主多备的部署模式。例如在分布式数据库中存在一个主节点,多个备份节点。当主节点故障时,需要选举产生新的主节点。本申请实施例提供的第一节点或者第二节点,可以承载分布式仲裁管理器的功能,在数据库的主节点故障后,本申请提供第一节点或者第二节点处理选举请求,从而确定产生数据库中新的主节点,并将存储新的主节点信息。In distributed arbitration scenarios, in order to ensure high reliability, a deployment model of one master and multiple backups is usually adopted. For example, in a distributed database, there is one primary node and multiple backup nodes. When the master node fails, a new master node needs to be elected. The first node or the second node provided by the embodiment of this application can carry the function of the distributed arbitration manager. After the main node of the database fails, this application provides the first node or the second node to process the election request, thereby determining the generation of the database. Create a new master node and store the new master node information.
在一些可选的实施方式中,如果数据处理方法应用在分布式缓存一致性场景中,第二节点中存储的数据所指示的内容包括某个数据的缓存信息,缓存信息指示缓存该数据的副本的客户端。In some optional implementations, if the data processing method is applied in a distributed cache consistency scenario, the content indicated by the data stored in the second node includes cache information of a certain data, and the cache information indicates caching a copy of the data. client.
在分布式缓存系统中,为了加速数据的访问过程,通常会将远端的数据缓存到本地,方便进行读写操作。因此,某一个数据可能存在着多个副本。当某个客户端需要修改数据时,客户端首先需要发送失效(invalid)信息到缓存有该数据的所有客户端,告诉它们该数据对象已经被修改。在该场景中,本申请实施例提供的第一节点或者第二节点中可以存储某个数据的缓存信息,即哪些客户端拥有该数据的副本。当需要修改时,第一节点或者第二节点可以查找到所有副本所在的位置,并发送数据失效报文。通过节点之间的连接,路由到其他的客户端。In a distributed cache system, in order to speed up the data access process, remote data is usually cached locally to facilitate read and write operations. Therefore, there may be multiple copies of a certain piece of data. When a client needs to modify data, the client first needs to send invalid information to all clients that cache the data to tell them that the data object has been modified. In this scenario, the first node or the second node provided by the embodiment of the present application can store cache information of a certain data, that is, which clients have copies of the data. When modification is required, the first node or the second node can find the location of all replicas and send a data invalidation message. Route to other clients through connections between nodes.
接下来,对本申请实施例提供的通信系统和相关设备进行说明。Next, the communication system and related equipment provided by the embodiments of the present application will be described.
请参阅图10,图10为本申请实施例提供的通信系统的一个结构示意图。Please refer to Figure 10, which is a schematic structural diagram of a communication system provided by an embodiment of the present application.
如图10所示,通信系统1000包括第一节点1001和第二节点1002,第一节点1001能够执行前述图2至图9所示实施例中第一节点所执行的操作,第二节点1002能够执行前述图2至图9所示实施例中第二节点所执行的操作,具体此处不再赘述。As shown in Figure 10, the communication system 1000 includes a first node 1001 and a second node 1002. The first node 1001 can perform the operations performed by the first node in the embodiments shown in Figures 2 to 9, and the second node 1002 can The operations performed by the second node in the aforementioned embodiments shown in FIGS. 2 to 9 are performed, and details will not be described again here.
请参阅图11,图11为本申请实施例提供的网络设备的一个结构示意图。Please refer to Figure 11, which is a schematic structural diagram of a network device provided by an embodiment of the present application.
如图11所示,如果网络设备1100为第一节点,那么网络设备1100包括收发单元1101和处理单元1102。As shown in Figure 11, if the network device 1100 is a first node, the network device 1100 includes a transceiver unit 1101 and a processing unit 1102.
收发单元1101,用于获取来自于第一客户端的第一数据修改消息,第一数据修改消息指示修改第一节点中存储的第一数据。The transceiver unit 1101 is configured to obtain a first data modification message from the first client, where the first data modification message indicates modification of the first data stored in the first node.
处理单元1102,用于根据第一数据修改消息,修改第一数据,得到第二数据。The processing unit 1102 is configured to modify the first data according to the first data modification message to obtain the second data.
收发单元1101,还用于向第二节点发送第一数据同步消息,第一数据同步消息携带第二数据,以使第二节点进行数据同步。The transceiver unit 1101 is also configured to send a first data synchronization message to the second node, where the first data synchronization message carries the second data, so that the second node performs data synchronization.
收发单元1101,还用于接收来自于第二节点的第一响应消息,第一响应消息指示第二节点的数据同步结果。The transceiver unit 1101 is also configured to receive a first response message from the second node, where the first response message indicates the data synchronization result of the second node.
处理单元1102,还用于根据第一响应消息,处理第二数据,得到第一目标数据。The processing unit 1102 is also configured to process the second data according to the first response message to obtain the first target data.
在一种可能的实施方式中,第一响应消息对应于第二节点中的第四数据,第四数据为第二节点根据第一数据同步消息对第三数据进行数据同步后得到的数据。In a possible implementation, the first response message corresponds to fourth data in the second node, and the fourth data is data obtained after the second node performs data synchronization on the third data according to the first data synchronization message.
处理单元1102,具体用于若第一响应消息指示第四数据的内容同步为第二数据的内容, 则确定第一目标数据的内容与第二数据的内容相同;若第一响应消息指示第四数据的内容与第二数据的内容不同,则将第二数据的内容更新为所第四数据的内容,得到第一目标数据。The processing unit 1102 is specifically configured to: if the first response message indicates that the content of the fourth data is synchronized to the content of the second data, Then it is determined that the content of the first target data is the same as the content of the second data; if the first response message indicates that the content of the fourth data is different from the content of the second data, then the content of the second data is updated to the content of the fourth data. , get the first target data.
在一种可能的实施方式中,处理单元1102,还用于将第一节点的同步标志位的取值置为第一值,第一值指示第一节点中存储的数据发生修改;将第一节点的同步标志位的取值更新为第二值,第二值指示第一节点存储的数据与第二节点存储的数据同步。In a possible implementation, the processing unit 1102 is also configured to set the value of the synchronization flag bit of the first node to a first value, and the first value indicates that the data stored in the first node is modified; The value of the synchronization flag bit of the node is updated to a second value, and the second value indicates that the data stored in the first node is synchronized with the data stored in the second node.
在一种可能的实施方式中,收发单元1101,还用于获取来自于第二节点的第二数据同步消息,第二数据同步消息指示第一节点进行数据同步,第二数据同步消息对应于第二节点中存储的第五数据,第五数据是第二节点根据来自于第二客户端的第二数据修改消息对第二节点中的第一历史数据修改后得到的数据。其中,第二客户端与第一客户端可以是相同的客户端,也可以是不同的客户端,具体此处不做限定。In a possible implementation, the transceiver unit 1101 is also used to obtain a second data synchronization message from the second node. The second data synchronization message instructs the first node to perform data synchronization. The second data synchronization message corresponds to the second data synchronization message. The fifth data stored in the second node is data obtained by the second node modifying the first historical data in the second node according to the second data modification message from the second client. The second client and the first client may be the same client or different clients, and the details are not limited here.
处理单元1102,还用于根据第二数据同步消息和第一节点的第一数据状态,处理第一节点中当前存储的数据,得到第一数据。The processing unit 1102 is also configured to process the data currently stored in the first node according to the second data synchronization message and the first data status of the first node to obtain the first data.
在一种可能的实施方式中,处理单元1102,具体用于若第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容相同,则将第一节点中当前存储的数据的内容更新为第五数据的内容,得到第一数据;若第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容不同,且第一节点的优先级不高于第二节点的优先级,则将第一节点中当前存储的数据的内容更新为第五数据的内容,得到第一数据;若第一数据状态指示第一节点中当前存储的数据的内容与第一历史数据的内容不同,且第一节点的优先级高于第二节点的优先级,则确定第一数据的内容与第一节点中当前存储的数据的内容相同。In a possible implementation, the processing unit 1102 is specifically configured to, if the first data status indicates that the content of the data currently stored in the first node is the same as the content of the first historical data, then convert the content of the data currently stored in the first node to The content of the data is updated to the content of the fifth data to obtain the first data; if the first data status indicates that the content of the data currently stored in the first node is different from the content of the first historical data, and the priority of the first node is not high to the priority of the second node, then update the content of the data currently stored in the first node to the content of the fifth data to obtain the first data; if the first data status indicates that the content of the data currently stored in the first node is the same as The content of the first historical data is different, and the priority of the first node is higher than the priority of the second node, then it is determined that the content of the first data is the same as the content of the data currently stored in the first node.
在一种可能的实施方式中,收发单元1101,还用于向第二节点发送对应于第二数据同步消息的第二响应消息,第二响应消息指示第一节点的数据同步结果。In a possible implementation, the transceiver unit 1101 is also configured to send a second response message corresponding to the second data synchronization message to the second node, where the second response message indicates the data synchronization result of the first node.
在一种可能的实施方式中,处理单元1102,还用于若第一节点得到第一数据,将第一节点的同步标志位的取值置为第二值,以表示第一节点和第二节点的数据已经同步。In a possible implementation, the processing unit 1102 is further configured to, if the first node obtains the first data, set the value of the synchronization flag bit of the first node to a second value to indicate that the first node and the second The node's data has been synchronized.
在一种可能的实施方式中,收发单元1101,还用于获取来自于第二节点的第三数据同步消息,第一目标数据同步消息指示第一节点进行数据同步,第一目标数据同步消息对应于第二节点中存储的第六数据,第六数据是第二节点根据来自于第三客户端的第三数据修改消息对第二节点中的第二历史数据修改后得到的数据。In a possible implementation, the transceiver unit 1101 is also used to obtain a third data synchronization message from the second node. The first target data synchronization message instructs the first node to perform data synchronization. The first target data synchronization message corresponds to The sixth data stored in the second node is data obtained by the second node after modifying the second historical data in the second node according to the third data modification message from the third client.
处理单元1102,还用于根据第三数据同步消息和第一节点的第二数据状态,处理第一目标数据,得到第二目标数据。其中,第三客户端、第二客户端和第一客户端中的任意两个客户端,也可以是不同的客户端,具体此处不做限定。The processing unit 1102 is also configured to process the first target data according to the third data synchronization message and the second data status of the first node to obtain the second target data. Among them, any two clients among the third client, the second client and the first client can also be different clients, and the details are not limited here.
在一种可能的实施方式中,处理单元1102,具体用于若第二数据状态指示第一目标数据的内容与第二历史数据的内容相同,则将第一目标数据的内容更新为第六数据的内容,得到第二目标数据;若第二数据状态指示第一目标数据的内容与第二历史数据的内容不同,且第一节点的优先级不高于第二节点的优先级,则将第一目标数据的内容更新为第六数据的内容,得到第二目标数据;若第二数据状态指示第一目标数据的内容与第二历史数据的 内容不同,且第一节点的优先级高于第二节点的优先级,则确定第二目标数据的内容与第一目标数据的内容相同。In a possible implementation, the processing unit 1102 is specifically configured to update the content of the first target data to the sixth data if the second data status indicates that the content of the first target data is the same as the content of the second historical data. The content of the second target data is obtained; if the second data status indicates that the content of the first target data is different from the content of the second historical data, and the priority of the first node is not higher than the priority of the second node, then the The content of one target data is updated to the content of the sixth data to obtain the second target data; if the second data status indicates that the content of the first target data is different from the second historical data If the content is different and the priority of the first node is higher than the priority of the second node, it is determined that the content of the second target data is the same as the content of the first target data.
在一种可能的实施方式中,收发单元1101,还用于向第二节点发送对应于第三数据同步消息的第三响应消息,第三响应消息指示第一节点的数据同步结果。In a possible implementation, the transceiver unit 1101 is also configured to send a third response message corresponding to the third data synchronization message to the second node, where the third response message indicates the data synchronization result of the first node.
在一种可能的实施方式中,处理单元1102,还用于若第一节点得到第二目标数据,修改第一节点的数据状态,将同步标志位的取值置为第二值,以表示第一节点和第二节点的数据已经同步。In a possible implementation, the processing unit 1102 is also configured to modify the data status of the first node if the first node obtains the second target data, and set the value of the synchronization flag bit to the second value to represent the second target data. The data of the first node and the second node have been synchronized.
在一种可能的实施方式中,收发单元1101,还用于向第一客户端发送第四响应消息,第四响应消息携带第一目标数据。In a possible implementation, the transceiver unit 1101 is also configured to send a fourth response message to the first client, where the fourth response message carries the first target data.
该网络设备1100可以执行前述图2至图9所示实施例中第二节点所执行的操作,此处不再赘述。The network device 1100 can perform the operations performed by the second node in the embodiments shown in FIGS. 2 to 9 , which will not be described again here.
如图11所示,如果网络设备1100为第二节点,那么网络设备1100包括收发单元1101和处理单元1102。As shown in Figure 11, if the network device 1100 is the second node, the network device 1100 includes a transceiver unit 1101 and a processing unit 1102.
收发单元1101,用于获取来自于第一节点的第一数据同步消息,第一数据同步消息指示第二节点进行数据同步,第一数据同步消息对应于第一节点中的第二数据,第二数据是第一节点根据来自于第一客户端的第一数据修改消息将第一节点中的第一数据修改后得到的数据。The transceiver unit 1101 is used to obtain a first data synchronization message from the first node. The first data synchronization message instructs the second node to perform data synchronization. The first data synchronization message corresponds to the second data in the first node. The second data synchronization message instructs the second node to perform data synchronization. The data is data obtained by the first node modifying the first data in the first node according to the first data modification message from the first client.
处理单元1102,用于根据第一数据同步消息和第二节点的第一数据状态,处理第二节点中存储的第三数据,得到第四数据。The processing unit 1102 is configured to process the third data stored in the second node according to the first data synchronization message and the first data status of the second node to obtain fourth data.
收发单元1101,还用于向第一节点发送第一响应消息,第一响应消息指示第二节点的数据同步结果,以使第一节点根据数据同步结果,处理第二数据得到第一目标数据。The transceiver unit 1101 is also configured to send a first response message to the first node. The first response message indicates the data synchronization result of the second node, so that the first node processes the second data to obtain the first target data according to the data synchronization result.
在一种可能的实施方式中,处理单元1102,具体用于若所述第一数据状态指示所述第三数据的内容与所述第一数据的内容相同,则将所述第三数据的内容更新为所述第二数据的内容,得到所述第四数据;若所述第一数据状态指示所述第三数据的内容与所述第一数据的内容不同,且所述第二节点的优先级不高于所述第一节点的优先级,则将所述第三数据的内容更新为所述第二数据的内容,得到所述第四数据。In a possible implementation, the processing unit 1102 is specifically configured to, if the first data status indicates that the content of the third data is the same as the content of the first data, change the content of the third data to Update the content of the second data to obtain the fourth data; if the first data status indicates that the content of the third data is different from the content of the first data, and the priority of the second node level is not higher than the priority level of the first node, then the content of the third data is updated to the content of the second data to obtain the fourth data.
在一种可能的实施方式中,处理单元1102,具体用于若所述第一数据状态指示所述第三数据的内容与所述第一数据的内容不同,且所述第二节点的优先级高于所述第一节点的优先级,则确定所述第四数据的内容与所述第三数据的内容相同。In a possible implementation, the processing unit 1102 is specifically configured to: if the first data status indicates that the content of the third data is different from the content of the first data, and the priority of the second node is higher than the priority of the first node, it is determined that the content of the fourth data is the same as the content of the third data.
在一种可能的实施方式中,处理单元1102,还用于将所述第一数据状态更新为第二数据状态,所述第二数据状态指示所述第二节点与所述第一节点的数据同步。In a possible implementation, the processing unit 1102 is also configured to update the first data state to a second data state, where the second data state indicates the data of the second node and the first node. Synchronize.
在一种可能的实施方式中,收发单元1101,还用于获取来自于第二客户端的第二数据修改消息,所述第二数据修改消息指示修改所述第二节点中存储的第一历史数据。In a possible implementation, the transceiver unit 1101 is also configured to obtain a second data modification message from the second client, where the second data modification message indicates modification of the first historical data stored in the second node. .
处理单元1102,还用于根据所述第二数据修改消息,修改所述第一历史数据,得到第五数据。The processing unit 1102 is also configured to modify the first historical data according to the second data modification message to obtain fifth data.
收发单元1101,还用于向第一节点发送第二数据同步消息,以使所述第一节点对所述第一节点当前存储的数据进行数据同步得到所述第一数据;接收来自于所述第一节点的第 二响应消息,所述第二响应消息指示所述第一节点的数据同步结果。The transceiver unit 1101 is also configured to send a second data synchronization message to the first node, so that the first node performs data synchronization on the data currently stored in the first node to obtain the first data; receiving from the The first node's Two response messages, the second response message indicates the data synchronization result of the first node.
处理单元1102,还用于根据所述第二响应消息,处理所述第五数据。The processing unit 1102 is also configured to process the fifth data according to the second response message.
在一种可能的实施方式中,处理单元1102,具体用于若所述第二响应消息指示所述第一数据的内容同步为所述第五数据的内容,则保持所述第五数据的内容不变。若所述第二响应消息指示所述第一数据的内容与所述第五数据的内容不同,则将所述第五数据的内容更新为所述第一数据的内容。In a possible implementation, the processing unit 1102 is specifically configured to maintain the content of the fifth data if the second response message indicates that the content of the first data is synchronized to the content of the fifth data. constant. If the second response message indicates that the content of the first data is different from the content of the fifth data, the content of the fifth data is updated to the content of the first data.
在一种可能的实施方式中,收发单元1101,还用于获取来自于第三客户端的第三数据修改消息,所述第三数据修改消息指示修改所述第二节点中存储的第二历史数据。In a possible implementation, the transceiver unit 1101 is also configured to obtain a third data modification message from a third client, where the third data modification message indicates modification of the second historical data stored in the second node. .
处理单元1102,还用于根据所述第三数据修改消息,修改所述第二历史数据,得到第六数据。The processing unit 1102 is also configured to modify the second historical data according to the third data modification message to obtain sixth data.
收发单元1101,还用于向第一节点发送第三数据同步消息,以使所述第一节点对所述第一目标数据进行数据同步得到第二目标数据;接收来自于所述第一节点的第三响应消息,所述第三响应消息指示所述第一节点的数据同步结果。The transceiver unit 1101 is also configured to send a third data synchronization message to the first node, so that the first node performs data synchronization on the first target data to obtain the second target data; and receives a third data synchronization message from the first node. A third response message indicating the data synchronization result of the first node.
处理单元1102,还用于根据所述第三响应消息,处理所述第六数据。The processing unit 1102 is also configured to process the sixth data according to the third response message.
在一种可能的实施方式中,处理单元1102,具体用于若所述第三响应消息指示所述第二目标数据的内容同步为所述第六数据的内容,则保持所述第六数据的内容不变;若所述第三响应消息指示所述第二目标数据的内容与所述第六数据的内容不同,则将所述第六数据的内容更新为所述第二目标数据的内容。In a possible implementation, the processing unit 1102 is specifically configured to maintain the content of the sixth data if the third response message indicates that the content of the second target data is synchronized to the content of the sixth data. The content remains unchanged; if the third response message indicates that the content of the second target data is different from the content of the sixth data, then the content of the sixth data is updated to the content of the second target data.
该网络设备1100可以执行前述图2至图10所示实施例中第二节点所执行的操作,此处不再赘述。The network device 1100 can perform the operations performed by the second node in the embodiments shown in FIGS. 2 to 10 , which will not be described again here.
下面,请参阅图12,图12为本申请实施例提供的网络设备的一个结构示意图。Next, please refer to Figure 12, which is a schematic structural diagram of a network device provided by an embodiment of the present application.
该网络设备1200包括:处理器1201和存储器1202,存储器1202中存储有一个或一个以上的应用程序或数据。The network device 1200 includes: a processor 1201 and a memory 1202. One or more application programs or data are stored in the memory 1202.
其中,存储器1202可以是易失性存储或持久存储。存储在存储器1202的程序可以包括一个或一个以上模块,每个模块可以用于执行网络设备1200所执行的一系列操作。更进一步地,处理器1201可以与存储器1202通信,在网络设备1200上执行存储器1202中的一系列指令操作。处理器1201可以是中央处理器(central processing units,CPU),也可以是单核处理器,除此之外,还可以是其他类型的处理器,例如双核处理器,具体此处不做限定。Among them, the memory 1202 may be volatile storage or persistent storage. The program stored in memory 1202 may include one or more modules, and each module may be used to perform a series of operations performed by network device 1200 . Furthermore, the processor 1201 can communicate with the memory 1202 to execute a series of instruction operations in the memory 1202 on the network device 1200 . The processor 1201 can be a central processing unit (CPU) or a single-core processor. In addition, it can also be other types of processors, such as a dual-core processor, and the details are not limited here.
网络设备1200还可以包括一个或一个以上通信接口1203,一个或一个以上操作系统,例如WindowsServerTM,MacOSXTM,UnixTM,LinuxTM,FreeBSDTM等。The network device 1200 may also include one or more communication interfaces 1203, and one or more operating systems, such as Windows Server ™ , MacOSX ™ , Unix ™ , Linux ™ , FreeBSD ™ , etc.
该网络设备1200可以执行前述图2至图9所示实施例中第一节点或者第二节点所执行的操作,以及图10所示实施例中网络设备所执行的操作,此处不再赘述。The network device 1200 can perform the operations performed by the first node or the second node in the embodiment shown in FIG. 2 to FIG. 9 , and the operations performed by the network device in the embodiment shown in FIG. 10 , which will not be described again here.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be described again here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的 划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative, for example, the unit Division is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。 If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program code. .
Claims (25)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210909739.9 | 2022-07-29 | ||
| CN202210909739.9A CN117527532A (en) | 2022-07-29 | 2022-07-29 | Data processing methods, communication systems and related equipment |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024021746A1 true WO2024021746A1 (en) | 2024-02-01 |
Family
ID=89705208
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2023/092513 Ceased WO2024021746A1 (en) | 2022-07-29 | 2023-05-06 | Data processing method, communication system, and related device |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN117527532A (en) |
| WO (1) | WO2024021746A1 (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102801543A (en) * | 2011-05-24 | 2012-11-28 | 中国银联股份有限公司 | Method for dynamic data synchronization between active-active systems |
| CN113779143A (en) * | 2021-08-20 | 2021-12-10 | 中国邮政储蓄银行股份有限公司 | Double-activity data center and business system |
| CN113836155A (en) * | 2021-09-14 | 2021-12-24 | 青岛海尔科技有限公司 | Data processing method, device and storage medium based on distributed system |
| WO2022061807A1 (en) * | 2020-09-27 | 2022-03-31 | 华为技术有限公司 | Data storage method and device |
-
2022
- 2022-07-29 CN CN202210909739.9A patent/CN117527532A/en active Pending
-
2023
- 2023-05-06 WO PCT/CN2023/092513 patent/WO2024021746A1/en not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102801543A (en) * | 2011-05-24 | 2012-11-28 | 中国银联股份有限公司 | Method for dynamic data synchronization between active-active systems |
| WO2022061807A1 (en) * | 2020-09-27 | 2022-03-31 | 华为技术有限公司 | Data storage method and device |
| CN113779143A (en) * | 2021-08-20 | 2021-12-10 | 中国邮政储蓄银行股份有限公司 | Double-activity data center and business system |
| CN113836155A (en) * | 2021-09-14 | 2021-12-24 | 青岛海尔科技有限公司 | Data processing method, device and storage medium based on distributed system |
Also Published As
| Publication number | Publication date |
|---|---|
| CN117527532A (en) | 2024-02-06 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8671151B2 (en) | Maintaining item-to-node mapping information in a distributed system | |
| US9218299B2 (en) | Recovering data segment contents in a distributed shared memory | |
| CN100478902C (en) | Geographically distributed clusters | |
| WO2016070375A1 (en) | Distributed storage replication system and method | |
| CN102012944B (en) | Distributed NOSQL (not only structured query language) database capable of providing replication property | |
| CN113010549A (en) | Data processing method based on remote multi-active system, related equipment and storage medium | |
| CN100388225C (en) | Cluster database with remote data mirroring | |
| CN115292408A (en) | Master-slave synchronization method, device, equipment and medium for MySQL database | |
| CN112243030A (en) | Data synchronization method, device, device and medium of distributed storage system | |
| CN112230853A (en) | Storage capacity adjustment method, device, device, and storage medium | |
| CN114885007B (en) | Method and electronic device for real-time strong consistency session synchronization | |
| CN112202601A (en) | Application method of two physical node mongo clusters operated in duplicate set mode | |
| CN110704541A (en) | High-availability distributed method and architecture for Redis cluster multi-data center | |
| CN112052104B (en) | Message queue management method based on multi-machine-room implementation and electronic equipment | |
| WO2024021746A1 (en) | Data processing method, communication system, and related device | |
| CN106951443A (en) | The method, apparatus and system of copies synchronized based on distributed system | |
| CN117668103B (en) | Data processing method, system, electronic equipment and computer storage medium | |
| CN113297134B (en) | Data processing system and data processing method, device and electronic equipment | |
| CN114840365A (en) | Abnormal state double live volume expansion method, system, terminal and storage medium | |
| JP2726001B2 (en) | Error recovery method in computer system | |
| CN120675814A (en) | Vhost-user identity authentication and I/O authentication method for distributed system | |
| CN116684261A (en) | Cluster architecture control method and device, storage medium and electronic equipment | |
| CN117149515A (en) | Data backup method and device | |
| CN117749818A (en) | Cross-machine-room data synchronization system | |
| CN114448781A (en) | Data processing system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23844961 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 23844961 Country of ref document: EP Kind code of ref document: A1 |