Data synchronization method and system, terminal equipment and cloud server

By uniformly managing cloud synchronization and near-end synchronization in the device cluster, terminal devices send messages to cloud servers and other devices when in the leader state, solving the problem of electronic devices repeatedly receiving the same synchronized data, improving synchronization efficiency and stability.

CN120455471APending Publication Date: 2025-08-08HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410178222.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-08
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

The existing cloud synchronization and near-end synchronization mechanisms are independent, resulting in electronic devices that may repeatedly receive the same synchronization data, affecting synchronization efficiency.

Method used

In the device cluster, the terminal device sends synchronization messages to the cloud server and other devices when it is in the leader state, and sends messages to the cluster leader when it is in the non-leader state, so that the unified management of cloud synchronization and near-end synchronization can be achieved through the leader.

Benefits of technology

Reduce data duplicate reception, improve data synchronization efficiency, and maintain stable communication quality between device clusters and cloud servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120455471A_ABST
    Figure CN120455471A_ABST
Patent Text Reader

Abstract

The invention provides a data synchronization method and system, terminal equipment and a cloud server, and relates to the technical field of data synchronization, and the method is applied to a system comprising the cloud server and a plurality of terminal equipment. The method comprises the following steps: in response to a first operation for changing first data, the terminal equipment sends a first message for synchronously changing the first data to a cloud server and other terminal equipment in an equipment cluster under the condition that the terminal equipment is in the equipment cluster and is in a leader state; and under the condition that the terminal equipment is not in the leader state, sending a first message to the terminal equipment in the leader state in the equipment cluster. The cloud server performs data synchronization according to the received first message and then sends the first message to the target terminal device in the leader state in the other device clusters, and the target terminal device is associated with the terminal device sending the first message. According to the technical scheme provided by the invention, the synchronization efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of data synchronization technology, and in particular to a data synchronization method, system, terminal device, and cloud server. Background Art

[0002] With the continuous development of Internet technology, data synchronization between different electronic devices is becoming more and more common. Data synchronization between electronic devices is usually achieved through two methods: cloud synchronization and local synchronization.

[0003] However, cloud synchronization and local synchronization are two independent synchronization mechanisms. This means that for the same synchronization data, an electronic device may receive the synchronization data through both cloud synchronization and local synchronization, resulting in repeated reception of synchronization data and affecting synchronization efficiency. Summary of the Invention

[0004] In view of this, the present specification provides a data synchronization method, system, terminal device and cloud server to reduce the situation where electronic devices repeatedly receive the same synchronization data during the data synchronization process, thereby improving synchronization efficiency.

[0005] To achieve the above objectives, in a first aspect, embodiments of this specification provide a data synchronization method, applied to a terminal device, the method comprising:

[0006] In response to a first operation, when the terminal device is in a device cluster and the terminal device is in a leader state, a first message is sent to a cloud server and other terminal devices in the device cluster; the first operation is used to change first data, and the first message is used to synchronously change the first data;

[0007] When the terminal device is not in the leader state, the first message is sent to the terminal device in the device cluster that is in the leader state.

[0008] The data synchronization method provided in the embodiments of this specification is that the terminal device responds to the first operation of changing the first data, and when it is the leader in the device cluster, sends a first message to the cloud server and other terminal devices in the device cluster; when it is in the device cluster but not the leader, it sends the first message to the leader in the device cluster. In this way, when data synchronization is performed, when the shared data of any terminal device in the same device cluster changes, the first message can be forwarded to other terminal devices through the leader to perform data synchronization within the device cluster (i.e., near-end synchronization); and both can communicate with the cloud server through the leader, and the leader sends a synchronization message to the cloud server (i.e., cloud synchronization). Correspondingly, the cloud server can forward the first message to the leaders in other device clusters, and realize near-end synchronization of other device clusters through the leaders in other device clusters. Therefore, during a data synchronization process, the synchronization message received by the terminal device is based on one of the cloud synchronization and near-end synchronization methods, thereby reducing the situation of repeated data reception and improving data synchronization efficiency.

[0009] In a possible implementation of the first aspect, the method further includes:

[0010] In response to the first operation, when the terminal device is not in the device cluster, the first message is sent to the cloud server.

[0011] Through the above method, terminal devices that are not in the device cluster can also synchronize data with the cloud server, thereby expanding the application scenarios of this solution.

[0012] In a possible implementation of the first aspect, the method further includes:

[0013] receiving a second message sent by a first terminal device in the device cluster;

[0014] performing data synchronization according to the second message;

[0015] When the terminal device is in the leader state, the second message is sent to the cloud server and other terminal devices in the device cluster.

[0016] Through the above method, data synchronization is performed between the leader and non-leader in the device cluster, and data synchronization is performed between the leader and the cloud, thereby realizing data synchronization between each terminal device in the device cluster, and data synchronization from the device cluster to the cloud server.

[0017] In a possible implementation of the first aspect, the method further includes:

[0018] In a case where the terminal device is not in the leader state, if data synchronization is completed, a synchronization completion message is returned to the first terminal device.

[0019] Through the above manner, the leader in the device cluster can perceive the data synchronization status of other terminal devices in the device cluster, so that the leader in the device cluster can synchronize data with other terminal devices.

[0020] In a possible implementation of the first aspect, the method further includes:

[0021] receiving a third message sent by the cloud server;

[0022] Performing data synchronization according to the third message;

[0023] In the case that the terminal device is in a device cluster, if the terminal device is in a leader state, the third message is sent to other terminal devices in the device cluster.

[0024] Through the above method, the cloud server synchronizes data with the leader in the device cluster, and the leader synchronizes data with other terminal devices in the device cluster, thereby realizing data synchronization from the cloud server to each terminal device in the device cluster.

[0025] In a possible implementation of the first aspect, the method further includes:

[0026] If the device cluster where the terminal device is located changes, and the terminal device is in the leader state in the changed device cluster, a device cluster change message is sent to the cloud server, where the device cluster change message is used to indicate the change of the device cluster.

[0027] Through the above method, the cloud server can timely perceive the changes in each device cluster, so as to make corresponding adjustments when synchronizing data to the terminal devices in each device cluster.

[0028] In a possible implementation manner of the first aspect, the change in the device cluster includes at least one of the following:

[0029] A terminal device in the leader state in the device cluster changes;

[0030] Adding a new terminal device to the device cluster;

[0031] A terminal device in the device cluster is removed.

[0032] Through the above method, the cloud server can perceive the change of the leader in the device cluster, as well as the addition and removal of terminal devices in the device cluster, so as to make corresponding adjustments when synchronizing data with the leader in the device cluster.

[0033] In a possible implementation of the first aspect, when a terminal device in a leader state in the device cluster changes, the device cluster change message includes: an identifier of the device cluster and an identifier of the terminal device.

[0034] Through the above method, when the leader in the device cluster changes, the cloud server can determine the new leader in the device cluster, so as to facilitate subsequent data synchronization with the new leader in the device cluster.

[0035] In a possible implementation of the first aspect, when a terminal device is newly added to the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the newly added terminal device.

