CN116962430A - Data synchronization method, device, equipment and storage medium - Google Patents
Data synchronization method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN116962430A CN116962430A CN202210395610.0A CN202210395610A CN116962430A CN 116962430 A CN116962430 A CN 116962430A CN 202210395610 A CN202210395610 A CN 202210395610A CN 116962430 A CN116962430 A CN 116962430A
- Authority
- CN
- China
- Prior art keywords
- data
- synchronized
- serial number
- node
- synchronization
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 94
- 230000001360 synchronised effect Effects 0.000 claims abstract description 276
- 238000004590 computer program Methods 0.000 claims description 18
- 238000010586 diagram Methods 0.000 description 12
- 230000006870 function Effects 0.000 description 9
- 238000005516 engineering process Methods 0.000 description 8
- 230000008569 process Effects 0.000 description 8
- 238000012545 processing Methods 0.000 description 7
- 239000002699 waste material Substances 0.000 description 5
- 238000013473 artificial intelligence Methods 0.000 description 4
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 230000001174 ascending effect Effects 0.000 description 3
- 230000015556 catabolic process Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 3
- 238000006731 degradation reaction Methods 0.000 description 3
- 238000012217 deletion Methods 0.000 description 3
- 230000037430 deletion Effects 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application provides a data synchronization method, a device, equipment and a storage medium, and relates to the technical field of computers, wherein the method comprises the following steps: receiving a data synchronization request sent by terminal equipment, wherein the data synchronization request comprises a first serial number and a second serial number; determining a data synchronization mode based on the first serial number; and when the synchronization mode is incremental synchronization and the first serial number is smaller than the second serial number, sending data of a target node to the terminal equipment according to the sequence of increasing the serial numbers, wherein the target node is a node to be synchronized, the serial number of which is larger than the first serial number and smaller than or equal to the second serial number on the server, and the indication information indicates reservation. The method can enable the server to select the optimal synchronization mode according to the actual condition of data synchronization, and by introducing the concepts of synchronizing data according to the sequence of increasing the second serial number and the serial number, the data volume during incremental synchronization can be reduced, the synchronization efficiency is improved, and the synchronization time and flow are saved.
Description
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a data synchronization method, a device, equipment and a storage medium.
Background
Currently, when a terminal device needs a server to synchronize data of a certain service scenario, there are two schemes, scheme one: the server pulls all background data related to the service scene and synchronizes all the background data to the terminal equipment for the service scene; scheme II: the server provides the capability of pulling all child node data according to the father node, and the terminal equipment acquires the data from the server according to actual needs according to the service scene.
However, the scheme one is only suitable for the scenes of small data scale, low data use frequency and low occurrence of data modification events. For the data scale reaching tens of thousands or the scene of event frequency is modified, the total amount of synchronous data at each time can bring waste of flow and synchronous time, and the system bottleneck is formed. In the second scheme, the hierarchical characteristic of the tree data structure is utilized, a method for acquiring data in real time according to the hierarchy is designed, and most of service scenes displayed in a hierarchical manner can be met, but the problem of large single synchronous data volume is still faced in the condition that the number of child nodes of a single father node is too large or the service scene of the whole subtree needs to be acquired in a recursion mode.
Disclosure of Invention
The application provides a data synchronization method, a device, equipment and a storage medium, which can enable a server to select an optimal synchronization mode according to the actual condition of data synchronization, and can reduce the data quantity during incremental synchronization, improve the synchronization efficiency and save the synchronization time and flow by introducing a concept of synchronizing data according to a second serial number and the sequence of increasing the serial number.
In a first aspect, the present application provides a data synchronization method, which is applied to a server, and includes:
receiving a data synchronization request sent by terminal equipment, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of a node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on a server when the last full-quantity synchronization starts;
determining a data synchronization mode based on the first serial number;
and when the synchronization mode is incremental synchronization and the first serial number is smaller than the second serial number, sending data of a target node to the terminal equipment according to the sequence of increasing the serial numbers, wherein the target node is a node to be synchronized, the serial number of which is larger than the first serial number and smaller than or equal to the second serial number on the server, and the indication information indicates reservation.
In a second aspect, the present application provides a data synchronization method, where the method is applied to a terminal device, and includes:
transmitting a data synchronization request to a server, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of a node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on the server when the last full-quantity synchronization starts;
receiving data of a target node sent by the server, wherein the target node is a node to be synchronized, the serial number of which is greater than the first serial number and less than or equal to the second serial number, on the server, and the indication information indicates reservation;
the data of the target node is sent according to the sequence of increasing sequence when the data synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number;
and merging and storing the data of the target node and the locally received first data of the node to be synchronized.
In a third aspect, the present application provides a data synchronization device, which is a server, including:
the receiving unit is used for receiving a data synchronization request sent by the terminal equipment, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of the node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on the server when the last full-size synchronization is started;
A determining unit, configured to determine a synchronization manner of data based on the first sequence number;
and the sending unit is used for sending the data of the target node to the terminal equipment according to the sequence of increasing the sequence number when the synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number, wherein the target node is a node to be synchronized, the sequence number of which is larger than the first sequence number and smaller than or equal to the second sequence number on the server, and the indication information indicates reservation.
In a fourth aspect, the present application provides a data synchronization device, where the device is a terminal device, and the device includes:
the sending unit is used for sending a data synchronization request to the server, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of the node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on the server when the last full-size synchronization is started;
the receiving unit is used for receiving data of a target node sent by the server, wherein the target node is a node to be synchronized, the serial number of which is greater than the first serial number and less than or equal to the second serial number, on the server, and the indication information indicates reservation;
The data of the target node is sent according to the sequence of increasing sequence when the data synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number;
and the merging unit is used for merging and storing the data of the target node and the first data of the locally received node to be synchronized.
In a fifth aspect, the present application provides an electronic device, comprising:
a processor adapted to execute a computer program;
a computer readable storage medium having a computer program stored therein, the computer program being loaded by the processor and performing the method of the first or second aspect described above.
In a sixth aspect, the present application provides a computer readable storage medium storing computer instructions which, when read and executed by a processor of a computer device, cause the computer device to perform the method of the first or second aspect described above.
In this embodiment, the synchronization manner of the data is determined by the first sequence number, which is equivalent to considering that there may be a large number of data deletion operations in a scene where the data changes frequently, and if incremental synchronization is directly used at this time, a large number of indication information needs to be synchronized to indicate unreserved nodes to be synchronized, which conversely causes performance degradation and synchronization resource waste; therefore, the incremental data can be clarified by using the first sequence number, and the synchronization method of the data can be determined by comparing the incremental data with the full-size data, that is, the server can select the optimal synchronization method according to the actual condition of data synchronization by using the first sequence number.
In addition, by introducing the concept of the second serial number and synchronizing data according to the ascending order of the serial numbers during incremental synchronization, the method is equivalent to considering that the node to be synchronized, which is larger than the first serial number and smaller than or equal to the second serial number, on the server side is definitely the node which is not synchronized to the terminal, so that during incremental synchronization, the influence of the indication information in the range on the local data of the terminal, which is caused by the indication information in the range, is not considered, namely, only the indication information in the range is needed to be synchronized to indicate the reserved node to be synchronized, and the non-synchronization indication information indicates the unreserved node to be synchronized, so that the data quantity during incremental synchronization can be reduced, the synchronization efficiency is improved, and the synchronization time and flow are saved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a diagram illustrating a scenario provided by an embodiment of the present application.
Fig. 2 is a schematic flow chart of a data synchronization method provided by an embodiment of the present application.
FIG. 3 is a schematic diagram of incremental synchronization provided by an embodiment of the present application.
FIG. 4 is a schematic diagram of another incremental synchronization provided by an embodiment of the present application.
Fig. 5 is another schematic flow chart of a data synchronization method provided by an embodiment of the present application.
FIG. 6 is another schematic flow chart of a data synchronization method provided by an embodiment of the present application
Fig. 7 is a schematic block diagram of a data synchronization device according to an embodiment of the present application.
Fig. 8 is another schematic block diagram of a data synchronization device according to an embodiment of the present application.
Fig. 9 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
With research and advancement of artificial intelligence technology, research and application of artificial intelligence technology is being developed in various fields, such as common smart home, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned, automatic driving, unmanned aerial vehicles, robots, smart medical treatment, smart customer service, etc., and it is believed that with the development of technology, artificial intelligence technology will be applied in more fields and with increasing importance value.
The scheme provided by the embodiment of the application also relates to a data processing technology in the field of network media. Network media, unlike conventional audio and video devices, relies on techniques and equipment provided by Information Technology (IT) device developers to transmit, store and process audio and video signals. The conventional Serial Digital (SDI) transmission mode lacks network switching characteristics in a true sense. Much work is required to create a portion of the network functionality like that provided by ethernet and Internet Protocol (IP) using SDI. Thus, network media technology has evolved. Further, the data processing technology of the network medium may include transmission, storage and processing of audio and video signals.
Fig. 1 is an example of a scenario 100 provided by an embodiment of the present application.
The scenario 100 may be an application system, and embodiments of the present application are not limited to a particular type of application. The scene 100 includes: terminal equipment 110, server 120. Terminal device 110 may be connected to server 120 via a wireless or wired network.
The terminal device 110 may be one of a smart phone, a game console, a desktop computer, a tablet computer, an electronic book reader, an MP4 player, and a laptop portable computer. The terminal device 110 has an application installed and running. The application program may be any one of an online video program, a short video program, a picture sharing program, a sound social program, a cartoon program, a wallpaper program, a news pushing program, a supply and demand information pushing program, an academic communication program, a technical communication program, a policy communication program, a program containing a comment mechanism, a program containing a view publishing mechanism, and a knowledge sharing program. Terminal device 110 may be a terminal used by user 130, with a user account logged into an application running in terminal device 110.
The server 120 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, basic cloud computing services such as big data and an artificial intelligence platform, and the servers may be directly or indirectly connected through wired or wireless communication modes, which is not limited herein.
Alternatively, taking the example that the scenario 100 is a data synchronization scenario, the server 120 is configured to provide data of nodes to be synchronized to an application program (e.g., an application program on the terminal device 110). The server 120 is configured to receive a data synchronization request sent by the terminal device 110, determine data to be synchronized based on parameters in the data synchronization request, and send the data to be synchronized to the terminal device.
At present, since the server has redundant data in transmitting data to be synchronized to the terminal device, waste in traffic and synchronization time is caused.
Based on the above, the application provides a data synchronization method, a device, equipment and a storage medium, which can enable a server to select an optimal synchronization mode according to the actual condition of data synchronization, and can reduce the data quantity during incremental synchronization, improve the synchronization efficiency and save the synchronization time and flow by introducing the concepts of synchronizing data according to the sequence of increasing the second serial number and the serial number.
In order to facilitate understanding of the aspects of the present application, the following description will refer to related terms.
1. Synchronizing: the method refers to that the data of the background is issued to the front end through a protocol so as to ensure the consistency of the data of the front end and the back end.
2. Incremental synchronization: after the last full-volume synchronization or the last increment synchronization, only the data which is added or modified compared with the previous data is needed to be synchronized each time later, namely, only the data which generates change is issued when the increment synchronization is the data synchronization. It should be appreciated that incremental synchronization enables faster synchronization of terminal data to the most up-to-date data with less difference between the terminal data and the background data.
3. Full synchronization: refer to issuing all data each time data is synchronized. It should be appreciated that full synchronization is mostly applied when the terminal is behind too much or no data.
It should be noted that, the application scenario of the present application includes, but is not limited to, synchronization of data in patrol report of an information platform in an enterprise; the patrol report can be based on a gridding treatment work order, members can report the problems found in the patrol visit to the grid, the grid center responsible person uniformly distributes the problems, and the management efficiency is improved by the aid of a flow work order classification mechanism. In particular, the grid for patrol report may be a tree data structure, the worksheets in the grid may be circulated to the grids of the parent nodes, and the grids of each parent node may view the grid data of its child nodes. It should be appreciated that the terminal needs to store the entire grid structure permanently, and that the terminal data is first aligned with the background data by the synchronization protocol each time the relevant data needs to be used.
Fig. 2 is a schematic flow chart of a data synchronization method 200 provided by an embodiment of the present application. The method 200 may be performed by a server, such as the server 120 shown in fig. 1.
S201, receiving a data synchronization request sent by a terminal device, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of a node to be synchronized received by the terminal device, and the second serial number is the maximum serial number of the node to be synchronized on a server when the last full-size synchronization is started;
s202, determining a data synchronization mode based on the first serial number;
and S203, when the synchronization mode is incremental synchronization and the first serial number is smaller than the second serial number, sending data of a target node to the terminal equipment according to the sequence of increasing the serial numbers, wherein the target node is a node to be synchronized, the serial number of which is larger than the first serial number and smaller than or equal to the second serial number on the server, and the indication information indicates reservation.
In other words, the server receives a data synchronization request sent by the terminal device, determines whether the synchronization mode of the data is incremental synchronization or full synchronization based on a first sequence number in the data synchronization request, and sends data of which the sequence number is greater than the first sequence number, less than or equal to the second sequence number and the indication information indicates a reserved node to be synchronized to the terminal device in the sequence of increasing the sequence number when the synchronization mode is incremental synchronization and the first sequence number is less than the second sequence number.
It should be appreciated that if full synchronization does not occur before local data synchronization, this time is the first data synchronization, i.e., the second sequence number in the current data synchronization request is equal to 0.
Each node to be synchronized on the server not only stores own service data, but also comprises serial number information and indication information; the sequence number information is used for uniquely corresponding to the sequence number of the node to be synchronized, and the indication information is used for indicating whether the node to be synchronized is reserved or not; it should be appreciated that the sequence number of each node to be synchronized on the server is different.
Illustratively, the sequence number of the node to be synchronized on the server may be incremented based on the first timestamp of the node to be synchronized.
If the information of the node to be synchronized is updated, determining a time stamp when the information is updated as a first time stamp of the node to be synchronized; if the node to be synchronized is a newly added node, the time stamp when the node to be synchronized is stored for the first time is determined to be the first time stamp of the node to be synchronized.
For example, an incremented sequence number may also be generated for each node to be synchronized based on the millisecond time stamp and the order of operation. For example, if there are different millisecond time stamps of different nodes to be synchronized, a monotonically increasing serial number can be configured for the different nodes to be synchronized directly along the sequence of the time axis, if there are different millisecond time stamps of the nodes to be synchronized, the operation sequence of the nodes to be synchronized with the front is small, and the operation sequence of the nodes to be synchronized with the back is large.
It should be noted that, the method of generating the sequence number of the node to be synchronized may be other methods, and it is only required to satisfy that the sequence number of the node to be synchronized on the server is incremented based on the first timestamp of the node to be synchronized, which is not particularly limited in the present application.
The serial number of the node to be synchronized on the server is increased based on the first time stamp of the node to be synchronized, so that the efficiency of acquiring incremental data or full data in the data synchronization process is improved.
In this embodiment, the synchronization manner of the data is determined by the first sequence number, which is equivalent to considering that there may be a large number of data deletion operations in a scene where the data changes frequently, and if incremental synchronization is directly used at this time, a large number of indication information needs to be synchronized to indicate unreserved nodes to be synchronized, which conversely causes performance degradation and synchronization resource waste; therefore, the incremental data can be clarified by using the first sequence number, and the synchronization method of the data can be determined by comparing the incremental data with the full-size data, that is, the server can select the optimal synchronization method according to the actual condition of data synchronization by using the first sequence number.
In addition, by introducing the concept of the second serial number and synchronizing data according to the ascending order of the serial numbers during incremental synchronization, the method is equivalent to considering that the node to be synchronized, which is larger than the first serial number and smaller than or equal to the second serial number, on the server side is definitely the node which is not synchronized to the terminal, so that during incremental synchronization, the influence of the indication information in the range on the local data of the terminal, which is caused by the indication information in the range, is not considered, namely, only the indication information in the range is needed to be synchronized to indicate the reserved node to be synchronized, and the non-synchronization indication information indicates the unreserved node to be synchronized, so that the data quantity during incremental synchronization can be reduced, the synchronization efficiency is improved, and the synchronization time and flow are saved.
Incremental synchronization provided by the present application will be schematically described below in connection with fig. 3-4.
FIG. 3 is a schematic diagram of incremental synchronization provided by an embodiment of the present application.
As shown in fig. 3, the method comprises a node 1 and a node 2 in nodes to be synchronized, which are received by a terminal; wherein, the serial number of the node 1 is 1, and the serial number of the node 2 is 2.
Node 1, node 2, node 3 and node 4 among the nodes to be synchronized on the server; wherein, the serial number of the node 1 is 1, the serial number of the node 2 is 2, the serial number of the node 3 is 3, and the serial number of the node 4 is 4.
The terminal sends a data synchronization request to the server, where the data synchronization request includes a first serial number (as shown in fig. 3, the first serial number is equal to 2), and after the server receives the data synchronization request, determines a data synchronization mode, and if the synchronization mode is incremental synchronization, sends data of a node to be synchronized with a serial number greater than the first serial number to the terminal according to an increasing sequence of the serial number (as shown in fig. 3, the node to be synchronized with the serial number greater than the first serial number is node 3 and node 4, and sends data of node 3 and data of node 4 to the terminal in sequence according to an increasing sequence of the serial number, where the serial number of node 3 is 3 and the serial number of node 4 is 4).
It should be noted that, the sequence numbers of the nodes 1 to 4 in fig. 3 are only illustrative, and may be other sequence numbers satisfying monotonically increasing, which is not particularly limited by the present application.
It should be noted that, the sequence number is the key of incremental synchronization, if there is a new node to be synchronized on the server, the incremental sequence number needs to be distributed for the new node to be synchronized, if the data of the existing node to be synchronized is modified or the indication information is modified, the modified sequence number of the node to be synchronized needs to be updated, and the incremental sequence number is reconfigured for the modified sequence number; based on the method, when the data are synchronized every time, the server only needs to send the data of the nodes to be synchronized, the serial number of which is larger than that of the first serial number, to the terminal, so that the data synchronization efficiency is improved.
FIG. 4 is a schematic diagram of another incremental synchronization provided by an embodiment of the present application.
As shown in fig. 4, the node 1 and the node 2 which comprise the node to be synchronized and are received by the terminal are included; wherein, the serial number of the node 1 is 1 and the indication information indicates reservation, and the serial number of the node 2 is 2 and the indication information indicates reservation.
Node 1, node 3, node 4 and node 2 to be synchronized on the server; wherein, the sequence number of the node 1 is 1, the indication information indicates reservation, the sequence number of the node 3 is 3, the indication information indicates reservation, the sequence number of the node 4 is 4, the indication information indicates reservation, the sequence number of the node 2 is 5, and the indication information indicates no reservation; since the indication information of the node 2 is modified, the incremented sequence number 5 is reconfigured.
The terminal sends a data synchronization request to the server, where the data synchronization request includes a first sequence number (as shown in fig. 4, the first sequence number is equal to 2), and after the server receives the data synchronization request, determines a data synchronization mode, and if the synchronization mode is incremental synchronization, sends data of a node to be synchronized with a sequence number greater than the first sequence number to the terminal according to an increasing sequence of the sequence number (as shown in fig. 4, nodes to be synchronized with a sequence number greater than the first sequence number are node 3, node 4 and node 2, and sends data of node 3, data of node 4 and data of node 2 to the terminal in sequence according to an increasing sequence of the sequence number, wherein the sequence number of node 3 is 3, the sequence number of node 4 is 4, and the sequence number of node 2 is 5).
Accordingly, after receiving the data of the node 3, the data of the node 4 and the data of the node 2, the terminal combines the data of the node 3, the data of the node 4 and the data of the node 2 with the local data of the terminal based on the indication information of the node 3, the indication information of the node 4 and the indication information of the node 2, respectively (for example, as shown in fig. 4, when the indication information of the node 2 indicates that the data is not reserved, all the data of the node 2 in the local data will be deleted when the terminal combines the data).
It should be noted that the sequence number of the node 2 in fig. 4 is merely illustrative, and any sequence number greater than 4 may be configured for the node 2, which is not particularly limited in the present application.
In some embodiments of the present application, the method 200 may further comprise:
and when the synchronization mode is incremental synchronization, the first serial number is smaller than the second serial number, and the node to be synchronized with the serial number larger than the second serial number exists, sending data of the node to be synchronized with the serial number larger than the second serial number to the terminal equipment according to the sequence of increasing the serial number.
In this embodiment, since it is considered that, among the nodes to be synchronized whose sequence number is greater than the second sequence number on the server, there may be nodes to be synchronized that have been sent to the terminal and whose indication information is modified or whose data is modified, based on this, data of all the nodes to be synchronized whose sequence number is greater than the second sequence number are sent to the terminal device in the sequence of increasing sequence number without considering the indication information, so that the integrity and accuracy of data synchronization can be ensured.
In some embodiments of the present application, the method 200 may further comprise:
and when the synchronization mode is incremental synchronization and the first serial number is greater than or equal to the second serial number, sending data of the node to be synchronized, the serial number of which is greater than the first serial number, to the terminal equipment according to the sequence of increasing the serial numbers.
In this embodiment, since the first sequence number is greater than or equal to the second sequence number, it is indicated that the data of the node to be synchronized with the server side sequence number less than the second sequence number is sent to the terminal, at this time, any modification of the data of the node to be synchronized with the server side sequence number greater than the second sequence number needs to be sent to the terminal, and meanwhile, taking into account that the synchronization mode is incremental synchronization, and the first sequence number is greater than or equal to the second sequence number, the data of the node to be synchronized with the sequence number greater than the first sequence number is sent to the terminal device, so that the integrity and the correctness of data synchronization can be ensured.
In some embodiments of the present application, the method 200 may further comprise:
when the synchronization mode is full synchronization, acquiring the maximum serial number of the node to be synchronized when the full synchronization is started;
transmitting an instruction to the terminal equipment, wherein the instruction is used for indicating the terminal equipment to empty the locally received data of the node to be synchronized, and the instruction comprises the maximum serial number of the node to be synchronized on the server when the full synchronization is started;
and sending indication information to the terminal equipment according to the sequence of increasing sequence numbers, wherein the indication information indicates the reserved data of the nodes to be synchronized.
In this embodiment, when the synchronization mode is full synchronization, since it is considered that after the terminal receives the data of the node to be synchronized, it is not necessary to combine the data with local data, before sending the full data, an instruction is sent to the terminal to instruct the terminal to empty the data of the node to be synchronized received locally; in addition, because the data synchronization scheme of the application is considered to synchronize data according to the sequence of increasing sequence numbers, the maximum sequence number (second sequence number) of the node to be synchronized at the beginning of the full-quantity synchronization is sent to the terminal for recording, and when the data is in the follow-up incremental synchronization, the data integrity is ensured, and the least incremental data is determined to be laid on the basis of the second sequence number stored by the terminal.
Of course, in other alternative embodiments, the server may also store the maximum sequence number of the node to be synchronized each time full synchronization begins, and when determining the synchronization mode, recall the stored second sequence number from the database.
In some embodiments of the present application, S202 may include:
determining a first number of reserved nodes to be synchronized and a second number of nodes to be synchronized, the number of which is greater than the first number of the nodes to be synchronized, wherein the first number of the nodes to be synchronized is indicated by the indication information;
if the first number is greater than or equal to the second number, the synchronization mode is incremental synchronization;
If the first number is smaller than the second number, the synchronization mode is full synchronization.
In other words, among all the nodes to be synchronized on the server, determining that the indication information indicates the number of reserved nodes to be synchronized (the number of nodes to be synchronized in full) and the number of nodes to be synchronized (the number of nodes to be synchronized in increment) with the sequence number greater than the first sequence number, and if the indication information indicates that the number of reserved nodes to be synchronized is greater than or equal to the number of nodes to be synchronized with the sequence number greater than the first sequence number, synchronizing the nodes to be synchronized in increment; otherwise, the synchronization mode is full synchronization.
For example, only one indication information of all nodes to be synchronized on the server indicates reservation, and indication information of other nodes to be synchronized (at least two nodes to be synchronized) indicates non-reservation, and at this time, full synchronization is the optimal synchronization mode.
In this embodiment, by comparing the number of nodes to be synchronized in full synchronization with the number of nodes to be synchronized in incremental synchronization, a synchronization mode with the smallest data amount is selected, which avoids performance degradation and synchronization resource waste caused by the reverse of the situation that a large amount of indication information is required to indicate unreserved nodes to be synchronized if incremental synchronization is directly used in a scene where data change is frequent and a large amount of data deletion operations are possible; or when the data change is not frequent, all the data are synchronized every time, so that the problems of overtime synchronization and low synchronization efficiency are caused.
In some embodiments of the present application, S200 may further include:
paging and transmitting data of nodes to be synchronized on the server to the terminal equipment;
when the synchronization mode is incremental synchronization and the number of first nodes to be synchronized corresponding to data sent to the terminal equipment by a current page is equal to a preset threshold value, determining the maximum sequence number of the first nodes to be synchronized as a new first sequence number;
when the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to data sent to the terminal equipment by the current page is equal to the preset threshold value, determining the maximum serial number of the second nodes to be synchronized as a new first serial number;
and when the new first serial number is smaller than the maximum serial number of the current node to be synchronized of the server, determining the data synchronization mode of the next page again based on the new first serial number.
The preset threshold may be 1000 or 2000, which is not particularly limited by the present application.
In this embodiment, paging synchronization is performed on data of a node to be synchronized, and before synchronization of each page begins, a synchronization mode of the data is redetermined based on a new first serial number, on one hand, the synchronization mode of the data is determined by using the new first serial number, so that effective data with minimum synchronization of each page can be ensured; on the other hand, the accuracy of data synchronization can be ensured because the sequence of increasing sequence numbers is always performed during data synchronization.
In addition, the data of the node to be synchronized is always sent to the terminal according to the sequence of increasing the sequence number during data synchronization, so that the paging updating data operation can be simply performed based on the sequence number by utilizing the characteristic of increasing the sequence number, the data acquisition efficiency is improved, and the problem of overtime is avoided.
Fig. 5 is another schematic flow chart of a data synchronization method 300 provided by an embodiment of the present application. The method 300 may be performed by a server, such as the server 120 shown in fig. 1.
S301, the server acquires a data synchronization request.
S302, the server determines whether the first sequence number in the data synchronization request is equal to 0?
S303, if the first serial number is not equal to 0, the server determines whether the first number is smaller than the second number.
It should be noted that, the first number is the number of nodes to be synchronized reserved indicated by the indication information, that is, the number of nodes to be synchronized corresponding to the full data; the second number is the number of nodes to be synchronized with a sequence number greater than the first sequence number, namely the number of nodes to be synchronized corresponding to the incremental data.
S304, if the first number is greater than or equal to the second number, determining whether the first serial number is smaller than the second serial number.
If the first number is greater than or equal to the second number, the incremental synchronization is the optimal synchronization method.
S305, if the first serial number is smaller than the second serial number, determining the initial value of i as 0, determining the initial value of j as the minimum serial number with serial number larger than the first serial number among all serial numbers corresponding to all nodes to be synchronized on the server, determining whether i is smaller than a preset threshold value, j is larger than the second serial number, and the indication information of the node to be synchronized with serial number j indicates reservation?
And S306, if the conditions of the S305 are met, issuing data of the nodes to be synchronized with the sequence number j, and re-determining the minimum sequence number with the sequence number greater than j in all sequence numbers corresponding to all the nodes to be synchronized on the server as a new j, wherein i is determined as the sum of i and 1.
In short, the execution procedure of S305 to S306 is: if the first serial number is smaller than the second serial number, the server sends data of the target nodes to the terminal according to the sequence of increasing the serial numbers, the number of the target nodes is recorded, and the number of the target nodes does not exceed a preset threshold value.
It should be noted that, when the preset threshold is page synchronization, the preset data amount of each page is the most synchronized. The target node is a node to be synchronized, the serial number of which is larger than the first serial number and smaller than or equal to the second serial number, on the server, and the indication information indicates reservation.
S307, determining whether i is less than a preset threshold and whether there is a node to be synchronized with a sequence number j greater than the second sequence number?
And S308, if the conditions in the S307 are met, issuing data of the nodes to be synchronized with the sequence number j, and re-determining the minimum sequence number with the sequence number greater than j in all sequence numbers corresponding to all the nodes to be synchronized on the server as a new j, wherein i is determined as the sum of i and 1.
In short, the execution procedure of S307 to S308 is: and if the first serial number is smaller than the second serial number, the number of the sent nodes to be synchronized is smaller than a preset threshold value, and the server has the nodes to be synchronized with the serial number larger than the second serial number, sending the data of the nodes to be synchronized with the serial number larger than the second serial number to the terminal equipment according to the sequence of increasing the serial number.
S309, if no node to be synchronized exists on the server, or the number of i is equal to a preset threshold, determining the maximum sequence number of the sent node to be synchronized as a new first sequence number.
S310, if the first serial number is greater than or equal to the second serial number, determining that the initial value of i is 0, and determining that the initial value of j is the minimum serial number, of all serial numbers corresponding to all nodes to be synchronized on the server, of which the serial numbers are greater than the first serial number, and determining whether i is less than a preset threshold value and j is present?
And S311, if the conditions of the S310 are met, issuing data of the nodes to be synchronized with the sequence number j, and re-determining the minimum sequence number with the sequence number greater than j in all sequence numbers corresponding to all the nodes to be synchronized on the server as a new j, wherein i is determined as the sum of i and 1.
In short, the execution process of S310 to S311 is: and when the synchronization mode is incremental synchronization, the first serial number is larger than or equal to the second serial number, and the number of the sent nodes to be synchronized is smaller than a preset threshold value, sending data of the nodes to be synchronized, of which the serial number is larger than the first serial number, to the terminal equipment according to the serial number increasing sequence.
S312, if the first serial number is equal to 0 or the first number is smaller than the second number, the maximum serial number of the node to be synchronized at the beginning of the full-quantity synchronization is obtained, and an instruction is sent to the terminal equipment to instruct the terminal equipment to empty the locally received data of the node to be synchronized.
S313, determining the initial value of i as 0, determining the initial value of j as the minimum sequence number of all sequence numbers corresponding to all nodes to be synchronized on the server, determining whether i is smaller than a preset threshold value, and determining whether there is a node to be synchronized with the sequence number of j on the server?
And S314, if the conditions of the S313 are met, issuing data of the nodes to be synchronized with the sequence number j, and re-determining the minimum sequence number with the sequence number greater than j in all sequence numbers corresponding to all the nodes to be synchronized on the server as a new j, wherein i is determined as the sum of i and 1.
S315, determining whether the new first sequence number is less than the maximum sequence number of the current node to be synchronized of the server?
If the first serial number is smaller than the maximum serial number of the current node to be synchronized of the server, determining the synchronization mode of the data of the next page again based on the new first serial number.
S316, if the first serial number is equal to the maximum serial number of the current node to be synchronized of the server, the data synchronization is finished.
In this embodiment, the number of nodes to be synchronized corresponding to the incremental data and the number of nodes to be synchronized corresponding to the full data are determined through the first serial number, and then the optimal data synchronization mode is determined through comparing the number of the nodes to be synchronized and the number of the nodes to be synchronized, that is, the server can select the optimal synchronization mode according to the actual data synchronization condition by using the first serial number, so as to improve the synchronization efficiency.
In addition, the concept of introducing the second serial number and synchronizing data according to the ascending sequence of the serial numbers during incremental synchronization is equivalent to the fact that the node to be synchronized, which is larger than the first serial number and smaller than or equal to the second serial number, on the server side is definitely the node which is not synchronized to the terminal, so that during incremental synchronization, the influence of the indication information in the range on the local data of the terminal, which is caused by the fact that the indication information in the range indicates the reserved node to be synchronized, is not needed to be synchronized, the data quantity during incremental synchronization can be reduced, the synchronization efficiency is improved, and the synchronization time and flow are saved.
In addition, paging synchronization is carried out on data of nodes to be synchronized during data synchronization, and the synchronization mode of the data is redetermined based on the new first serial number before the synchronization of each page begins; on the other hand, the accuracy of data synchronization can be ensured because the sequence of increasing sequence numbers is always performed during data synchronization. That is, by utilizing the characteristic of increasing the serial number, the paging updating data operation can be simply performed based on the serial number, and the data acquisition efficiency is improved, so that the problem of overtime is avoided.
Fig. 6 is another schematic flow chart diagram of a data synchronization method 400 provided by an embodiment of the present application. The method 400 may be performed by a terminal device, such as the terminal device 110 shown in fig. 1.
S401, sending a data synchronization request to a server, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of a node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on the server when the last full-quantity synchronization starts;
S402, receiving data of a target node sent by the server, wherein the target node is a node to be synchronized, the serial number of which is greater than the first serial number and less than or equal to the second serial number, on the server, and the indication information indicates reservation;
the data of the target node is sent according to the sequence of increasing sequence when the data synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number;
s403, merging and storing the data of the target node and the first data of the locally received node to be synchronized.
In other words, the terminal device sends a data synchronization request to the server, where the data synchronization request includes a first sequence number and a second sequence number, receives data of a target node with an increased sequence number sent by the server, and merges and stores the received data of the target node with the first data of the locally received node to be synchronized.
In this embodiment, on the basis that the data received by the terminal satisfies the data integrity, the data amount of the node to be synchronized received by the terminal is reduced, and the efficiency of merging data by the terminal is improved.
In some embodiments of the present application, the method 400 may further comprise:
Receiving data of nodes to be synchronized, the serial numbers of which are larger than the second serial numbers, sent by the server;
the data of the nodes to be synchronized with the serial numbers larger than the second serial number are sent according to the sequence of increasing serial numbers when the synchronization mode is incremental synchronization, the first serial number is smaller than the second serial number, and the nodes to be synchronized with the serial numbers larger than the second serial number exist on the server;
and merging and storing the data of the node to be synchronized with the serial number larger than the second serial number and the locally received second data of the node to be synchronized.
In this embodiment, the data of the node to be synchronized, which has the sequence number increased and is greater than the second sequence number, is received, so that the integrity and correctness of the received data can be ensured.
In some embodiments of the present application, the method 400 may further comprise:
receiving an instruction sent by a server, wherein the instruction is used for indicating the terminal equipment to empty the locally received data of the node to be synchronized, and the instruction comprises the maximum serial number of the node to be synchronized on the server when the full synchronization is started;
responding to the instruction, clearing the data of the locally received nodes to be synchronized, and determining the maximum serial number of the nodes to be synchronized on the server at the beginning of the full synchronization as a new second serial number;
Receiving the data of the node to be synchronized, which is indicated to be reserved by the indication information sent by the server;
the indication information indicates that reserved data of the nodes to be synchronized are sent when the synchronization mode is full synchronization;
and storing the data of the node to be synchronized, wherein the data is reserved and indicated by the indication information.
In this embodiment, the maximum sequence number of the node to be synchronized on the server is received and stored as the new second sequence number when the full-volume synchronization starts, which is equivalent to determining that as few incremental data as possible is used as a pad on the basis of ensuring the data integrity when the full-volume synchronization starts.
The preferred embodiments of the present application have been described in detail above with reference to the accompanying drawings, but the present application is not limited to the specific details of the above embodiments, and various simple modifications can be made to the technical solution of the present application within the scope of the technical concept of the present application, and all the simple modifications belong to the protection scope of the present application. For example, the specific features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various possible combinations are not described further. As another example, any combination of the various embodiments of the present application may be made without departing from the spirit of the present application, which should also be regarded as the disclosure of the present application.
It should be further understood that, in the various method embodiments of the present application, the sequence numbers of the foregoing processes do not mean the order of execution, and the order of execution of the processes should be determined by the functions and internal logic of the processes, and should not constitute any limitation on the implementation process of the embodiments of the present application.
The method provided by the embodiment of the application is described above, and the device provided by the embodiment of the application is described below.
Fig. 7 is a schematic block diagram of a data synchronization apparatus 500 according to an embodiment of the present application.
The device is a server.
The apparatus 500 includes:
a receiving unit 510, configured to receive a data synchronization request sent by a terminal device, where the data synchronization request includes a first sequence number and a second sequence number, where the first sequence number is a maximum sequence number of a node to be synchronized received by the terminal device, and the second sequence number is a maximum sequence number of the node to be synchronized on a server when a last full-size synchronization is started;
a determining unit 520, configured to determine a synchronization manner of the data based on the first sequence number;
and a sending unit 530, configured to send, to the terminal device, data of a target node according to an order of increasing sequence numbers when the synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number, where the target node is a node to be synchronized where the sequence number on the server is greater than the first sequence number, less than or equal to the second sequence number, and the indication information indicates a reservation.
In some embodiments of the present application, the transmitting unit 530 may be further configured to:
and when the synchronization mode is incremental synchronization, the first serial number is smaller than the second serial number, and the node to be synchronized with the serial number larger than the second serial number exists, sending data of the node to be synchronized with the serial number larger than the second serial number to the terminal equipment according to the sequence of increasing the serial number.
In some embodiments of the present application, the transmitting unit 530 may be further configured to:
and when the synchronization mode is incremental synchronization and the first serial number is greater than or equal to the second serial number, sending data of the node to be synchronized, the serial number of which is greater than the first serial number, to the terminal equipment according to the sequence of increasing the serial numbers.
In some embodiments of the present application, the transmitting unit 530 may be further configured to:
when the synchronization mode is full synchronization, acquiring the maximum serial number of the node to be synchronized when the full synchronization is started;
transmitting an instruction to the terminal equipment, wherein the instruction is used for indicating the terminal equipment to empty the locally received data of the node to be synchronized, and the instruction comprises the maximum serial number of the node to be synchronized on the server when the full synchronization is started;
and sending indication information to the terminal equipment according to the sequence of increasing sequence numbers, wherein the indication information indicates the reserved data of the nodes to be synchronized.
In some embodiments of the present application, the determining unit 520 is configured to:
determining a first number of reserved nodes to be synchronized and a second number of nodes to be synchronized, the number of which is greater than the first number of the nodes to be synchronized, wherein the first number of the nodes to be synchronized is indicated by the indication information;
if the first number is greater than or equal to the second number, the synchronization mode is incremental synchronization;
if the first number is smaller than the second number, the synchronization mode is full synchronization.
In some embodiments of the present application, the transmitting unit 530 may be further configured to:
paging and transmitting data of nodes to be synchronized on the server to the terminal equipment;
when the synchronization mode is incremental synchronization and the number of first nodes to be synchronized corresponding to data sent to the terminal equipment by a current page is equal to a preset threshold value, determining the maximum sequence number of the first nodes to be synchronized as a new first sequence number;
when the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to data sent to the terminal equipment by the current page is equal to the preset threshold value, determining the maximum serial number of the second nodes to be synchronized as a new first serial number;
and when the new first serial number is smaller than the maximum serial number of the current node to be synchronized of the server, determining the data synchronization mode of the next page again based on the new first serial number.
In some embodiments of the present application, the sequence number of the node to be synchronized on the server is incremented based on the first timestamp of the node to be synchronized;
if the information of the node to be synchronized is updated, determining a time stamp when the information is updated as a first time stamp of the node to be synchronized; if the node to be synchronized is a newly added node, the time stamp when the node to be synchronized is stored for the first time is determined to be the first time stamp of the node to be synchronized.
Fig. 8 is another schematic block diagram of a data synchronization apparatus 600 provided by an embodiment of the present application.
The device is a terminal device.
The apparatus 600 includes:
a sending unit 610, configured to send a data synchronization request to a server, where the data synchronization request includes a first sequence number and a second sequence number, where the first sequence number is a maximum sequence number of a node to be synchronized received by the terminal device, and the second sequence number is a maximum sequence number of the node to be synchronized on the server when the last full-size synchronization starts;
a receiving unit 620, configured to receive data of a target node sent by the server, where the target node is a node to be synchronized that has a sequence number on the server that is greater than the first sequence number, less than or equal to the second sequence number, and indicates that the indication information indicates reservation;
The data of the target node is sent according to the sequence of increasing sequence when the data synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number;
and the merging unit 630 is configured to merge and store the data of the target node and the locally received first data of the node to be synchronized.
In some embodiments of the present application, the receiving unit 620 may further be configured to:
receiving data of nodes to be synchronized, the serial numbers of which are larger than the second serial numbers, sent by the server;
the data of the nodes to be synchronized with the serial numbers larger than the second serial number are sent according to the sequence of increasing serial numbers when the synchronization mode is incremental synchronization, the first serial number is smaller than the second serial number, and the nodes to be synchronized with the serial numbers larger than the second serial number exist on the server;
and merging and storing the data of the node to be synchronized with the serial number larger than the second serial number and the locally received second data of the node to be synchronized.
In some embodiments of the present application, the receiving unit 620 may further be configured to:
receiving an instruction sent by a server, wherein the instruction is used for indicating the terminal equipment to empty the locally received data of the node to be synchronized, and the instruction comprises the maximum serial number of the node to be synchronized on the server when the full synchronization is started;
Responding to the instruction, clearing the data of the locally received nodes to be synchronized, and determining the maximum serial number of the nodes to be synchronized on the server at the beginning of the full synchronization as a new second serial number;
receiving the data of the node to be synchronized, which is indicated to be reserved by the indication information sent by the server;
the indication information indicates that reserved data of the nodes to be synchronized are sent when the synchronization mode is full synchronization;
and storing the data of the node to be synchronized, wherein the data is reserved and indicated by the indication information.
It should be understood that apparatus embodiments and method embodiments may correspond with each other and that similar descriptions may refer to the method embodiments. To avoid repetition, no further description is provided here. Specifically, the data synchronization device 500 may correspond to a corresponding body in the method 200 or the method 300 for executing the embodiment of the present application, the data synchronization device 600 may correspond to a corresponding body in the method 400 for executing the embodiment of the present application, and each unit in the data synchronization device 500 is for implementing a corresponding flow in the method 200 or the method 300, and each unit in the device 600 is for implementing a corresponding flow in the method 400, which is not described herein for brevity.
It should also be understood that each unit in the data synchronization device 500 or 600 according to the embodiments of the present application may be separately or all combined into one or several other units to form a structure, or some unit(s) thereof may be further split into a plurality of units with smaller functions to form a structure, which may achieve the same operation without affecting the implementation of the technical effects of the embodiments of the present application. The above units are divided based on logic functions, and in practical applications, the functions of one unit may be implemented by a plurality of units, or the functions of a plurality of units may be implemented by one unit. In other embodiments of the present application, the data synchronization device 500 or 600 may also include other units, and in practical applications, these functions may also be implemented with assistance from other units, and may be implemented by cooperation of multiple units. According to another embodiment of the present application, the data synchronization apparatus 500 or 600 related to the embodiment of the present application may be constructed by running a computer program (including a program code) capable of executing the steps involved in the respective methods on a general-purpose computing device of a general-purpose computer including a processing element such as a Central Processing Unit (CPU), a random access storage medium (RAM), a read only storage medium (ROM), and the like, and a storage element, and implementing the data synchronization method of the embodiment of the present application. The computer program may be recorded on a computer readable storage medium, and loaded into an electronic device through the computer readable storage medium and executed therein to implement a corresponding method provided by an embodiment of the present application.
In other words, the units referred to above may be implemented in hardware, or may be implemented by instructions in software, or may be implemented in a combination of hardware and software. Specifically, each step of the method embodiment in the embodiment of the present application may be implemented by an integrated logic circuit of hardware in a processor and/or an instruction in software form, and the steps of the method disclosed in connection with the embodiment of the present application may be directly implemented as a hardware decoding processor or implemented by a combination of hardware and software in the decoding processor. Alternatively, the software may reside in a well-established storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, and the like. The storage medium is located in a memory, and the processor reads information in the memory, and in combination with hardware, performs the steps in the above method embodiments.
Fig. 9 is a schematic structural diagram of an electronic device 700 provided in an embodiment of the present application.
As shown in fig. 9, the electronic device 700 includes at least a processor 710 and a computer readable storage medium 720. Wherein the processor 710 and the computer-readable storage medium 720 may be connected by a bus or other means. The computer readable storage medium 720 is for storing a computer program 721, the computer program 721 comprising computer instructions, and the processor 710 is for executing the computer instructions stored by the computer readable storage medium 720. Processor 710 is a computing core and a control core of electronic device 700 that are adapted to implement one or more computer instructions, in particular to load and execute one or more computer instructions to implement a corresponding method flow or a corresponding function.
By way of example, the processor 710 may also be referred to as a central processing unit (Central Processing Unit, CPU). Processor 710 may include, but is not limited to: a general purpose processor, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like.
By way of example, computer readable storage medium 720 may be high speed RAM Memory or Non-Volatile Memory (NonVolatile Memory), such as at least one magnetic disk Memory; alternatively, it may be at least one computer-readable storage medium located remotely from the aforementioned processor 710. In particular, computer-readable storage media 720 include, but are not limited to: volatile memory and/or nonvolatile memory. The nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM) which acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (Double Data Rate SDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), and Direct memory bus RAM (DR RAM).
In one implementation, the electronic device 700 may be the data synchronization apparatus 500 or 600 shown in fig. 7 or 8; the computer readable storage medium 720 has stored therein computer instructions; computer instructions stored in computer-readable storage medium 720 are loaded and executed by processor 710 to implement the corresponding steps in the method embodiments; in particular, the computer instructions in the computer-readable storage medium 720 are loaded by the processor 710 and perform the corresponding steps, and for avoiding repetition, a detailed description is omitted here.
According to another aspect of the present application, the embodiment of the present application further provides a computer-readable storage medium (Memory), which is a Memory device in the electronic device 700, for storing programs and data. Such as computer readable storage medium 720. It is understood that the computer readable storage medium 720 herein may include a built-in storage medium in the electronic device 700, and may include an extended storage medium supported by the electronic device 700. The computer-readable storage medium provides storage space that stores an operating system of the electronic device 700. Also stored in this memory space are one or more computer instructions, which may be one or more computer programs 721 (including program code), adapted to be loaded and executed by the processor 710.
The electronic device 700 may further include: a transceiver 730, the transceiver 730 being connectable to the processor 710 or the computer readable storage medium 720.
The computer-readable storage medium 720 may control the transceiver 730 to communicate with other devices, and in particular, may transmit information or data to other devices or receive information or data transmitted by other devices. Transceiver 730 may include a transmitter and a receiver. Transceiver 730 may further include antennas, the number of which may be one or more.
According to another aspect of the present application, there is provided a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. Such as a computer program 721. At this time, the electronic device 700 may be a computer, and the processor 710 reads the computer instructions from the computer-readable storage medium 720, and the processor 710 executes the computer instructions so that the computer performs the data synchronization method provided in the above-mentioned various alternatives.
In other words, when implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, runs the processes of, or implements the functions of, embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, from one website, computer, server, or data center by wired (e.g., coaxial cable, fiber optic, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
Those of ordinary skill in the art will appreciate that the elements and process steps of the examples described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or as a combination of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
Finally, it should be noted that the above embodiments are merely specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes or substitutions are included in the scope of the present application.
Claims (15)
1. A method for synchronizing data, the method being applied to a server and comprising:
receiving a data synchronization request sent by terminal equipment, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of a node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on a server when the last full-size synchronization is started;
Determining a data synchronization mode based on the first serial number;
and when the synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number, sending data of a target node to the terminal equipment according to the sequence of increasing the sequence numbers, wherein the target node is a node to be synchronized, the sequence number of which is greater than the first sequence number, smaller than or equal to the second sequence number and the indication information indicates reservation, on the server.
2. The method according to claim 1, wherein the method further comprises:
and when the synchronization mode is incremental synchronization, the first serial number is smaller than the second serial number, and the node to be synchronized with the serial number larger than the second serial number exists, sending data of the node to be synchronized with the serial number larger than the second serial number to the terminal equipment according to the sequence of increasing the serial number.
3. The method according to claim 1, wherein the method further comprises:
and when the synchronization mode is incremental synchronization and the first serial number is greater than or equal to the second serial number, sending data of the nodes to be synchronized, the serial number of which is greater than the first serial number, to the terminal equipment according to the sequence of increasing the serial numbers.
4. The method according to claim 1, wherein the method further comprises:
when the synchronization mode is full synchronization, acquiring the maximum serial number of the node to be synchronized when the full synchronization is started;
transmitting an instruction to the terminal equipment, wherein the instruction is used for indicating the terminal equipment to empty the locally received data of the node to be synchronized, and the instruction comprises the maximum serial number of the node to be synchronized on the server when the full-quantity synchronization is started;
and sending the indication information to the terminal equipment according to the sequence of increasing the sequence number, wherein the indication information indicates the reserved data of the nodes to be synchronized.
5. The method according to any one of claims 1 to 4, wherein said determining a data synchronization pattern based on said first sequence number comprises:
determining that the indication information indicates a first number of reserved nodes to be synchronized and a second number of nodes to be synchronized, the sequence number of which is greater than the first sequence number;
if the first number is greater than or equal to the second number, the synchronization mode is incremental synchronization;
and if the first quantity is smaller than the second quantity, the synchronization mode is full-quantity synchronization.
6. The method according to any one of claims 1 to 4, further comprising:
Paging and sending data of nodes to be synchronized on the server to the terminal equipment;
when the synchronization mode is incremental synchronization and the number of first nodes to be synchronized corresponding to data sent to the terminal equipment by a current page is equal to a preset threshold, determining the maximum sequence number of the first nodes to be synchronized as a new first sequence number;
when the synchronization mode is full synchronization and the number of second nodes to be synchronized corresponding to data sent to the terminal equipment by the current page is equal to the preset threshold value, determining the maximum serial number of the second nodes to be synchronized as a new first serial number;
and when the new first serial number is smaller than the maximum serial number of the current node to be synchronized of the server, determining the synchronization mode of the data of the next page again based on the new first serial number.
7. The method according to any of claims 1 to 4, wherein the sequence number of the node to be synchronized on the server is incremented based on the first timestamp of the node to be synchronized;
if the information of the node to be synchronized is updated, determining a time stamp when the information is updated as a first time stamp of the node to be synchronized; if the node to be synchronized is a newly added node, determining the time stamp when the node to be synchronized is stored for the first time as the first time stamp of the node to be synchronized.
8. A data synchronization method, wherein the method is applied to a terminal device, and comprises:
a data synchronization request is sent to a server, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of a node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on the server when the last full-size synchronization is started;
receiving data of a target node sent by the server, wherein the target node is a node to be synchronized, the serial number of which is greater than the first serial number and less than or equal to the second serial number, on the server, and the indication information indicates reservation;
the data of the target node is sent according to the sequence of increasing sequence when the data synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number;
and merging and storing the data of the target node and the first data of the locally received node to be synchronized.
9. The method of claim 8, wherein the method further comprises:
receiving data of nodes to be synchronized, the serial numbers of which are larger than the second serial numbers, sent by the server;
The data of the nodes to be synchronized with the sequence number larger than the second sequence number are sent according to the sequence of increasing sequence numbers when the synchronization mode is incremental synchronization, the first sequence number is smaller than the second sequence number, and the nodes to be synchronized with the sequence number larger than the second sequence number exist on the server;
and merging and storing the data of the node to be synchronized, the serial number of which is larger than the second serial number, and the locally received second data of the node to be synchronized.
10. The method of claim 8, wherein the method further comprises:
receiving an instruction sent by a server, wherein the instruction is used for indicating the terminal equipment to empty the locally received data of the node to be synchronized, and the instruction comprises the maximum serial number of the node to be synchronized on the server when the full synchronization is started;
responding to the instruction, clearing the data of the locally received node to be synchronized, and determining the maximum serial number of the node to be synchronized on the server at the beginning of the full-quantity synchronization as a new second serial number;
receiving the data of the node to be synchronized, which is reserved and indicated by the indication information sent by the server;
The indication information indicates that reserved data of the nodes to be synchronized are sent when the synchronization mode is full synchronization;
and storing the data of the node to be synchronized, wherein the data is reserved and indicated by the indication information.
11. A data synchronization device, wherein the device is a server, comprising:
the receiving unit is used for receiving a data synchronization request sent by the terminal equipment, wherein the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of the node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on the server when the last full-size synchronization is started;
a determining unit, configured to determine a synchronization manner of data based on the first sequence number;
and the sending unit is used for sending data of a target node to the terminal equipment according to the sequence of increasing the sequence number when the synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number, wherein the target node is a node to be synchronized, the sequence number of which is larger than the first sequence number and smaller than or equal to the second sequence number on the server, and the indication information indicates reservation.
12. A data synchronization device, characterized in that the device is a terminal device, comprising:
the device comprises a sending unit, a server and a receiving unit, wherein the sending unit is used for sending a data synchronization request to the server, the data synchronization request comprises a first serial number and a second serial number, the first serial number is the maximum serial number of a node to be synchronized received by the terminal equipment, and the second serial number is the maximum serial number of the node to be synchronized on the server when the last full-quantity synchronization is started;
the receiving unit is used for receiving data of a target node sent by the server, wherein the target node is a node to be synchronized, the serial number of which is greater than the first serial number and less than or equal to the second serial number, on the server, and the indication information indicates reservation;
the data of the target node is sent according to the sequence of increasing sequence when the data synchronization mode is incremental synchronization and the first sequence number is smaller than the second sequence number;
and the merging unit is used for merging and storing the data of the target node and the first data of the locally received node to be synchronized.
13. An electronic device, comprising:
a processor adapted to execute a computer program;
A computer readable storage medium having stored therein a computer program which, when executed by the processor, implements the method of any one of claims 1 to 7 or the method of any one of claims 8 to 11.
14. A computer readable storage medium storing a computer program for causing a computer to perform the method of any one of claims 1 to 7 or the method of any one of claims 8 to 11.
15. A computer program product comprising a computer program and/or instructions which, when executed by a processor, implement the method of any one of claims 1 to 7 or the method of any one of claims 8 to 11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210395610.0A CN116962430A (en) | 2022-04-14 | 2022-04-14 | Data synchronization method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210395610.0A CN116962430A (en) | 2022-04-14 | 2022-04-14 | Data synchronization method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116962430A true CN116962430A (en) | 2023-10-27 |
Family
ID=88455200
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210395610.0A Pending CN116962430A (en) | 2022-04-14 | 2022-04-14 | Data synchronization method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116962430A (en) |
-
2022
- 2022-04-14 CN CN202210395610.0A patent/CN116962430A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107819829B (en) | Method and system for accessing block chain, block chain node point equipment and user terminal | |
EP2378718B1 (en) | Method, node and system for controlling version in distributed system | |
CN105338078B (en) | Date storage method and device for storage system | |
CN101677325B (en) | Method, device and system for publishing media description information and acquiring media | |
KR101871383B1 (en) | Method and system for using a recursive event listener on a node in hierarchical data structure | |
CN110413650B (en) | Method, device, equipment and storage medium for processing service data | |
CN104731516A (en) | Method and device for accessing files and distributed storage system | |
CN111552701B (en) | Method for determining data consistency in distributed cluster and distributed data system | |
CN114979158B (en) | Resource monitoring method, system, equipment and computer readable storage medium | |
CN107888666A (en) | A kind of cross-region data-storage system and method for data synchronization and device | |
CN111212135A (en) | Message subscription method, device, system, electronic equipment and storage medium | |
CN112069195A (en) | Database-based message transmission method and device, electronic equipment and storage medium | |
CN1645824A (en) | Automated generation of message exchange pattern simulation code | |
CN111478953A (en) | Self-construction method, device, system, equipment and storage medium of server cluster | |
WO2022057525A1 (en) | Method and device for data retrieval, electronic device, and storage medium | |
US7840529B2 (en) | Contents list providing apparatus and contents list providing method | |
CN102947825B (en) | The computer documents that management is shared between at least two devices | |
CN116962430A (en) | Data synchronization method, device, equipment and storage medium | |
CN111919419A (en) | Node, network system and data synchronization method | |
CN101877722A (en) | Electronic program guide (EPG) system and file downloading method | |
CN115189931A (en) | Distributed key management method, device, equipment and storage medium | |
CN111125142B (en) | Data updating method and system | |
CN110659299B (en) | Data updating method and device and front-end development client | |
CN116542668A (en) | Block chain-based data processing method, equipment and readable storage medium | |
CN110515907B (en) | Data synchronization method and related device for distributed storage nodes |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |