Data synchronization method and system based on distributed application coordination service
By creating information nodes and data nodes in distributed application coordination services, collaborative work between the publishing end and the synchronization end is achieved, the problem of data inconsistency between clusters is solved, the burden on operation and maintenance personnel is reduced, and automated data migration and updates are realized.
Patent Information
- Application Number
- CN202411652195.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, the problem of inconsistency between clusters has led to an increase in the burden on operation and maintenance personnel, and it is difficult to realize automated data migration and updates.
The data synchronization method based on distributed application coordination services is adopted, and data node registration and monitoring are created, and the coordinated work of the publishing end and the synchronization end can be achieved to ensure data consistency.
It reduces the burden on operation and maintenance personnel, realizes automated migration and update of data between different platforms and servers, and ensures consistency of data between clusters.
Smart Images

Figure CN119760012A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data synchronization, and in particular to a data synchronization method and system based on distributed application coordination services. Background Art
[0002] Cluster data synchronization is to solve the data migration and update work between different platforms (such as: Windows, Linux, etc.) and different servers, and it is necessary to ensure data consistency. In related technologies, data migration and update operations between different platforms and different servers are mainly completed by operation and maintenance personnel on each server by configuring scheduled tasks, manually executing command scripts, and manually executing copies. However, this lack of automation has invisibly increased the burden on operation and maintenance personnel, and it is also inevitable that data inconsistencies between clusters will occur. Summary of the invention
[0003] The present application provides a data synchronization method, system, electronic device and storage medium based on a distributed application coordination service to solve the problem of data inconsistency between clusters.
[0004] In a first aspect, an embodiment of the present application provides a data synchronization method based on a distributed application coordination service, comprising:
[0005] The distributed application coordination service creates information nodes, wherein the information nodes include a version information node, a consistency information node, and an online information node;
[0006] The data node registers and monitors the information node, and the data node includes a publishing end and a synchronization end;
[0007] The publishing end publishes the data version, and records the data version published by the publishing end into the version information node;
[0008] When the synchronization end monitors that the data on the version information node changes, it pulls the data version published by the publishing end to the synchronization end offline directory of the synchronization end, and records the data version in the synchronization end offline directory to the online information node;
[0009] When the publishing end monitors that the online information nodes corresponding to all synchronization ends have changed, it detects whether the data version published by the publishing end is consistent with the data version in the offline directories of all synchronization ends to determine the detection result; and records the detection result to the consistency information node;
[0010] If the synchronization end monitors that the consistency information node has changed, and the detection result in the consistency information node is consistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are switched.
[0011] In some embodiments, the method further comprises:
[0012] The synchronization end uses the data version in the switched synchronization end online directory to upgrade the data version in the switched synchronization end offline directory.
[0013] In some embodiments, the method further comprises:
[0014] If the detection result is inconsistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are kept unchanged.
[0015] In some embodiments, the step of publishing the data version by the publishing end includes:
[0016] When receiving the data version publishing instruction, the publishing end calculates the hash value of the data version in the online directory of the publishing end; compares the hash value of the data version in the online directory of the publishing end with the hash value of the data version in the offline directory of the publishing end;
[0017] If they are different, an incremental difference file is created based on the data version in the online directory of the publishing end and the data version in the offline directory of the publishing end;
[0018] The incremental difference file is used to upgrade the data version in the offline directory of the publishing end, and the hash value of the current data version in the offline directory of the publishing end is calculated; and the current data version in the offline directory of the publishing end is published.
[0019] In some embodiments, after the step of pulling the data version published by the publishing end to the offline directory of the synchronization end of the synchronization end, the step further includes:
[0020] Calculate the hash value of the data version in the synchronization end offline directory of the synchronization end.
[0021] In some embodiments, the step of detecting whether the data version published by the publishing end is consistent with the data version in the offline directories of all synchronization ends to determine the detection result includes:
[0022] Determine whether the hash value of the data version in the offline directory of the synchronization end in the online information node is the same as the hash value of the data version published by the publishing end;
[0023] If they are the same, then the test results are determined to be consistent;
[0024] If they are not the same, the detection result is determined to be inconsistent.
[0025] In some embodiments, the method further comprises:
[0026] When the publishing end receives the instruction to publish the data version, the publishing end writes the memory data of the publishing end to the disk.
[0027] In a second aspect, an embodiment of the present application further provides a data synchronization system based on a distributed application coordination service, comprising:
[0028] Distributed application coordination service, used to create information nodes, including version information nodes, consistency information nodes and online information nodes;
[0029] A data node, used to register and monitor the information node, the data node includes a publishing end and a synchronization end;
[0030] A publishing end, used to publish a data version, and record the data version published by the publishing end into the version information node;
[0031] The synchronization end is used to pull the data version published by the publishing end to the synchronization end offline directory of the synchronization end when the synchronization end monitors the data change on the version information node, and record the data version in the synchronization end offline directory to the online information node;
[0032] The publishing end is also used to detect whether the data version published by the publishing end is consistent with the data version in the offline directory of all synchronization ends when the publishing end monitors the change of the online information nodes corresponding to all synchronization ends, so as to determine the detection result; and record the detection result to the consistency information node;
[0033] The synchronization end is also used to switch the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end if the synchronization end monitors that the consistency information node has changed and the detection result in the consistency information node is consistent.
[0034] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the data synchronization method based on a distributed application coordination service when executing the computer program.
[0035] In a fourth aspect, the embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the data synchronization method based on the distributed application coordination service are implemented.
[0036] In the above embodiment, a data synchronization method, system, electronic device and storage medium based on distributed application coordination service are provided. In the method, a distributed application coordination service is used, and a data node monitors an information node, and the information node includes a publishing end and a synchronization end. The publishing end publishes a data version and records the data version to a version information node. When the synchronization end monitors that the data on the version information node has changed, the data version published by the publishing end is obtained to the offline directory of the synchronization end, and the data version in the offline directory of the synchronization end is recorded to the online information node. When the publishing end monitors that the online information nodes corresponding to all synchronization ends have changed, it detects whether the data version published by the publishing end is consistent with the data version in the offline directory of the synchronization end of all synchronization ends, obtains the detection result, and records it to the consistency information node. If the synchronization end monitors that the consistency information node has changed, and the detection result in the consistency information node is consistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are switched. Through the above method, the burden of operation and maintenance personnel can be reduced, and the migration and update of data between different platforms and different servers can be guaranteed, as well as the consistency of data between clusters can be guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A flowchart of a method for data synchronization based on a distributed application coordination service provided according to some embodiments is exemplarily shown;
[0038] Figure 2 The flowchart of another data synchronization method based on a distributed application coordination service provided according to some embodiments is exemplified. DETAILED DESCRIPTION
[0039] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0040] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0041] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.
[0042] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0043] Cluster data synchronization is to solve the data migration and update work between different platforms (such as: Windows, Linux, etc.) and different servers, and it is necessary to ensure data consistency. In related technologies, data migration and update operations between different platforms and different servers are mainly completed by operation and maintenance personnel on each server by configuring scheduled tasks, manually executing command scripts, and manually executing copies. However, this lack of automation has invisibly increased the burden on operation and maintenance personnel, and it is also inevitable that data inconsistencies between clusters will occur.
[0044] In order to solve the above technical problems, the embodiment of the present application provides a data synchronization method, system, electronic device and storage medium based on distributed application coordination service. In the method, the distributed application coordination service is used, and the data node monitors the information node, and the information node includes a publishing end and a synchronization end. The publishing end publishes the data version and records the data version to the version information node. When the synchronization end monitors that the data on the version information node changes, the data version published by the publishing end is obtained to the offline directory of the synchronization end, and the data version in the offline directory of the synchronization end is recorded to the online information node. When the publishing end monitors that the online information nodes corresponding to all synchronization ends change, it detects whether the data version published by the publishing end is consistent with the data version in the offline directory of the synchronization end of all synchronization ends, obtains the detection result, and records it to the consistency information node. If the synchronization end monitors that the consistency information node changes, and the detection result in the consistency information node is consistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are switched. Through the above method, the burden of operation and maintenance personnel can be reduced, and the migration and update of data between different platforms and different servers can be guaranteed, as well as the consistency of data between clusters can be guaranteed.
[0045] Figure 1 A flowchart of a data synchronization method based on a distributed application coordination service provided according to some embodiments is exemplarily shown. The method includes S100-S600.
[0046] S100. The distributed application coordination service creates information nodes, where the information nodes include a version information node, a consistency information node, and an online information node.
[0047] As an open source distributed application coordination service, Zookeeper can realize functions such as data publishing and subscription, coordination notification, cluster management, and further realize the function of data synchronization between different platforms and different servers under the cluster.
[0048] In the embodiment of the present application, a distributed application coordination service is used to realize data synchronization between different servers in a cluster as an example. All servers in the same cluster register a listening function with the distributed application coordination service, set and perceive the changes of information nodes in the distributed application coordination service and respond accordingly, thereby realizing relevant processing operations on the data, and finally realizing data synchronization and achieving the purpose of data consistency in the same cluster. The cluster mentioned here refers to all servers connected to the same distributed application coordination service. The information node is a Zookeeper-related directory.
[0049] In the embodiment of the present application, creating an information node on the distributed application coordination service can be completed by initializing the coordination management information of the distributed application coordination service.
[0050] S200: A data node registers and monitors the information node, wherein the data node includes a publishing end and a synchronization end.
[0051] The publisher refers to the server that executes the publishing of data versions, and the synchrotron refers to the server that executes the synchronization of data versions. The publisher and synchrotron are collectively referred to as data nodes. There is no rigid distinction between publishers and synchrotrons in the cluster, and each data node can be both a publisher and a synchrotron. Both the publisher and the synchrotron register and monitor the information node. The distributed application coordination service can be deployed separately or share a server with the data node.
[0052] Figure 2 The following is a schematic diagram showing the distribution of a publishing end, a synchronization end, and a distributed application coordination service provided according to some embodiments. Figure 2 It includes a distributed application coordination service (Zookeeper coordination management center), four synchronization terminals and one publishing terminal. When the data in the information node in the distributed application coordination service changes, the corresponding monitoring function will be automatically called to process the changed data.
[0053] S300: The publishing end publishes a data version, and records the data version published by the publishing end into the version information node.
[0054] In the embodiment of the present application, after the data version in the publishing end is upgraded, when the upgraded data version needs to be synchronized to the synchronization end, the publishing end publishes the data version. When the publishing end publishes the data version, the data version published by the publishing end is recorded in the version information node in the distributed application coordination service.
[0055] In some embodiments, Figure 2 A flowchart of another data synchronization method based on a distributed application coordination service provided according to some embodiments is exemplarily shown, wherein the step of the publishing end publishing a data version includes S301-S305.
[0056] S301. When receiving a data version publishing instruction, the publishing end calculates a hash value of the data version in the online directory of the publishing end.
[0057] In the embodiment of the present application, both the publishing end and the synchronization end store a space twice the size of the reserved data version, where the data version in one space is used for online use, and this data version is also called the data version in the online directory; the data version in the other space is used for synchronization, and this data version is also called the data version in the offline directory. In this way, there is no need to temporarily copy a new data each time the data version is synchronized. For files with large amounts of data, this process is very time-consuming and even unacceptable; at the same time, the synchronization of offline data will not affect the use of online data. This method of synchronizing offline copies performs redundant backup of data, which can achieve performance improvement.
[0058] In the embodiment of the present application, the data version published by the publishing end is the data version used online by the publishing end, that is, the data version in the online directory of the publishing end. When the publishing end receives the instruction to publish the data version, the publishing end first compares the data version in the online directory of the publishing end with the data version in the offline directory of the publishing end. If the data version in the offline directory of the publishing end is the same as the data version in the online directory of the publishing end, the publishing end synchronizes the data version in the offline directory of the publishing end for synchronization to the synchronization end, so that the synchronization end can use the same data version as the online publishing end.
[0059] In the embodiment of the present application, the corresponding hash value is used when comparing the data version in the online directory of the publishing end and the data version in the offline directory of the publishing end. A hash value is a fixed-length value calculated by a hash algorithm from the original data, which is used to ensure the integrity and consistency of data transmission. The hash value can be an MD5 value. Therefore, in the present embodiment, the hash value of the data version in the online directory of the publishing end and the hash value of the data version in the offline directory of the publishing end are compared.
[0060] In some embodiments, the method further includes: when the publishing end receives the data version publishing instruction, the publishing end writes the memory data of the publishing end to the disk. The writing to the disk refers to the process of transferring the data originally stored in the memory (RAM) to the disk (such as a hard disk or a solid state drive SSD) for storage.
[0061] S302: Compare the hash value of the data version in the online directory of the publishing end with the hash value of the data version in the offline directory of the publishing end.
[0062] In the embodiment of the present application, the hash value of the data version in the offline directory of the publishing end is obtained when step S305 was last executed, that is, the data version in the offline directory of the publishing end is upgraded by using the incremental difference file, and the hash value of the current data version in the offline directory of the publishing end is calculated.
[0063] S303: If they are different, an incremental difference file is created according to the data version in the online directory of the publishing end and the data version in the offline directory of the publishing end.
[0064] In an embodiment of the present application, the hash value of the data version in the online directory of the publishing end and the hash value of the data version in the offline directory of the publishing end are compared. If they are different, it means that the data version in the offline directory of the publishing end currently used for synchronization is different from the data version in the online directory of the publishing end currently used online. At this time, the data version in the offline directory of the publishing end needs to be updated to the data version in the online directory of the publishing end. Specifically, an incremental difference file can be created, which is the different data between the data version in the online directory of the publishing end and the data version in the offline directory of the publishing end.
[0065] In the embodiment of the present application, in addition to pre-storing space twice the size of the reserved data version, the data node also reserves additional space to save the historical version of the incremental difference file.
[0066] S304: Use the incremental difference file to upgrade the data version in the offline directory of the publishing end, calculate the hash value of the current data version in the offline directory of the publishing end, and publish the current data version in the offline directory of the publishing end.
[0067] In an embodiment of the present application, after the data version in the offline directory of the publishing end is upgraded by using the incremental difference file, the data version in the offline directory of the publishing end is the same as the data version in the online directory of the publishing end. Calculating the hash value of the data version in the current offline directory of the publishing end can be understood as calculating the hash value of the data version in the offline directory of the publishing end after the upgrade. When the step of comparing the hash value of the data version in the online directory of the publishing end with the hash value of the data version in the offline directory of the publishing end is performed next time, the hash value of the data version in the current offline directory of the publishing end obtained in S304 and the hash value of the data version in the online directory of the publishing end can be directly used for comparison. If the hash values are the same, it is determined that the data version in the online directory of the publishing end is the same as the data version in the offline directory of the publishing end.
[0068] S305: If they are the same, directly publish the data version in the offline directory of the publishing end.
[0069] In the embodiment of the present application, if they are the same, it means that the data version in the offline directory of the publishing end currently used for synchronization is the same as the data version in the online directory of the publishing end currently used online. At this time, the data version in the offline directory of the publishing end is directly published, and S303 is not executed to create an incremental difference file based on the data version in the online directory of the publishing end and the data version in the offline directory of the publishing end, and the step of using the incremental difference file in step S304 to upgrade the data version in the offline directory of the publishing end is not executed.
[0070] In some embodiments, after the data version in the offline directory of the publishing end is released, the publishing end can continue to add, delete, and modify the data version in the online directory of the publishing end according to demand.
[0071] S400. When the synchronization end monitors that the data on the version information node has changed, the synchronization end pulls the data version published by the publishing end to the synchronization end offline directory of the synchronization end, and records the data version in the synchronization end offline directory to the online information node.
[0072] In the embodiment of the present application, when the synchronization end monitors that the data on the version information node has changed, it indicates that the publishing end has published the data version. Since the synchronization end offline directory of the synchronization end is used to store the data version used by the synchronization end for synchronization, the synchronization end places the data version published by the publishing end in the synchronization end offline directory after pulling it. In addition, the synchronization end records the data version in the synchronization end offline directory to the online information node, that is, the data version pulled from the publishing end to the online information node.
[0073] In some embodiments, the online information node is a temporary node determined by the identifier of the data node. Each data node has a unique identifier, which can be the IP (Internet Protocol) address of the data node, so that when the online information node is created, it can be added to the cluster, and when the online information node needs to be deleted, it can be removed from the cluster.
[0074] S500: When the publishing end monitors that the online information nodes corresponding to all synchronization ends have changed, it detects whether the data version published by the publishing end is consistent with the data version in the offline directory of all synchronization ends to determine the detection result; and records the detection result to the consistency information node.
[0075] In the embodiment of the present application, when the publishing end monitors that the online information nodes corresponding to all synchronization ends have changed, it means that the data version published by the publishing end has been synchronized to the offline directories of the synchronization ends of all synchronization ends. Since the data version published by the publishing end may be tampered with when it is synchronized to the offline directory of the synchronization end, after the data version published by the publishing end has been synchronized to the offline directory of the synchronization end of all synchronization ends, it is detected whether the data version published by the publishing end is consistent with the data version in the offline directory of the synchronization end of all synchronization ends to obtain the detection result.
[0076] In the embodiment of the present application, the detection result includes consistency and inconsistency. It should be noted that no matter whether the detection result is consistent or inconsistent, the detection result will be recorded in the consistency information node.
[0077] In some embodiments, after the step of pulling the data version published by the publishing end to the offline directory of the synchronization end, it also includes: calculating the hash value of the data version in the offline directory of the synchronization end.
[0078] In this embodiment, when detecting whether the data version published by the publishing end is consistent with the data version in the offline directory of all synchronization ends, it can be completed by comparing the hash value of the data version published by the publishing end and the hash value of the data version in the offline directory of the synchronization end.
[0079] In some embodiments, the step of detecting whether the data version published by the publishing end is consistent with the data version in the offline directories of all synchronization ends to determine the detection result includes:
[0080] Determine whether the hash value of the data version in the offline directory of the synchronization end in the online information node is the same as the hash value of the data version published by the publishing end; if they are the same, determine that the detection result is consistent; if they are not the same, determine that the detection result is inconsistent.
[0081] S600: If the synchronization end monitors that the consistency information node has changed, and the detection result in the consistency information node is consistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are switched.
[0082] In an embodiment of the present application, if the detection result in the consistency information node is consistent, it means that the data version synchronized by the publishing end is the same as the data version in the current synchronization end offline directory. At this time, the data version in the synchronization end offline directory can be switched to the synchronization end online directory, so that the synchronization end can use the data version in the synchronization end online directory for online use.
[0083] In some embodiments, the method further includes: the synchronization end upgrading the data version in the offline directory of the switched synchronization end using the data version in the online directory of the switched synchronization end.
[0084] In this embodiment, since the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are switched, the data version in the current offline directory of the synchronization end is the original data version in the online directory of the synchronization end. At this time, the synchronization end is also required to use the data version in the online directory of the synchronization end after switching to upgrade the data version in the offline directory of the synchronization end after switching, so that the data version in the offline directory of the synchronization end after the upgrade is the same as the data version in the online directory version of the synchronization end.
[0085] In the above embodiment, a data synchronization method, system, electronic device and storage medium based on distributed application coordination service are provided. In the method, a distributed application coordination service is used, and a data node monitors an information node, and the information node includes a publishing end and a synchronization end. The publishing end publishes a data version and records the data version to a version information node. When the synchronization end monitors that the data on the version information node has changed, the data version published by the publishing end is obtained to the offline directory of the synchronization end, and the data version in the offline directory of the synchronization end is recorded to the online information node. When the publishing end monitors that the online information nodes corresponding to all synchronization ends have changed, it detects whether the data version published by the publishing end is consistent with the data version in the offline directory of the synchronization end of all synchronization ends, obtains the detection result, and records it to the consistency information node. If the synchronization end monitors that the consistency information node has changed, and the detection result in the consistency information node is consistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are switched. Through the above method, the burden of operation and maintenance personnel can be reduced, and the migration and update of data between different platforms and different servers can be guaranteed, as well as the consistency of data between clusters can be guaranteed.
[0086] Further, as Figure 1-2The specific implementation of the method, the embodiment of the present application provides a data synchronization system based on a distributed application coordination service, including:
[0087] Distributed application coordination service, used to create information nodes, including version information nodes, consistency information nodes and online information nodes;
[0088] A data node, used to register and monitor the information node, the data node includes a publishing end and a synchronization end;
[0089] A publishing end, used to publish a data version, and record the data version published by the publishing end into the version information node;
[0090] The synchronization end is used to pull the data version published by the publishing end to the synchronization end offline directory of the synchronization end when the synchronization end monitors the data change on the version information node, and record the data version in the synchronization end offline directory to the online information node;
[0091] The publishing end is also used to detect whether the data version published by the publishing end is consistent with the data version in the offline directory of all synchronization ends when the publishing end monitors the changes of the online information nodes corresponding to all synchronization ends, so as to determine the detection result; and record the detection result to the consistency information node;
[0092] The synchronization end is also used to switch the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end if the synchronization end monitors that the consistency information node has changed and the detection result in the consistency information node is consistent.
[0093] It should be noted that for other corresponding descriptions of the functional units involved in the data synchronization system based on distributed application coordination service provided in this embodiment, please refer to Figure 1-2 The corresponding description in will not be repeated here.
[0094] In a specific application scenario, the system also includes:
[0095] The synchronization end is also used to upgrade the data version in the offline directory of the switched synchronization end by using the data version in the online directory of the switched synchronization end.
[0096] It should be noted that for other corresponding descriptions of the functional units involved in the data synchronization system based on distributed application coordination service provided in this embodiment, please refer to Figure 1-2 The corresponding description in will not be repeated here.
[0097] In a specific application scenario, the system also includes:
[0098] The synchronization end is further configured to keep the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end unchanged if the detection result is inconsistent.
[0099] It should be noted that for other corresponding descriptions of the functional units involved in the data synchronization system based on distributed application coordination service provided in this embodiment, please refer to Figure 1-2 The corresponding description in will not be repeated here.
[0100] In a specific application scenario, the publishing end is specifically used for:
[0101] When receiving the data version publishing instruction, the publishing end calculates the hash value of the data version in the online directory of the publishing end; compares the hash value of the data version in the online directory of the publishing end with the hash value of the data version in the offline directory of the publishing end;
[0102] If they are different, an incremental difference file is created based on the data version in the online directory of the publishing end and the data version in the offline directory of the publishing end;
[0103] The incremental difference file is used to upgrade the data version in the offline directory of the publishing end, and the hash value of the current data version in the offline directory of the publishing end is calculated; and the current data version in the offline directory of the publishing end is published.
[0104] It should be noted that for other corresponding descriptions of the functional units involved in the data synchronization system based on distributed application coordination service provided in this embodiment, please refer to Figure 1-2 The corresponding description in will not be repeated here.
[0105] In a specific application scenario, the synchronization end is also used to calculate a hash value of a data version in an offline directory of the synchronization end.
[0106] It should be noted that for other corresponding descriptions of the functional units involved in the data synchronization system based on distributed application coordination service provided in this embodiment, please refer to Figure 1-2 The corresponding description in will not be repeated here.
[0107] In a specific application scenario, the publishing end is specifically used for:
[0108] Determine whether the hash value of the data version in the offline directory of the synchronization end in the online information node is the same as the hash value of the data version published by the publishing end;
[0109] If they are the same, then the test results are determined to be consistent;
[0110] If they are not the same, the detection result is determined to be inconsistent.
[0111] It should be noted that for other corresponding descriptions of the functional units involved in the data synchronization system based on distributed application coordination service provided in this embodiment, please refer to Figure 1-2 The corresponding description in will not be repeated here.
[0112] In a specific application scenario, the publishing end is also used to write the memory data of the publishing end to the disk when receiving a data version publishing instruction.
[0113] It should be noted that for other corresponding descriptions of the functional units involved in the data synchronization system based on distributed application coordination service provided in this embodiment, please refer to Figure 1-2 The corresponding description in will not be repeated here.
[0114] Based on the above Figure 1-2 The method shown in the embodiment of the present application accordingly provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned Figure 1-2 The data synchronization method based on distributed application coordination service is shown.
[0115] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0116] Based on the above Figure 1-2 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides a physical device for data synchronization based on a distributed application coordination service, which can be a computer, a smart phone, a tablet computer, a smart watch, a server, or a network device, etc. The physical device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1-2 The data synchronization method based on distributed application coordination service is shown.
[0117] Optionally, the physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0118] Those skilled in the art will appreciate that the electronic device structure provided in this embodiment does not limit the electronic device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0119] The storage medium may also include an operating device and a network communication module. The operating device is a program that manages and saves the hardware and software resources of the electronic device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the various controls inside the storage medium, and the communication with other hardware and software in the physical device.
[0120] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware.
[0121] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the units or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the units in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The units of the above-mentioned implementation scenarios can be combined into one unit, or can be further split into multiple sub-units.
[0122] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A data synchronization method based on distributed application coordination service, characterized in that: include: The distributed application coordination service creates information nodes, wherein the information nodes include a version information node, a consistency information node, and an online information node; The data node registers and monitors the information node, and the data node includes a publishing end and a synchronization end; The publishing end publishes the data version, and records the data version published by the publishing end into the version information node; When the synchronization end monitors that the data on the version information node changes, it pulls the data version published by the publishing end to the synchronization end offline directory of the synchronization end, and records the data version in the synchronization end offline directory to the online information node; When the publishing end monitors that the online information nodes corresponding to all synchronization ends have changed, it detects whether the data version published by the publishing end is consistent with the data version in the offline directories of all synchronization ends to determine the detection result; Recording the detection result to the consistency information node; If the synchronization end monitors that the consistency information node has changed, and the detection result in the consistency information node is consistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are switched.
2. The method according to claim 1, characterized in that Also includes: The synchronization end uses the data version in the switched synchronization end online directory to upgrade the data version in the switched synchronization end offline directory.
3. The method according to claim 1, characterized in that Also includes: If the detection result is inconsistent, the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end are kept unchanged.
4. The method according to claim 1, characterized in that: The step of publishing the data version by the publishing end includes: When receiving the data version publishing instruction, the publishing end calculates the hash value of the data version in the online directory of the publishing end; compares the hash value of the data version in the online directory of the publishing end with the hash value of the data version in the offline directory of the publishing end; If they are different, an incremental difference file is created based on the data version in the online directory of the publishing end and the data version in the offline directory of the publishing end; The incremental difference file is used to upgrade the data version in the offline directory of the publishing end, and the hash value of the current data version in the offline directory of the publishing end is calculated; and the current data version in the offline directory of the publishing end is published.
5. The method according to claim 1, characterized in that: After the step of pulling the data version published by the publishing end to the offline directory of the synchronization end of the synchronization end, the method further includes: Calculate the hash value of the data version in the synchronization end offline directory of the synchronization end.
6. The method according to claim 5, characterized in that The step of detecting whether the data version published by the publishing end is consistent with the data version in the offline directories of all synchronization ends to determine the detection result includes: Determine whether the hash value of the data version in the offline directory of the synchronization end in the online information node is the same as the hash value of the data version published by the publishing end; If they are the same, then the test results are determined to be consistent; If they are not the same, the detection result is determined to be inconsistent.
7. The method according to claim 4, characterized in that Also includes: When the publishing end receives the instruction to publish the data version, the publishing end writes the memory data of the publishing end to the disk.
8. A data synchronization system based on distributed application coordination service, characterized in that: include: Distributed application coordination service, used to create information nodes, including version information nodes, consistency information nodes and online information nodes; A data node, used to register and monitor the information node, the data node includes a publishing end and a synchronization end; A publishing end, used to publish a data version, and record the data version published by the publishing end into the version information node; The synchronization end is used to pull the data version published by the publishing end to the synchronization end offline directory of the synchronization end when the synchronization end monitors the data change on the version information node, and record the data version in the synchronization end offline directory to the online information node; The publishing end is also used to detect whether the data version published by the publishing end is consistent with the data version in the offline directory of all synchronization ends when the publishing end monitors the change of the online information nodes corresponding to all synchronization ends, so as to determine the detection result; and record the detection result to the consistency information node; The synchronization end is also used to switch the data version in the offline directory of the synchronization end and the data version in the online directory of the synchronization end if the synchronization end monitors that the consistency information node has changed and the detection result in the consistency information node is consistent.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the data synchronization method based on distributed application coordination service described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data synchronization method based on a distributed application coordination service described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Distributed service change configuration processing method and device, electronic equipment and program product
CN121711246A