[0036] Through the above method, when a new terminal device is added to the device cluster, the cloud server can determine the new terminal device in the device cluster. In this way, when performing data synchronization subsequently, the cloud server only needs to synchronize data with the leader in the device cluster, and no longer needs to synchronize data with the new terminal device separately, thereby reducing the communication overhead of the cloud server.

[0037] In a possible implementation of the first aspect, when a terminal device is removed from the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the removed terminal device.

[0038] Through the above method, when a terminal device is removed from a device cluster due to being far away from other terminal devices in the device cluster, the cloud server can perceive the change, so that when performing subsequent data synchronization, it can send synchronization data to the removed terminal device separately, thereby improving the stability of data synchronization.

[0039] In a possible implementation of the first aspect, the communication quality between the terminal device in the leader state in the device cluster and the cloud server is higher than a first threshold.

[0040] Through the above method, the leader in the device cluster can always maintain a high communication quality with the cloud server, which can improve the stability of data synchronization between the cloud server and each terminal device in the device cluster.

[0041] In a possible implementation of the first aspect, the communication quality between the terminal device in the leader state in the device cluster and the cloud server is the highest.

[0042] Through the above method, the communication quality between the terminal device in the leader state and the cloud server can be maximized, thereby further improving the stability of data synchronization between the cloud server and each terminal device in the device cluster.

[0043] In a possible implementation of the first aspect, the first data includes at least one of schedule data, memo data, and note data.

[0044] Through the above method, the present solution can support data synchronization of schedule data, memo data and note data, thereby expanding the application scenarios of the present solution.

[0045] In a possible implementation of the first aspect, the first operation includes at least one of adding the first data, modifying the first data, deleting the first data, and adjusting a position of the first data.

[0046] Through the above-mentioned manner, the present solution can support the addition, modification, deletion and position adjustment of the first data, thereby expanding the application scenarios of the present solution.

[0047] In a second aspect, an embodiment of this specification provides a data synchronization device, applied to a terminal device, the device comprising:

[0048] Sending module: used to respond to a first operation, when the terminal device is in a device cluster, if the terminal device is in a leader state, send a first message to the cloud server and other terminal devices in the device cluster; the first operation is used to change the first data, and the first message is used to synchronously change the first data; when the terminal device is not in a leader state, send the first message to the terminal device in the device cluster that is in a leader state.

[0049] In a possible implementation of the second aspect, the sending module is further configured to:

[0050] In response to the first operation, when the terminal device is not in the device cluster, the first message is sent to the cloud server.

[0051] In a possible implementation of the second aspect, the device further includes:

[0052] Receiving module: configured to receive a second message sent by a first terminal device in the device cluster;

[0053] Data synchronization module: configured to perform data synchronization according to the second message received by the receiving module;

[0054] The sending module is further configured to: when the terminal device is in a leader state, send the second message to the cloud server and other terminal devices in the device cluster.

[0055] In a possible implementation of the second aspect, the sending module is further configured to:

[0056] In a case where the terminal device is not in the leader state, if data synchronization is completed, a synchronization completion message is returned to the first terminal device.

[0057] In a possible implementation manner of the second aspect, the receiving module is further configured to:

[0058] receiving a third message sent by the cloud server;

[0059] The data synchronization module is further configured to: perform data synchronization according to the third message received by the receiving module;

[0060] The sending module is further configured to: when the terminal device is in a device cluster, if the terminal device is in a leader state, send the third message to other terminal devices in the device cluster.

[0061] In a possible implementation of the second aspect, the sending module is further configured to:

[0062] If the device cluster where the terminal device is located changes, and the terminal device is in the leader state in the changed device cluster, a device cluster change message is sent to the cloud server, where the device cluster change message is used to indicate the change of the device cluster.

[0063] In a possible implementation manner of the second aspect, the change in the device cluster includes at least one of the following:

[0064] A terminal device in the leader state in the device cluster changes;

[0065] Adding a new terminal device to the device cluster;

[0066] A terminal device in the device cluster is removed.

[0067] In a possible implementation of the second aspect, when a terminal device in a leader state in the device cluster changes, the device cluster change message includes: an identifier of the device cluster and an identifier of the terminal device.

[0068] In a possible implementation of the second aspect, when a terminal device is newly added to the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the newly added terminal device.

[0069] In a possible implementation of the second aspect, when a terminal device is removed from the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the removed terminal device.

[0070] In a possible implementation of the second aspect, the communication quality between the terminal device in the leader state in the device cluster and the cloud server is higher than a first threshold.

[0071] In a possible implementation of the second aspect, the communication quality between the terminal device in the leader state in the device cluster and the cloud server is the highest.

[0072] In a possible implementation of the second aspect, the first data includes at least one of schedule data, memo data, and note data.

[0073] In a possible implementation of the second aspect, the first operation includes at least one of adding the first data, modifying the first data, deleting the first data, and adjusting the position of the first data.

[0074] In a third aspect, an embodiment of this specification provides a data synchronization method, applied to a cloud server, comprising:

[0075] receiving a first message sent by a first terminal device;

[0076] performing data synchronization according to the first message;

[0077] For each target terminal device associated with the first terminal device, when the target terminal device and the first terminal device are located in different device clusters, if the target terminal device is in a leader state, the first message is sent to the target terminal device.

[0078] In a possible implementation manner of the third aspect, the method further includes:

[0079] For each target terminal device associated with the first terminal device, if the target terminal device is not in a device cluster, the first message is sent to the target terminal device.

[0080] Through the above method, the cloud server can also synchronize data with terminal devices that are not in the device cluster, thereby expanding the application scenarios of this solution.

[0081] In a possible implementation manner of the third aspect, the method further includes:

[0082] Receive a device cluster change message sent by the second terminal device, where the device cluster change message is used to indicate a change in the target device cluster;

[0083] According to the device cluster change message, corresponding device cluster information is updated.

[0084] Through the above method, the cloud server can timely perceive the changes in each device cluster, so as to make corresponding adjustments when synchronizing data to the terminal devices in each device cluster.

[0085] In a possible implementation of the third aspect, the device cluster change message includes an identifier of the target device cluster and an identifier of the second terminal device, and updating corresponding device cluster information according to the device cluster change message includes:

[0086] The identifier of the terminal device in the leader state in the device cluster information corresponding to the identifier of the target device cluster is updated to the identifier of the second terminal device.

[0087] Through the above method, the cloud server can update the information of the leader in the device cluster, so as to facilitate subsequent data synchronization with the new leader in the device cluster.

[0088] In a possible implementation of the third aspect, the device cluster change message includes an identifier of the target device cluster and an identifier of a third terminal device added to the target device cluster, and updating corresponding device cluster information according to the device cluster change message includes:

[0089] The identifier of the third terminal device is added to the device cluster information corresponding to the identifier of the target device cluster.

[0090] Through the above method, the cloud server can add the identifier of the third terminal device to the device cluster information. In this way, when performing data synchronization subsequently, the cloud server only needs to synchronize data with the leader in the device cluster, and no longer needs to synchronize data with the newly added terminal device separately, thereby reducing the communication overhead of the cloud server.

[0091] In a possible implementation of the third aspect, the device cluster change message includes an identifier of the target device cluster and an identifier of the fourth terminal device removed from the target device cluster, and updating corresponding device cluster information according to the device cluster change message includes:

[0092] The identifier of the fourth terminal device is removed from the device cluster information corresponding to the identifier of the target device cluster.

[0093] Through the above method, when a terminal device is removed from a device cluster due to being far away from other terminal devices in the device cluster, the cloud server can perceive the change, so that when performing subsequent data synchronization, it can send synchronization data to the removed terminal device separately, thereby improving the stability of data synchronization.

[0094] In a possible implementation of the third aspect, the communication quality between the terminal device in the leader state in each device cluster and the cloud server is higher than a first threshold.

[0095] Through the above method, the leader in the device cluster can always maintain a high communication quality with the cloud server, which can improve the stability of data synchronization between the cloud server and each terminal device in the device cluster.

[0096] In a possible implementation of the third aspect, the communication quality between the terminal device in the leader state in each device cluster and the cloud server is the highest.

[0097] Through the above method, the terminal device with the highest communication quality with the cloud server in the device cluster can synchronize data with the cloud server, thereby further improving the stability of data synchronization between the cloud server and each terminal device in the device cluster.

[0098] In a fourth aspect, an embodiment of this specification provides a data synchronization device, which is applied to a cloud server, and the device includes:

[0099] Receiving module: used for receiving a first message sent by a first terminal device;

[0100] Data synchronization module: used for performing data synchronization according to the first message;

[0101] A sending module: for each target terminal device associated with the first terminal device, when the target terminal device and the first terminal device are located in different device clusters, if the target terminal device is in a leader state, sending the first message to the target terminal device.

[0102] In a possible implementation manner of the fourth aspect, the sending module is further configured to:

[0103] For each target terminal device associated with the first terminal device, if the target terminal device is not in a device cluster, the first message is sent to the target terminal device.

[0104] In a possible implementation manner of the fourth aspect, the receiving module is further configured to:

[0105] Receive a device cluster change message sent by the second terminal device, where the device cluster change message is used to indicate a change in the target device cluster;

[0106] The data synchronization module is further configured to update corresponding device cluster information according to the device cluster change message.

[0107] In a possible implementation manner of the fourth aspect, the device cluster change message includes an identifier of the target device cluster and an identifier of the second terminal device, and the data synchronization module is specifically configured to:

[0108] The identifier of the terminal device in the leader state in the device cluster information corresponding to the identifier of the target device cluster is updated to the identifier of the second terminal device.

[0109] In a possible implementation of the fourth aspect, the device cluster change message includes an identifier of the target device cluster and an identifier of a third terminal device added to the target device cluster, and the data synchronization module is specifically configured to:

[0110] The identifier of the third terminal device is added to the device cluster information corresponding to the identifier of the target device cluster.

[0111] In a possible implementation manner of the fourth aspect, the device cluster change message includes an identifier of the target device cluster and an identifier of a fourth terminal device removed from the target device cluster, and the data synchronization module is specifically configured to:

[0112] The identifier of the fourth terminal device is removed from the device cluster information corresponding to the identifier of the target device cluster.

[0113] In a possible implementation of the fourth aspect, the communication quality between the terminal device in the leader state in each device cluster and the cloud server is higher than a first threshold.

[0114] In a possible implementation of the fourth aspect, the communication quality between the terminal device in the leader state in each device cluster and the cloud server is the highest.

[0115] In a fifth aspect, an embodiment of this specification provides a terminal device, comprising: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the method described in any embodiment of the first aspect above when calling the computer program.

[0116] In a sixth aspect, an embodiment of this specification provides a cloud server comprising: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the method described in any embodiment of the third aspect above when calling the computer program.

[0117] In a seventh aspect, an embodiment of this specification provides a data synchronization system, comprising: a cloud server as described in the sixth aspect above and multiple terminal devices as described in the fifth aspect above.

[0118] In an eighth aspect, an embodiment of this specification provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any one of the embodiments of the first or third aspect above.

[0119] In a ninth aspect, an embodiment of this specification provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute the method described in any one of the first or third aspects above.

[0120] In a tenth aspect, embodiments of this specification provide a chip system, comprising a processor coupled to a memory, the processor executing a computer program stored in the memory to implement the method described in any one of the first or third aspects above. The chip system may be a single chip or a chip module consisting of multiple chips.

[0121] It can be understood that the beneficial effects of the second aspect and the fourth to tenth aspects can be found in the relevant description of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0122] Figure 1 A schematic diagram of a data synchronization system provided in an embodiment of this specification;

[0123] Figure 2 A flowchart of a data synchronization method provided in an embodiment of this specification;

[0124] Figure 3 A flowchart of another data synchronization method provided in an embodiment of this specification;

[0125] Figure 4 A flowchart of another data synchronization method provided in an embodiment of this specification;

[0126] Figure 5 A schematic diagram of the structure of a data synchronization device provided in an embodiment of this specification;

[0127] Figure 6A schematic diagram of the structure of another data synchronization device provided in an embodiment of this specification;

[0128] Figure 7 A schematic diagram of the structure of a terminal device provided in an embodiment of this specification;

[0129] Figure 8 This is a schematic diagram of the structure of the cloud server provided in the embodiments of this specification. DETAILED DESCRIPTION

[0130] The following describes the embodiments of this specification in conjunction with the accompanying drawings. The terms used in the implementation methods of the embodiments of this specification are only used to explain the specific embodiments of this specification and are not intended to limit this specification. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0131] Data synchronization can include two methods: cloud synchronization and local synchronization. With the development of technology, more and more electronic devices (such as mobile phones, computers, etc.) can support both cloud synchronization and local synchronization.

[0132] However, cloud synchronization and near-end synchronization are usually two independent synchronization mechanisms, which means that for the same synchronization data, an electronic device may receive the synchronization data through both cloud synchronization and near-end synchronization. For example, an electronic device first receives the synchronization data through near-end synchronization and performs data synchronization based on the synchronization data, and then receives the same synchronization data through cloud synchronization. In this case, the electronic device can perform data synchronization again based on the synchronization data received through cloud synchronization. To avoid repeated data synchronization, another method is that the electronic device first determines whether the synchronization data received for the second time is the same as the synchronization data received for the first time. If they are the same, data synchronization is no longer performed. Although this method can avoid repeated synchronization of the same data, it requires comparison of the synchronization data received twice, which will also affect the synchronization efficiency. In addition, repeated reception of the same synchronization data by the electronic device will itself affect the synchronization efficiency.

[0133] To this end, this specification provides a data synchronization method to reduce the situation where an electronic device repeatedly receives the same synchronization number during the data synchronization process, thereby improving synchronization efficiency.

[0134] The data synchronization method provided in the embodiments of this specification can be applied to a data synchronization system, which may include a cloud server and multiple terminal devices. Figure 1As shown, the data synchronization system may include a cloud server and terminal devices 1 to 6, wherein terminal devices 1 to 3 belong to device cluster 1, terminal devices 4 and 5 belong to device cluster 2, and terminal device 6 is not in the device cluster.

[0135] Devices in a cluster can synchronize shared data (also known as near-end synchronization) using a distributed consensus (raft) algorithm via near-field communication (NFC) (e.g., Bluetooth, Wi-Fi, etc.). Each device in a cluster can belong to the same user. Each device in a cluster can be in a leader, follower, or candidate state.

[0136] The terminal device in the leader state is responsible for processing at least one of the operations of creating, modifying, deleting or repositioning the synchronized data, and is responsible for synchronizing data with the cloud server and the terminal devices in the follower state in the device cluster. For example, Figure 1 In device cluster 1, terminal device 2 is in the leader state, terminal device 1 and terminal device 3 are in the follower state, and in device cluster 2, terminal device 4 is in the leader state, and terminal device 5 is in the follower state.

[0137] Follower state devices receive and process synchronization messages from leader state devices, and check at fixed heartbeat intervals to see if leader state devices have sent heartbeat messages. If waiting for a heartbeat message from a leader state device times out or if no heartbeat message is received, the device transitions from follower state to candidate state and initiates its own leader election. Different follower state devices can use different fixed heartbeat intervals.

[0138] A terminal device in the candidate state is used to send a voting request to other terminal devices to notify other terminal devices to vote for it. After receiving more than half of the votes, the terminal device in the candidate state can change from the candidate state to the leader state.

[0139] In some embodiments, other terminal devices will vote for the candidate only when the communication quality between the candidate and the cloud server is higher than a first threshold. In this way, the communication quality between the elected leader and the cloud server will also be higher than the first threshold, so that the leader in the device cluster can maintain a high communication quality with the cloud server, which can improve the stability of data synchronization between the cloud server and each terminal device in the device cluster.

[0140] The first threshold may be determined according to the average communication quality between each terminal device in the device cluster and the cloud server.

[0141] In some embodiments, other terminal devices will vote for the candidate only when the candidate is the terminal device with the highest communication quality between the device cluster and the cloud server. In this way, in the device cluster, the communication quality between the terminal device in the leader state and the cloud server is the highest, which can further improve the stability of data synchronization between the cloud server and each terminal device in the device cluster.

[0142] The data synchronization system provided in the embodiments of this specification may also include one or more device clusters, and each device cluster may include more terminal devices. This embodiment of this specification does not specifically limit this.

[0143] Terminal devices may include but are not limited to personal computers (PCs), smart phones, smart watches, netbooks, tablet computers, PDAs, smart TVs, smart screens, etc. This specification does not impose any restrictions on the specific types of terminal devices.

[0144] When the shared data on any terminal device in the data synchronization system changes, the terminal device can first detect whether it is in the device cluster. If not, it can directly send a synchronization message to the cloud server. If it is in the device cluster, it can further detect whether it is in the leader state. If so, it can send a synchronization message to the terminal devices in the follower state in the device cluster and the cloud server. If not, it is in the follower state, and it can send a synchronization message to the terminal devices in the leader state in the device cluster. After receiving the synchronization message, the terminal device in the leader state can send a synchronization message to the terminal devices in the follower state in the device cluster and the cloud server to synchronize data.

[0145] After receiving the synchronization message, the cloud server can first synchronize data, and then determine the terminal devices associated with the terminal device that sends the synchronization message. For each associated terminal device, the cloud server can first detect whether the terminal device is in other device clusters. If not, a synchronization message can be sent to the terminal device. If so, a synchronization message can be sent to the terminal device if the terminal device is the leader.

[0146] When any terminal device receives a synchronization message sent by the cloud server, it can first synchronize data, and when it is in the leader state, it can send a synchronization message to the terminal devices in the follower state in the device cluster to which it belongs. The terminal devices in the follower state in the device cluster to which it belongs will then synchronize data according to the received synchronization message, thereby completing the data synchronization of the entire data synchronization system.

[0147] The following describes three methods for implementing data synchronization.

[0148] The first is that the shared data on the terminal device in the leader state in the device cluster changes.

[0149] For example, Figure 1 In the data synchronization system shown in FIG. 1 , shared data on the terminal device 2 in the device cluster 1 is changed. In the system, a method for implementing data synchronization may include: Figure 2 The following steps are shown:

[0150] S1101. Terminal device 2 detects a first operation and sends message 1 to terminal device 1, terminal device 3 and the cloud server.

[0151] The first operation may be used to change first data that can be shared with other terminal devices, such as schedule data, memo data, and note data. The first operation may include adding first data, modifying first data, deleting first data, and adjusting the position of first data.

[0152] When the terminal device 2 detects the first operation on the first data, it can first detect whether it is in the device cluster by querying the device cluster identifier. The device cluster identifier can be the ID, name, etc. of the device cluster where the terminal device 2 is located.

[0153] When terminal device 2 detects that it belongs to device cluster 1, it can further detect whether it is in the leader state. Terminal device 2 can store the device identifier (such as device ID, device SN, etc.) of each terminal device in device cluster 1, as well as the status of each terminal device (including leader state, follower state, and candidate state). Terminal device 2 can determine whether it is in the leader state by querying its own status.

[0154] When terminal device 2 is in the leader state, terminal device 2 can first modify the corresponding first data in the database, and then send message 1 to the cloud server and terminal devices in the follower state in device cluster 1 (ie, terminal device 1 and terminal device 3).

[0155] Message 1 may include the changed first data, which may be in the form of a key-value pair, where the key may be an identifier of the first data (such as a name, ID, etc.), and the value may be the value of the changed first data.

[0156] S1102, terminal device 1, terminal device 3 and cloud server respectively receive message 1 and synchronize data.

[0157] After receiving the message 1 sent by the terminal device 2, the terminal device 1, the terminal device 3 and the cloud server can respectively modify the corresponding first data in their own databases according to the changed first data in the message 1 to complete data synchronization.

[0158] S1103 , terminal device 1 and terminal device 3 return a synchronization completion message to terminal device 2 .

[0159] After completing data synchronization, terminal device 1 and terminal device 3 (i.e., the terminal devices in follower state in device cluster 1) can return synchronization completion information to terminal device 2 (i.e., the terminal device in leader state in device cluster 1) so that terminal device 2 can perceive the data synchronization status of terminal device 1 and terminal device 3.

[0160] After completing the data synchronization, the terminal device 1 and the terminal device 3 may also update their own synchronization periods to indicate that the data synchronization in the corresponding terminal devices has been completed.

[0161] S1104. Terminal device 2 receives the synchronization completion message sent by terminal device 1 and terminal device 3, and updates the synchronization period.

[0162] When terminal device 2 receives the synchronization completion message sent by all terminal devices in follower state in device cluster 1 (i.e., terminal device 1 and terminal device 3), it means that all terminal devices in device cluster 1 have completed this data synchronization. At this time, terminal device 2 can update its own synchronization cycle to indicate that device cluster 1 has completed this data synchronization.

[0163] S1105. The cloud server forwards message 1 to terminal device 4 and terminal device 6.

[0164] After completing data synchronization based on message 1 sent by terminal device 2, the cloud server can forward message 1 to the terminal device associated with terminal device 2 and in the leader state in other device clusters (i.e., device terminal 4), as well as the terminal device that is not in any device cluster (i.e., terminal device 6).

[0165] The terminal devices associated with the terminal device 2 may be terminal devices that can share data with the terminal device 2, for example, terminal devices belonging to the same user as the terminal device 2, and terminal devices of other users that the terminal device 2 allows to share data.

[0166] Specifically, the cloud server can first determine the terminal devices associated with terminal device 2 (i.e., terminal device 1 and terminal devices 3 to 6), and then for each terminal device, first detect whether the terminal device is in the device cluster. If it is not in the device cluster, forward message 1 to the terminal device. If it is in the device cluster, further detect whether the terminal device is in the leader state. If it is in the leader state, forward message 1 to the terminal device.

[0167] In other embodiments, the cloud server may also first determine the device cluster (i.e., device cluster 2) associated with the device cluster 1 where the terminal device 2 is located and the terminal device not in the device cluster, and then forward message 1 to the terminal device in the leader state in device cluster 2 and the terminal device not in the device cluster.

[0168] After completing the data synchronization, the cloud server may also update its own synchronization period to indicate that the cloud server has completed the data synchronization.

[0169] S1106, terminal device 4 and terminal device 6 respectively receive message 1 and perform data synchronization.

[0170] After receiving the message 1 sent by the cloud server, the terminal device 4 and the terminal device 6 can respectively modify the corresponding first data in their own databases according to the changed first data in the message 1 to complete data synchronization.

[0171] S1107 , terminal device 4 forwards message 1 to terminal device 5 .

[0172] After completing data synchronization, terminal device 4 may query a terminal device in a follower state (ie, terminal device 5 ) in its device cluster (ie, device cluster 2 ), and then forward message 1 to terminal device 5 .

[0173] S1108. Terminal device 5 receives message 1 and performs data synchronization.

[0174] After receiving the message 1 sent by the terminal device 4, the terminal device 5 can modify the corresponding first data in its own database according to the changed first data in the message 1 to complete data synchronization.

[0175] S1109 , terminal device 5 returns a synchronization completion message to terminal device 4 .

[0176] After completing data synchronization, terminal device 5 (i.e., the terminal device in follower state in device cluster 2) can update its own synchronization cycle to indicate that terminal device 5 has completed this data synchronization, and return synchronization completion information to terminal device 4 (i.e., the terminal device in leader state in device cluster 2) so that terminal device 4 can perceive the data synchronization status of terminal device 5.

[0177] S1110. Terminal device 4 receives the synchronization completion message and updates the synchronization period.

[0178] When terminal device 4 receives the synchronization completion message sent by all terminal devices in follower state in device cluster 2 (i.e., terminal device 5), it means that all terminal devices in device cluster 2 have completed this data synchronization. At this time, terminal device 4 can update its own synchronization cycle to indicate that device cluster 2 has completed this data synchronization.

[0179] The second type is that the shared data on the terminal device in the follower state in the device cluster changes.

[0180] For example, Figure 1 In the data synchronization system shown in FIG, shared data on the terminal device 1 in the device cluster 1 is changed. In the system, a method for implementing data synchronization may include: Figure 3 The following steps are shown:

[0181] S1201. Terminal device 1 detects a second operation and sends message 2 to terminal device 2.

[0182] The second operation may be used to change second data that can be shared with other terminal devices, such as schedule data, memo data, and note data. The second operation may include adding second data, modifying second data, deleting second data, and adjusting the position of second data.

[0183] When terminal device 1 detects the second operation on the second data, it may first detect whether it is in the device cluster. If terminal device 1 detects that it belongs to device cluster 1, it may further detect its own status. If terminal device 1 detects that it is in follower status, terminal device 1 may first modify the corresponding second data in the cache, then query the terminal device in the leader status in device cluster 1 (i.e., terminal device 2), and then send message 2 to terminal device 2.

[0184] Message 2 may include the changed second data. The changed second data may be in the form of a key-value pair, where the key may be an identifier of the second data and the value may be the value of the changed second data.

[0185] S1202. Terminal device 2 receives message 2 and performs data synchronization.

[0186] After receiving the message 2 sent by the terminal device 1, the terminal device 2 can modify the corresponding second data in its own database according to the changed second data in the message 2 to complete data synchronization.

[0187] S1203. Terminal device 2 forwards message 2 to terminal device 1, terminal device 3 and the cloud server.

[0188] When terminal device 2 is in the leader state, terminal device 2 may forward message 2 to the cloud server and terminal devices in the follower state in its device cluster (ie, terminal device 1 and terminal device 3). Message 2 may include the changed second data.

[0189] S1204, terminal device 1, terminal device 3 and cloud server respectively receive message 2 and synchronize data.

[0190] S1205 . Terminal device 1 and terminal device 3 return a synchronization completion message to terminal device 2 .

[0191] S1206. Terminal device 2 receives the synchronization completion messages sent by terminal device 1 and terminal device 3, and updates the synchronization period.

[0192] S1207. The cloud server forwards message 2 to terminal device 4 and terminal device 6.

[0193] S1208, terminal device 4 and terminal device 6 respectively receive message 2 and perform data synchronization.

[0194] S1209. Terminal device 4 forwards message 2 to terminal device 5.

[0195] S1210. Terminal device 5 receives message 2 and performs data synchronization.

[0196] S1211 , terminal device 5 returns a synchronization completion message to terminal device 4 .

[0197] S1212. Terminal device 4 receives the synchronization completion message and updates the synchronization period.

[0198] Steps S1204 to S1212 may refer to the above Figure 2 The description of steps S1102 to S1110 corresponding to the illustrated embodiment will not be repeated here.

[0199] The third type is that shared data on a terminal device outside the device cluster changes.

[0200] For example, Figure 1 In the data synchronization system shown in FIG. 1 , the shared data on the terminal device 6 is changed. In the system, the method for achieving data synchronization may include: Figure 4 The following steps are shown:

[0201] S1301. The terminal device 6 detects the third operation and sends a message 3 to the cloud server.

[0202] The third operation can be used to change third data that can be shared with other terminal devices, such as schedule data, memo data, and note data. The third operation can include adding third data, modifying third data, deleting third data, and adjusting the position of third data.

[0203] When the terminal device 6 detects the third operation on the third data, it can first detect whether it is in the device cluster. When the terminal device 1 detects that it is not in the device cluster, it can first modify the corresponding first data in the database and then send message 3 to the cloud server.

[0204] Message 3 may include the changed third data. The changed third data may be in the form of a key-value pair, where the key may be an identifier of the third data and the value may be the value of the changed third data.

[0205] S1302: The cloud server receives message 3 and performs data synchronization.

[0206] S1303. The cloud server sends message 3 to terminal device 2 and terminal device 4.

[0207] S1304, terminal device 2 and terminal device 4 respectively receive message 3 and perform data synchronization.

[0208] S1305. Terminal device 2 sends message 3 to terminal device 1 and terminal device 3.

[0209] S1306. Terminal device 1 and terminal device 3 respectively receive message 3 and perform data synchronization.

[0210] S1307 . Terminal device 1 and terminal device 3 return a synchronization completion message to terminal device 2 .

[0211] S1308. Terminal device 2 receives the synchronization completion messages sent by terminal device 1 and terminal device 3, and updates the synchronization period.

[0212] S1309. Terminal device 4 sends message 3 to terminal device 5.

[0213] S1310. Terminal device 5 receives message 3 and performs data synchronization.

[0214] S1311 , terminal device 5 returns a synchronization completion message to terminal device 4 .

[0215] S1312. Terminal device 4 receives the synchronization completion message and updates the synchronization period.

[0216] The data synchronization process of the two device clusters corresponding to steps S1302 to S1312 is the same as the above Figure 1The data synchronization process of device cluster 2 is similar. For details, please refer to the above Figure 1 The relevant descriptions in the illustrated embodiments will not be repeated here.

[0217] In some embodiments, when a device cluster changes (such as a change in the leader in the device cluster, addition or deletion of terminal devices in the device cluster, etc.), the terminal device in the leader state in the device cluster can send a device cluster change message to the cloud server, so that the cloud server can promptly perceive the changes in each device cluster, so as to make corresponding adjustments when synchronizing data to the terminal devices in each device cluster.

[0218] In some embodiments, when the communication quality between the leader in the device cluster and the cloud server is lower than or equal to a second threshold (the second threshold is less than or equal to the first threshold), the terminal devices in the device cluster can re-initiate voting to select a terminal device whose communication quality with the cloud server is higher than the first threshold as the new leader.

[0219] When the leader of a device cluster changes, the new leader sends a cluster change message to the cloud server, including the identifier of the device cluster and the identifier of the terminal device corresponding to the new leader. Upon receiving the cluster change message, the cloud server first determines the corresponding device cluster information based on the device cluster identifier in the message. It then updates the leader identifier in the cluster information with the identifier of the terminal device corresponding to the new leader. This allows the cloud server to update the cluster leader information, facilitating subsequent data synchronization with the new leader.

[0220] For example, Figure 1 In the device cluster 1 shown, if the communication quality between terminal device 2 and the cloud server is low, and the leader of device cluster 1 becomes terminal device 1 with higher communication quality with the cloud server, the message sent by terminal device 1 to the cloud server may include the identifier of device cluster 1 and the identifier of terminal device 1. After receiving the message from terminal device 1, the cloud server can determine the corresponding device cluster information from each stored device cluster based on the identifier of device cluster 1, and then modify the leader identifier in the device cluster information to the identifier of terminal device 1.

[0221] When a new terminal device is added to a device cluster, the cluster leader sends a cluster change message to the cloud server, including the device cluster identifier and the identifier of the newly added terminal device. Upon receiving the cluster change message, the cloud server can first determine the corresponding device cluster information based on the cluster identifier in the message, and then add the identifier of the newly added terminal device to that information. This allows the cloud server to synchronize data with the cluster leader during subsequent data synchronization, eliminating the need for the cloud server to synchronize data with the newly added terminal device separately, thus reducing communication overhead for the cloud server.

[0222] For example, Figure 1 In the example, terminal device 7 is added to device cluster 1. The message sent by terminal device 2 to the cloud server may include the identifier of device cluster 1 and the identifier of terminal device 7. Upon receiving the message from terminal device 2, the cloud server can determine the corresponding device cluster information from the stored device clusters based on the identifier of device cluster 1, and then add the identifier of terminal device 7 to the device cluster information.

[0223] In some embodiments, when a new terminal device is added to a device cluster, the new terminal device may first obtain the communication quality between the leader of the device cluster and the cloud server, and initiate a vote to be elected as the new leader if the communication quality between itself and the cloud server is higher than the communication quality between the leader and the cloud server. The new terminal device may then send a device cluster change message to the cloud server, which may include the identifier of the device cluster and the identifier of the new terminal device. After receiving the device cluster change message, the cloud server may first determine the corresponding device cluster information based on the device cluster identifier, then add the identifier of the new terminal device to the device cluster information, and update the identifier corresponding to the leader in the device cluster information to the identifier of the new terminal device.

[0224] In some embodiments, when a terminal device in a device cluster is removed from the device cluster because it is too far away from other terminal devices in the device cluster to communicate closely, the device cluster change message sent by the leader of the device cluster to the cloud server may include: the identifier of the device cluster and the identifier of the removed terminal device. After receiving the device cluster change message, the cloud server may first determine the corresponding device cluster information based on the device cluster identifier, and then delete the identifier of the removed terminal device from the device cluster information. In this way, when a terminal device is removed from the device cluster due to being too far away from other terminal devices in the device cluster, the cloud server can perceive the change, and can therefore send synchronization data to the removed terminal device separately during subsequent data synchronization, thereby improving the stability of data synchronization.

[0225] In some embodiments, if a leader in a device cluster receives conflicting synchronization messages from multiple followers in a synchronization cycle, the leader may process each synchronization message in sequence according to the initiation time of each synchronization message to reduce the impact of synchronization data conflicts.

[0226] Those skilled in the art will appreciate that the above embodiments are exemplary and are not intended to limit this specification. Where possible, the execution order of one or more of the steps above may be adjusted, or may be selectively combined to obtain one or more other embodiments. For example, in some embodiments, step S1103 is performed before step S1105, and step S1104 is performed after step S1105. In some embodiments, step S1103 and step S1104 may both be performed after step S1105. In some embodiments, step S1103 and step S1104 may also both be performed after step S1110. In some embodiments, step S1103 and step S1104 may not be performed. Those skilled in the art may select and combine any of the above steps as needed, and all that do not depart from the essence of the present specification fall within the scope of protection of this specification.

[0227] The data synchronization method provided in the embodiments of this specification is that the terminal device responds to the first operation of changing the first data, and when it is the leader in the device cluster, sends a first message to the cloud server and other terminal devices in the device cluster; when it is in the device cluster but not the leader, it sends the first message to the leader in the device cluster. In this way, when data synchronization is performed, when the shared data of any terminal device in the same device cluster changes, the first message can be forwarded to other terminal devices through the leader to perform data synchronization within the device cluster (i.e., near-end synchronization); and both can communicate with the cloud server through the leader, and the leader sends a synchronization message to the cloud server (i.e., cloud synchronization). Correspondingly, the cloud server can forward the first message to the leaders in other device clusters, and realize near-end synchronization of other device clusters through the leaders in other device clusters. Therefore, during a data synchronization process, the synchronization message received by the terminal device is based on one of the cloud synchronization and near-end synchronization methods, thereby reducing the situation of repeated data reception and improving data synchronization efficiency.

[0228] Based on the same concept, as an implementation of the method executed by the terminal device in the above embodiment, an embodiment of this specification provides a data synchronization device, which is applied to the terminal device. The device embodiment corresponds to the method embodiment executed by the above terminal device. For ease of reading, this device embodiment no longer repeats the details of the method embodiment executed by the above terminal device one by one, but it should be clear that the device in this embodiment can correspond to all the contents of the method embodiment executed by the above terminal device.

[0229] Figure 5 This is a structural diagram of a data synchronization device provided in an embodiment of this specification, such as Figure 5 As shown, the device provided in this embodiment includes:

[0230] Sending module 210: used to respond to a first operation, when the terminal device is in a device cluster, if the terminal device is in a leader state, send a first message to the cloud server and other terminal devices in the device cluster; the first operation is used to change the first data, and the first message is used to synchronously change the first data; when the terminal device is not in a leader state, send the first message to the terminal device in the device cluster that is in a leader state.

[0231] As an optional implementation manner, the sending module 210 is further configured to:

[0232] In response to the first operation, when the terminal device is not in the device cluster, the first message is sent to the cloud server.

[0233] As an optional implementation, the device further includes:

[0234] Receiving module 220: configured to receive a second message sent by a first terminal device in the device cluster;

[0235] Data synchronization module 230: configured to perform data synchronization according to the second message received by the receiving module 220;

[0236] The sending module 210 is further configured to: when the terminal device is in a leader state, send the second message to the cloud server and other terminal devices in the device cluster.

[0237] As an optional implementation manner, the sending module 210 is further configured to:

[0238] In a case where the terminal device is not in the leader state, if data synchronization is completed, a synchronization completion message is returned to the first terminal device.

[0239] As an optional implementation manner, the receiving module 220 is further configured to:

[0240] receiving a third message sent by the cloud server;

[0241] The data synchronization module 230 is further configured to: perform data synchronization according to the third message received by the receiving module 220;

[0242] The sending module 210 is further configured to: when the terminal device is in a device cluster, if the terminal device is in a leader state, send the third message to other terminal devices in the device cluster.

[0243] As an optional implementation manner, the sending module 210 is further configured to:

[0244] If the device cluster where the terminal device is located changes, and the terminal device is in the leader state in the changed device cluster, a device cluster change message is sent to the cloud server, where the device cluster change message is used to indicate the change of the device cluster.

[0245] As an optional implementation manner, the change in the device cluster includes at least one of the following:

[0246] A terminal device in the leader state in the device cluster changes;

[0247] Adding a new terminal device to the device cluster;

[0248] A terminal device in the device cluster is removed.

[0249] As an optional implementation, when a terminal device in a leader state in the device cluster changes, the device cluster change message includes: an identifier of the device cluster and an identifier of the terminal device.

[0250] As an optional implementation manner, when a terminal device is newly added to the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the newly added terminal device.

[0251] As an optional implementation, when a terminal device is removed from the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the removed terminal device.

[0252] As an optional implementation manner, the communication quality between the terminal device in the leader state in the device cluster and the cloud server is higher than a first threshold.

[0253] As an optional implementation, the communication quality between the terminal device in the leader state in the device cluster and the cloud server is the highest.

[0254] As an optional implementation manner, the first data includes at least one of schedule data, memo data and note data.

[0255] As an optional implementation manner, the first operation includes at least one of adding the first data, modifying the first data, deleting the first data, and adjusting the position of the first data.

[0256] The device provided in this embodiment can execute the method executed by the terminal device in the above method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0257] Based on the same concept, as an implementation of the method executed by the cloud server in the above embodiment, an embodiment of this specification provides a data synchronization device, which is applied to the cloud server. The embodiment of this device corresponds to the embodiment of the method executed by the aforementioned cloud server. For ease of reading, this embodiment of the device will no longer repeat the details of the embodiment of the method executed by the aforementioned cloud server one by one, but it should be clear that the device in this embodiment can correspond to and implement all the contents of the embodiment of the method executed by the aforementioned cloud server.

[0258] Figure 6 This is a structural diagram of another data synchronization device provided in an embodiment of this specification, such as Figure 6 As shown, the device provided in this embodiment includes:

[0259] Receiving module 310: configured to receive a first message sent by a first terminal device;

[0260] Data synchronization module 320: configured to perform data synchronization according to the first message;

[0261] Sending module 330: for each target terminal device associated with the first terminal device, when the target terminal device and the first terminal device are located in different device clusters, if the target terminal device is in a leader state, sending the first message to the target terminal device.

[0262] As an optional implementation manner, the sending module 330 is further configured to:

[0263] For each target terminal device associated with the first terminal device, if the target terminal device is not in a device cluster, the first message is sent to the target terminal device.

[0264] As an optional implementation manner, the receiving module 310 is further configured to:

[0265] Receive a device cluster change message sent by the second terminal device, where the device cluster change message is used to indicate a change in the target device cluster;

[0266] The data synchronization module 320 is further configured to update corresponding device cluster information according to the device cluster change message.

[0267] As an optional implementation manner, the device cluster change message includes the identifier of the target device cluster and the identifier of the second terminal device, and the data synchronization module 320 is specifically configured to:

[0268] The identifier of the terminal device in the leader state in the device cluster information corresponding to the identifier of the target device cluster is updated to the identifier of the second terminal device.

[0269] As an optional implementation manner, the device cluster change message includes the identifier of the target device cluster and the identifier of the third terminal device added to the target device cluster. The data synchronization module 320 is specifically configured to:

[0270] The identifier of the third terminal device is added to the device cluster information corresponding to the identifier of the target device cluster.

[0271] As an optional implementation manner, the device cluster change message includes the identifier of the target device cluster and the identifier of the fourth terminal device removed from the target device cluster, and the data synchronization module 320 is specifically configured to:

[0272] The identifier of the fourth terminal device is removed from the device cluster information corresponding to the identifier of the target device cluster.

[0273] As an optional implementation manner, the communication quality between the terminal device in the leader state in each device cluster and the cloud server is higher than a first threshold.

[0274] As an optional implementation, the communication quality between the terminal device in the leader state in each device cluster and the cloud server is the highest.

[0275] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0276] Based on the same concept, the embodiment of this specification also provides a terminal device, Figure 7 This is a schematic diagram of the structure of the terminal device provided in the embodiment of this specification, such as Figure 7 As shown, the terminal device provided in the embodiment of the present application may include: a memory 410 and a processor 420, the memory 410 is used to store computer programs; the processor 420 is used to implement the method executed by the terminal device in the above method embodiment when calling the computer program.

[0277] The terminal device provided in this embodiment can execute the method executed by the terminal device in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.

[0278] Based on the same concept, this specification also provides a cloud server. Figure 8 This is a schematic diagram of the structure of the cloud server provided in the embodiment of this specification, such as Figure 8 As shown, the cloud server provided in the embodiment of the present application may include: a memory 410 and a processor 420, the memory 510 is used to store computer programs; the processor 520 is used to implement the method executed by the cloud server in the above method embodiment when calling the computer program.

[0279] The cloud server provided in this embodiment can execute the method executed by the cloud server in the above method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0280] The embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in the above method embodiments is implemented.

[0281] The embodiments of this specification also provide a computer program product. When the computer program product is run on an electronic device, the electronic device implements the method described in the above method embodiments.

[0282] The present invention also provides a chip system, including a processor coupled to a memory, and executing a computer program stored in the memory to implement the method described in the above method embodiment. The chip system can be a single chip or a chip module composed of multiple chips.

[0283] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this specification are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted via the computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, hard disk, or tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0284] Those skilled in the art will appreciate that all or part of the process steps in the above-described method embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program can include the process steps in the above-described method embodiments. The aforementioned storage medium can include various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

[0285] The naming or numbering of steps in this specification does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The execution order of the named or numbered process steps can be changed according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved.

[0286] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0287] In the embodiments provided in this specification, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0288] It should be understood that in the description of this application and the appended claims, the terms "comprises," "includes," "has," and any variations thereof are intended to cover non-exclusive inclusions and mean "including but not limited to," unless otherwise specifically emphasized. For example, a process, method, system, product, or apparatus that includes a series of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to the process, method, product, or apparatus.

[0289] In the description of this specification, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship, for example, A / B can represent A or B; "and / or" in this specification is used to describe the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural.

[0290] Furthermore, in this specification, unless otherwise specified, "plurality" refers to two or more than two. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, "at least one of a, b, or c" can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or plural.

[0291] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0292] In addition, in the description of this application specification and the appended claims, the terms "first," "second," etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or precedence, nor should they be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein; and features specified as "first" or "second" may explicitly or implicitly include at least one of such features.

[0293] In the embodiments of this specification, words such as "exemplarily" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of this specification should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.

[0294] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in one or more embodiments of the specification. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized.

[0295] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this specification, rather than to limit them. Although this specification has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this specification.

Claims

1. A data synchronization method, applied to a terminal device, characterized in that: include: In response to a first operation, when the terminal device is in a device cluster and the terminal device is in a leader state, a first message is sent to a cloud server and other terminal devices in the device cluster; the first operation is used to change first data, and the first message is used to synchronously change the first data; When the terminal device is not in the leader state, the first message is sent to the terminal device in the device cluster that is in the leader state.

2. The method according to claim 1, characterized in that The method further comprises: In response to the first operation, when the terminal device is not in the device cluster, the first message is sent to the cloud server.

3. The method according to claim 1 or 2, characterized in that The method further comprises: receiving a second message sent by a first terminal device in the device cluster; performing data synchronization according to the second message; When the terminal device is in the leader state, the second message is sent to the cloud server and other terminal devices in the device cluster.

4. The method according to claim 3, characterized in that The method further comprises: In a case where the terminal device is not in the leader state, if data synchronization is completed, a synchronization completion message is returned to the first terminal device.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: receiving a third message sent by the cloud server; Performing data synchronization according to the third message; In the case that the terminal device is in a device cluster, if the terminal device is in a leader state, the third message is sent to other terminal devices in the device cluster.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: If the device cluster where the terminal device is located changes, and the terminal device is in the leader state in the changed device cluster, a device cluster change message is sent to the cloud server, where the device cluster change message is used to indicate the change of the device cluster.

7. The method according to claim 6, characterized in that The change in the device cluster includes at least one of the following: A terminal device in the leader state in the device cluster changes; Adding a new terminal device to the device cluster; A terminal device in the device cluster is removed.

8. The method according to claim 7, characterized in that In the case where a terminal device in a leader state in the device cluster changes, the device cluster change message includes: an identifier of the device cluster and an identifier of the terminal device.

9. The method according to claim 7 or 8, characterized in that In the case where a new terminal device is added to the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the newly added terminal device.

10. The method according to any one of claims 7 to 9, characterized in that: In the case where a terminal device is removed from the device cluster, the device cluster change message includes: an identifier of the device cluster and an identifier of the removed terminal device.

11. The method according to any one of claims 1 to 10, characterized in that The communication quality between the terminal device in the leader state in the device cluster and the cloud server is higher than a first threshold.

12. The method according to any one of claims 1 to 11, characterized in that The communication quality between the terminal device in the leader state in the device cluster and the cloud server is the highest.

13. The method according to any one of claims 1 to 12, characterized in that The first data includes at least one of schedule data, memo data, and note data.

14. The method according to any one of claims 1 to 13, characterized in that The first operation includes at least one of adding the first data, modifying the first data, deleting the first data, and adjusting a position of the first data.

15. A data synchronization method, applied to a cloud server, characterized in that: include: receiving a first message sent by a first terminal device; performing data synchronization according to the first message; For each target terminal device associated with the first terminal device, when the target terminal device and the first terminal device are located in different device clusters, if the target terminal device is in a leader state, the first message is sent to the target terminal device.

16. The method according to claim 15, characterized in that The method further comprises: For each target terminal device associated with the first terminal device, if the target terminal device is not in a device cluster, the first message is sent to the target terminal device.

17. The method according to claim 15 or 16, characterized in that The method further comprises: Receive a device cluster change message sent by the second terminal device, where the device cluster change message is used to indicate a change in the target device cluster; According to the device cluster change message, corresponding device cluster information is updated.

18. The method according to claim 17, characterized in that The device cluster change message includes the identifier of the target device cluster and the identifier of the second terminal device. The updating of corresponding device cluster information according to the device cluster change message includes: The identifier of the terminal device in the leader state in the device cluster information corresponding to the identifier of the target device cluster is updated to the identifier of the second terminal device.

19. The method according to claim 17 or 18, characterized in that The device cluster change message includes an identifier of the target device cluster and an identifier of a third terminal device added to the target device cluster. Updating corresponding device cluster information according to the device cluster change message includes: The identifier of the third terminal device is added to the device cluster information corresponding to the identifier of the target device cluster.

20. The method according to any one of claims 17 to 19, characterized in that: The device cluster change message includes the identifier of the target device cluster and the identifier of the fourth terminal device removed from the target device cluster. Updating the corresponding device cluster information according to the device cluster change message includes: The identifier of the fourth terminal device is removed from the device cluster information corresponding to the identifier of the target device cluster.

21. The method according to any one of claims 15 to 20, characterized in that The communication quality between the terminal device in the leader state in each device cluster and the cloud server is higher than a first threshold.

22. The method according to any one of claims 15 to 21, characterized in that The communication quality between the terminal device in the leader state in each device cluster and the cloud server is the highest.

23. A terminal device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the method according to any one of claims 1 to 14 when calling the computer program.

24. A cloud server, characterized in that: include: A memory and a processor, the memory being used to store a computer program; the processor being used to execute the method according to any one of claims 15 to 22 when calling the computer program.

25. A data synchronization system, characterized in that: include: The cloud server as claimed in claim 24 and multiple terminal devices as claimed in claim 23.

26. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 22 is implemented.

27. A chip system, characterized in that: The chip system includes a processor coupled to a memory, and the processor executes a computer program stored in the memory to implement the method according to any one of claims 1 to 22.