Data synchronization method, device, system and storage medium
The message pool receives the data identification of the device to be synchronized, determines and transmits the data to be synchronized between devices, and uses a private protocol for data synchronization, which solves the problems of high number of data synchronization interactions and low efficiency in the existing technology, and achieves high efficiency and Secure data synchronization.
Patent Information
- Application Number
- CN202210682589.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-16
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2042-06-16
AI Technical Summary
In the existing technology, the number of interactions during data synchronization is high, the efficiency is low, and synchronization errors are prone to occur.
Receive the data identification of the device's data to be synchronized through the message pool, pull the synchronization message and compare it based on the data identification to determine the data to be synchronized that needs to be synchronized, establish a data transmission link between devices, and transmit the data to be synchronized using a private protocol. Data synchronization simplifies the synchronization process and improves efficiency.
Synchronization of multiple data can be completed at one time, improving data synchronization efficiency, reducing the number of interactions, reducing the probability of errors, and improving security.
Smart Images

Figure CN115102968B
Abstract
Description
Technical Field
[0001] The present application relates to the field of communications, and in particular to a data synchronization method, device, system and storage medium. Background Art
[0002] Data synchronization is a method to achieve data consistency between two or more devices. Through data synchronization, two or more devices can have the same data, including the same pictures, videos, etc., so as to facilitate the same data processing or display on two or more devices.
[0003] At present, the synchronization method for large data (including pictures, facial feature values, audio, etc.) is mainly based on the http (Hypertext Transfer Protocol) protocol. That is, the server provides the URL (Universal Resource Locator) for picture downloads, and the client initiates an http request to download the picture through the URL. This synchronization method has a large number of interactions, and usually only one picture can be synchronized in one interaction, so the synchronization efficiency is low. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a data synchronization method, device, system and storage medium to solve the problems of high number of interactions, low synchronization efficiency and easy occurrence of synchronization errors when performing data synchronization in the prior art.
[0005] A first aspect of an embodiment of the present application provides a data synchronization method, the data synchronization method being used to synchronize a first device and a second device, the first device and the second device being connected via a message pool, the method comprising:
[0006] The first device and / or the second device sends a synchronization message to the message pool, where the synchronization message includes a data identifier;
[0007] When the second device and / or the first device pulls the synchronization message from the message pool, acquiring the data identifier in the synchronization message;
[0008] The second device determines the data to be synchronized that needs to be synchronized by comparing the data identifiers, establishes a data transmission link between the first device and the second device, and transmits the data to be synchronized.
[0009] In combination with the first aspect, in a first possible implementation manner of the first aspect, the synchronization message also includes a message type, and after the first device and / or the second device sends the synchronization message to the message pool, before the second device and / or the first device pulls the synchronization message from the message pool, the method further includes:
[0010] The message pool merges the synchronization messages according to the message type.
[0011] In combination with the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the message type includes a record type, and a sub-record type under a directory of the record type;
[0012] The message pool performs merging processing on the synchronization messages according to the message type, including:
[0013] When the synchronization messages received by the message pool include synchronization messages with the same record type and record subtype, two or more synchronization messages with the same record type and record subtype are merged into one synchronization message, and the data identifier of the received synchronization message is added to the merged synchronization message.
[0014] In combination with the first possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the message type includes an operation type, and the operation type includes an add operation, a modify operation, and a delete operation;
[0015] According to the message type, the synchronization message is merged and processed, including:
[0016] When the synchronization messages received by the message pool include the same data identifier and the message type is an operation type, a valid synchronization message is determined according to the impact of two or more operation types on the data.
[0017] In combination with the third possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, when the synchronization message received by the message pool includes the same data identifier and the message type is an operation type, determining a valid synchronization message according to the impact of two or more operation types on the data includes:
[0018] When the message types of the synchronization messages with the same data identifier are add operation and delete operation, and both are same-direction messages, the synchronization message with the attribute of add operation is cleared, and the synchronization message with the attribute of delete operation is not saved, or the synchronization message with the attribute of delete operation is cleared, and the synchronization message with the attribute of add operation is not saved;
[0019] When the message types of the synchronization messages with the same data identifier are add operation and modify operation, and they are all same-direction messages, the content of the synchronization message with the attribute of modify operation is added to the synchronization message with the same data identifier and the attribute of add operation, and the synchronization message with the attribute of add operation is not saved;
[0020] When the message types of synchronization messages with the same data identifier are modification operation and deletion operation respectively, the synchronization message with the modification operation attribute is deleted, and the synchronization message with the deletion operation attribute is saved;
[0021] When the message types of the synchronization messages with the same data identifier are all modification operations and are all same-direction messages, the message contents of the synchronization messages with the same data identifier are merged, and the merged message contents are modified into the stored synchronization messages with the attribute of modification operation, and the newly received synchronization messages are not saved;
[0022] When the message types of the synchronization messages with the same data identifiers are all modification operations and are heterodyne messages, the message contents of the synchronization messages with the same data identifiers are merged, and the merged message contents are respectively saved in the heterodyne synchronization messages.
[0023] In combination with the first possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, the message type includes a control type, and the control type includes a full update and a restart message synchronization;
[0024] According to the message type, the synchronization message is merged and processed, including:
[0025] When a synchronization message with the attribute of full update is received, the synchronization messages in the message pool are cleared, no new synchronization messages are received, and the message pool is controlled to enter a full synchronization state;
[0026] When the message pool is fully updated and a message with the attribute of restarting synchronization is received, the synchronization message with the attribute of full synchronization is cleared, and the reception of new incremental messages is allowed again.
[0027] In combination with the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, the fourth possible implementation manner of the first aspect, or the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner of the first aspect, establishing a data transmission link between the first device and the second device, and transmitting the data to be synchronized includes:
[0028] A data transmission link is established between the first device and the second device through a private protocol, and the data to be synchronized is actively pushed through the private protocol.
[0029] In combination with the first aspect, in a seventh possible implementation of the first aspect, the data to be synchronized includes one or more data streams, the data streams include multiple target objects, and the number of target objects in the data streams is the same as the number of target objects in the data to be synchronized.
[0030] A second aspect of an embodiment of the present application provides a data synchronization method, the data synchronization method is used to synchronize a first device and a second device, the first device and the second device are connected through a message pool, the method comprising:
[0031] Receiving a synchronization message sent by the first device and / or the second device, wherein the synchronization message includes a data identifier;
[0032] When a synchronization request from a second device to pull the synchronization message is received, the data identifier in the received synchronization message is sent to the second device, and the data identifier is used to compare the data identifier of the second device and / or the first device with the data identifier of the synchronization message in the message pool, determine the data to be synchronized, establish a data transmission link between the first device and the second device, and transmit the data to be synchronized.
[0033] A third aspect of an embodiment of the present application provides a data synchronization device, the data synchronization device is used to synchronize a first device and a second device, the first device and the second device are connected through a message pool, and the device includes:
[0034] A synchronization message sending unit, configured to send a synchronization message from the first device and / or the second device to the message pool, wherein the synchronization message includes a data identifier;
[0035] a data identification acquisition unit, configured to acquire the data identification in the synchronization message when the second device and / or the first device pulls the synchronization message from the message pool;
[0036] A data synchronization unit is used to compare the data identifier of the second device and / or the first device with the data identifier of the synchronization message in the message pool, determine the data to be synchronized, establish a data transmission link between the first device and the second device, and transmit the data to be synchronized.
[0037] A third aspect of an embodiment of the present application provides a data synchronization system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any method described in the first aspect when executing the computer program.
[0038] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of the first aspects are implemented.
[0039] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application receive the data identifier of the data to be synchronized of the first device through the message pool, pull the synchronization message on the second device, and send the data identifier to the second device, so that the second device determines the data to be synchronized that needs to be synchronized based on the comparison of the data identifier, and transmits the data to be synchronized by establishing a data transmission link between the first device and the second device. Compared with the synchronization method based on the http protocol, the present application can simplify the process of data synchronization between the first device and the second device, and can complete the synchronization of multiple pictures and other data at one time, which is conducive to improving data synchronization efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0041] Figure 1 It is a schematic diagram of an implementation scenario of a data synchronization method provided in an embodiment of the present application;
[0042] Figure 2 It is a schematic diagram of an implementation flow of a data synchronization method provided in an embodiment of the present application;
[0043] Figure 3 is a schematic diagram of a data synchronization device provided in an embodiment of the present application;
[0044] Figure 4 It is a schematic diagram of a data synchronization system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0046] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.
[0047] Figure 1 The following is a schematic diagram of an implementation scenario of a data synchronization method provided in an embodiment of the present application. Figure 1 As shown, the implementation scenario includes a first device, a second device and a message pool. The first device and the second device have data receiving and sending capabilities and data storage capabilities. The message pool is not limited to a specific form, and can be an independent server or set in any device for synchronization. The message pool serves as a transfer station for data information, and can assist the first device and the second device in data synchronization.
[0048] In the embodiment of the present application, the first device and the second device for synchronization can be used for bidirectional synchronization, that is, data synchronization from the first device to the second device and data synchronization from the second device to the first device can be achieved. Based on the bidirectional synchronization protocol, data synchronization between the first device and the second device is achieved. The data synchronization from the second device to the first device is basically the same as the process of data synchronization from the first device to the second device.
[0049] In the possible implementation of the present application, an implementation scenario in which a system synchronizes data with multiple devices may also be included. That is, a system (first device) is connected to multiple devices (second device), and a device can only be connected to a single system. Binding a single system to multiple devices can effectively avoid the problem of data confusion introduced by accessing multiple systems. When the device is connected to the system, the two negotiate to determine the IP address of the message pool, the message subject, the transmission protocol, etc., and can immediately perform a full synchronization of the device. Thereafter, whether the modification is performed on the system side or on the device side, an incremental synchronization message can be sent to the message pool in accordance with the message format specified in this solution, and the message pool can perform certain merging processing on the incremental synchronization message. When the device side or the system side pulls the incremental message, the data identifier of the data to be synchronized is obtained from the message pool, compared with the data identifier of the local data, the identifier of the data to be synchronized that needs to be synchronized is determined, and a data link for synchronizing the data is established for data synchronization.
[0050] Figure 2 A schematic diagram of an implementation flow of a data synchronization method provided in an embodiment of the present application, wherein the synchronization method is used as follows: Figure 1 The first device and the second device shown are connected via a message pool, such as Figure 2 As shown, the method includes:
[0051] In S201, the first device and / or the second device sends a synchronization message to the message pool, where the synchronization message includes a data identifier.
[0052] In an embodiment of the present application, according to the first device and the second device connected to the message pool, the first device can send synchronization data to the second device, and the second device can also send synchronization data to the first device. The first device or the second device can send two or more synchronization messages to the message pool. If the senders of two or more synchronization messages are the same, it means that the two or more synchronization messages are same-direction messages. For example, if two or more synchronization messages are both sent to the message pool by the first device, the two or more synchronization messages are same-direction messages. Correspondingly, if the senders of the two synchronization messages are different, such as one synchronization message is sent by the first device and the other synchronization message is sent by the second device, it means that the two synchronization messages are different-direction messages or different-direction synchronization messages.
[0053] Among them, when the first device and / or the second device sends a synchronization message to the message pool, including when the first device and / or the second device is connected to the data synchronization system, or incremental data appears in the first device and / or the second device, such as pictures and facial features are added to the first device and / or the second device waiting for synchronization data.
[0054] Before synchronizing the data, the first device and / or the second device first mark the data to be synchronized in the first device and / or the second device to determine the data identifier of the data to be synchronized in the first device and / or the second device. The data identifier is used to globally uniquely identify the data. The data identifier can be determined by an encryption algorithm such as a hash calculation.
[0055] In an embodiment of the present application, when the first device and / or the second device synchronizes data to other devices, it may first send the data identifier of the data to be synchronized, so that the message pool can obtain one or more data identifiers of the data to be synchronized through a smaller amount of data between the first device and / or the second device.
[0056] In S202, when the second device and / or the first device pulls the synchronization message from the message pool, the data identifier in the synchronization message is obtained.
[0057] When the message pool is connected to the first device and the second device, the synchronization message received by the message pool may include the synchronization message sent by the first device, the synchronization message sent by the second device, or the synchronization message sent by the first device and the second device. When pulling the synchronization message, it may include the first device pulling the synchronization message, the second device pulling the synchronization message, or the first device and the second device pulling the synchronization message.
[0058] Before the second device and / or the first device pulls the synchronization message from the message pool, the message pool can merge the synchronization messages according to the type of the received messages. For example, several or dozens of synchronization messages can be merged into one synchronization message. When the second device and / or the first device pulls the synchronization message, unnecessary redundant messages in the message pool can be reduced, thereby reducing the workload of the second device that needs to be synchronized.
[0059] The internal structure of the message pool can adopt the Reactor mode, including a receiving thread group (Acceptor) and a processing thread group (Handler). The receiving thread group is used to monitor the network connection and generate a unique message identifier (MSGID) for the received message, which is then handed over to the processing thread group for subsequent processing, including merging the identified synchronous messages, maintaining the message list and persisting the synchronous messages, etc.
[0060] When merging synchronization messages, the synchronization messages can be merged according to the message type, thereby eliminating redundant synchronization messages in the message pool as much as possible and preventing the same attribute from being modified multiple times. Therefore, before merging synchronization messages, the type of synchronization message can be determined first. The type of synchronization message can be determined based on the predetermined correspondence between the synchronization message and the type. The determined type of synchronization message can include a record type, an operation type, a control type, and the like.
[0061] For each type of synchronization message, it can include a first-level message type (fixed) and a second-level message type (optional). Among them, the first-level message type can be fixed by the protocol, and each system or device can only use the first-level message type specified by the protocol. The second-level message type is designed to provide expansion and adaptation for each system or device, and the system or device can define its own message content. Therefore, the merging of synchronization messages can be based on the first-level message type.
[0062] Among them, record messages can contain the first-level message type "record", which can represent all immutable records, including face capture records, attendance records, vehicle entry records, etc.
[0063] Operation messages include three types of messages for variable data: add, modify, and delete, which represent the operations of adding, modifying, and deleting data respectively.
[0064] Control messages are more targeted at the message synchronization process itself. The plan includes first-level message types such as full synchronization, stop synchronization, restart, and connect, which respectively mean that a full synchronization of data is required, message synchronization needs to be stopped, message synchronization needs to be restarted, and the connection method needs to be negotiated.
[0065] In the embodiment of the present application, the message may include a field representing the message propagation direction, which is used to distinguish which device the message is transmitted from, or may include a message subject field, which can be used to identify which subject the message belongs to.
[0066] When merging synchronous messages, the embodiment of the present application can establish a quick lookup table based on a key-value pair mapping table, using the message type and subject as the first-level key. For record and control messages, the first-level value is the actual value. For operation messages, the unique message identifier can be used as the second-level key, and its value is the incremental data that will eventually take effect; after receiving the message, the processing thread group in the message pool will scan the quick lookup table, merge the messages that meet the merge type, and update the quick lookup table.
[0067] The message merging in the embodiment of the present application may include merging of synchronization messages of the record type, merging of synchronization messages of the operation type, and merging of messages of the control type. Among them:
[0068] 1. Merging of record messages.
[0069] It can include record-record type. When the first-level message type is record, the subject of the synchronization message is the same, and the second-level message type is a sub-record type under the record type, it is considered that the two synchronization messages can be merged. The result of the merger is to add a record message to the value of the entry to record the data identifier that needs to be synchronized, and then batches will be synchronized at one time.
[0070] 2. Merging of operation messages.
[0071] 2.1 Add-Delete type. This type will only appear in the same-direction message. It is triggered when the first-level message received is a delete message and there is an operation type message with the same data identifier. The result of the merge is to clear the existing add message and the newly added delete message will not be saved.
[0072] 2.2. Add-Modify type. This type will only appear in the same-direction message. If the first-level message type is modified and there is an add message with the same data identifier, the two will be merged. The result is to modify the field attributes in the add message and change it to the attributes of the modified content. The newly added "modify" message will not be saved.
[0073] 2.3. Modify-Delete type. This message type is not limited in direction and is applicable to the following operations: If a delete type message is received and there is a modify message with the same data identifier, the merged structure is to delete the "modify" message and retain the "delete" message.
[0074] 2.4. Modification-Modification type. When a modification type message, i.e., a modification message, is received, if there are modification messages with the same data identifier and in the same direction, the message contents of the two are merged and modified into the existing "modification" message, and the new "modification" message is not retained; but if there are "modification" messages with the same data identifier but in different directions, the contents of the two messages need to be merged and the merged message contents are saved in two different-direction synchronization messages respectively.
[0075] 3. Merging of control messages.
[0076] 3.1. Full update type. When a full update type message is received, all quick lookup tables are directly cleared, and no new messages are received, entering a state of waiting for full synchronization.
[0077] 3.2. Restart type. When the full synchronization is completed, the party receiving the data is responsible for sending a "restart" type message to the message pool. At this time, the "full update" type message can be eliminated and the reception of new incremental messages can be allowed again.
[0078] In S203, the data identifier of the second device and / or the first device is compared with the data identifier of the synchronization message in the message pool to determine the data to be synchronized, a data transmission link is established between the first device and the second device, and the data to be synchronized is transmitted.
[0079] When the second device and / or the first device pulls data, the data processed by the message pool can be obtained. Since the message pool can merge the received synchronization messages, it can effectively remove redundant synchronization messages, greatly reduce the number of interactions for data synchronization, shorten the process, and reduce the probability of errors. In addition, the present application can perform matching and data transmission based on a private protocol, which can improve the security of data synchronization. The present application processes synchronization messages and synchronization data separately. When the second device and / or the first device pulls data, it can obtain multiple data identifiers to be synchronized at one time, so that the second device and / or the first device can efficiently obtain multiple synchronized data through the data transmission link, which is conducive to simplifying the synchronization process and improving data synchronization efficiency.
[0080] The data link established between the first device and the second device may be a direct data link or an indirect data link. The data link may be established by a data transmission link based on a private protocol, and the device that needs to be synchronized may actively push data based on the data transmission link. According to the private protocol, the synchronization operation can complete the synchronization of multiple types of data (including pictures, videos, and audio, etc.) in one interaction. Not limited to this, it may also include data links established by other communication protocols. When establishing an indirect data link, the data that needs to be synchronized may be forwarded through the message pool.
[0081] The private protocol can be privately expanded based on the RTSP protocol. Compared with the current interaction mode of the http protocol, the number of interactions is less, the process is shorter, and the probability of error is lower. Compared with the RFC standard protocol, the risk of being deciphered is relatively smaller and the security is higher based on the private protocol. By adopting the format of intelligent data, multiple segments of different types of data, including pictures, videos, and audio, can be intelligently identified and transmitted. Based on the identified data type, the attribute information corresponding to the data type can be determined, thereby customizing to meet different types of data transmission requirements. In the same system involving NVR, IPC and other devices, by using private protocols, the system can better maintain integrity.
[0082] In addition, the data stream of the private protocol described in the embodiment of the present application can transmit multiple target objects (such as different types of target objects or multiple target objects of the same type, etc.) at its top level, that is, a data stream includes a data stream header and one or more target objects, and the number of target objects in the data stream is the same as the number of target objects in the data to be synchronized, thereby reducing the number of interactions when multiple target objects are transmitted. The format of the private protocol can be TLV (the full name in English is type-length-value, and the full name in Chinese is type length value) format, so that the private protocol has good scalability and is convenient for adding properties of new target objects. That is, the data length of information such as data stream, target object, and attribute can be defined by the length identifier in the TLV format. Based on the defined data length, it is convenient to completely determine the specific information of the data stream, target object or attribute. And when the specific information changes, the defined data length can be adjusted accordingly. Based on the private protocol format, the requirements of multi-segment data synchronization can be effectively met and the efficiency of data interaction can be improved.
[0083] The data link directly established includes data links based on HTTP and FTP protocols. Not limited to this, a data link based on a message pool can also be established, that is, a data link is indirectly established through a message pool. Alternatively, the present application can also calculate data identifiers based on a message pool, compare data identifiers through the message pool, determine the synchronization data that needs to be sent to the second device, and merge synchronization messages through the message pool.
[0084] It can be understood that when the execution subject is a message pool, the synchronization method can receive a synchronization message sent by the first device and / or the second device through the message pool, and the synchronization message includes a data identifier; when a synchronization request is received from the second device and / or the first device to pull the synchronization message, the data identifier of the second device and / or the first device is compared with the data identifier of the synchronization message in the message pool to determine the data to be synchronized, so as to establish a data transmission link between the first device and the second device and transmit the data to be synchronized. Figure 2 The synchronization method shown corresponds to .
[0085] The data synchronized in the embodiments of the present application may include photos, facial features, fingerprint features and other data.
[0086] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0087] Figure 3 A schematic diagram of the structure of a data synchronization device according to an embodiment of the present application is shown in FIG. Figure 3 As shown, the device comprises:
[0088] A synchronization message sending unit 301, configured to send a synchronization message from the first device and / or the second device to the message pool, wherein the synchronization message includes a data identifier;
[0089] A data identifier acquisition unit 302, configured to acquire a data identifier in the synchronization message when the second device and / or the first device pulls the synchronization message from the message pool;
[0090] The data synchronization unit 303 is used to compare the data identifier of the second device and / or the first device with the data identifier of the synchronization message in the message pool, determine the data to be synchronized, establish a data transmission link between the first device and the second device, and transmit the data to be synchronized.
[0091] Figure 3 The data synchronization device shown, and Figure 2 The data synchronization method shown corresponds to.
[0092] Figure 4 Schematic diagram of a data synchronization system provided by an embodiment of the present application. Figure 4As shown, the data synchronization system 4 of this embodiment includes: a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40, such as a data synchronization program. When the processor 40 executes the computer program 42, the steps in the above-mentioned data synchronization method embodiments are implemented. Alternatively, when the processor 40 executes the computer program 42, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0093] Exemplarily, the computer program 42 may be divided into one or more modules / units, which are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 42 in the data synchronization system 4.
[0094] The data synchronization system may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Figure 4 It is only an example of the data synchronization system 4 and does not constitute a limitation of the data synchronization system 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the data synchronization system may also include input and output devices, network access devices, buses, etc.
[0095] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0096] The memory 41 may be an internal storage unit of the data synchronization system 4, such as a hard disk or memory of the data synchronization system 4. The memory 41 may also be an external storage device of the data synchronization system 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the data synchronization system 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the data synchronization system 4. The memory 41 is used to store the computer program and other programs and data required by the data synchronization system. The memory 41 may also be used to temporarily store data that has been output or is to be output.
[0097] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0098] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0099] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0100] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0101] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0102] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0103] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by hardware related to computer program instructions. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0104] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data synchronization method, characterized in that: The data synchronization method is used to synchronize a first device with a second device, wherein the first device and the second device are connected via a message pool, and the method includes: When incremental data appears in the first device and / or the second device, the first device and / or the second device sends a synchronization message to the message pool, where the synchronization message includes a data identifier, and the data identifier is used to globally uniquely identify the data; When the message types of the synchronization messages with the same data identifier are all modification operations and are all same-direction messages, the message contents of the synchronization messages with the same data identifier are merged, and the merged message contents are modified to the stored synchronization messages with the attribute of modification operation, and the newly received synchronization messages are not saved, and the same-direction messages are synchronization messages with the same sender; When the message types of the synchronization messages with the same data identifiers are all modification operations and are heterogeneous messages, the message contents of the synchronization messages with the same data identifiers are merged, and the merged message contents are respectively saved in heterogeneous synchronization messages, and the heterogeneous messages are synchronization messages with different senders; When the second device and / or the first device pulls the synchronization message from the message pool, acquiring the data identifier in the synchronization message in the message pool; Compare the data identifier of the second device and / or the first device with the data identifier of the synchronization message in the message pool, determine the data to be synchronized, establish a data transmission link between the first device and the second device, and transmit the data to be synchronized.
2. The method according to claim 1, characterized in that The synchronization message also includes a message type. After the first device and / or the second device sends the synchronization message to the message pool and before the second device and / or the first device pulls the synchronization message from the message pool, the method further includes: The message pool merges the synchronization messages according to the message type.
3. The method according to claim 2, characterized in that The message type includes a record type and a sub-record type under the directory of the record type; The message pool performs merging processing on the synchronization messages according to the message type, including: When the synchronization messages received by the message pool include synchronization messages with the same record type and record subtype, two or more synchronization messages with the same record type and record subtype are merged into one synchronization message, and the data identifier of the received synchronization message is added to the merged synchronization message.
4. The method according to claim 2, characterized in that: The message type includes an operation type, and the operation type includes an add operation, a modify operation, and a delete operation; According to the message type, the synchronization message is merged and processed, including: When the synchronization messages received by the message pool include the same data identifier and the message type is an operation type, a valid synchronization message is determined according to the impact of two or more operation types on the data.
5. The method according to claim 4, characterized in that When the synchronization messages received by the message pool include the same data identifier and the message type is an operation type, a valid synchronization message is determined based on the impact of two or more operation types on the data, including: When the message types of the synchronization messages with the same data identifier are add operation and delete operation, and both are same-direction messages, the synchronization message with the attribute of add operation is cleared, and the synchronization message with the attribute of delete operation is not saved, or the synchronization message with the attribute of delete operation is cleared, and the synchronization message with the attribute of add operation is not saved; When the message types of the synchronization messages with the same data identifier are add operation and modify operation, and they are all same-direction messages, the content of the synchronization message with the attribute of modify operation is added to the synchronization message with the same data identifier and the attribute of add operation, and the synchronization message with the attribute of add operation is not saved; When the message types of the synchronization messages with the same data identifier are modification operation and deletion operation respectively, the synchronization message with the deletion attribute being the modification operation is deleted, and the synchronization message with the preservation attribute being the deletion operation is saved.
6. The method according to claim 2, characterized in that The message type includes a control type, and the control type includes a full update and a restart message synchronization; According to the message type, the synchronization message is merged and processed, including: When a synchronization message with the attribute of full update is received, the synchronization messages in the message pool are cleared, no new synchronization messages are received, and the message pool is controlled to enter a full synchronization state; When the message pool is fully updated and a message with the attribute of restarting synchronization is received, the synchronization message with the attribute of full synchronization is cleared, and the reception of new incremental messages is allowed again.
7. The method according to any one of claims 1 to 6, characterized in that: Establishing a data transmission link between the first device and the second device to transmit the data to be synchronized includes: A data transmission link is established between the first device and the second device through a private protocol, and the data to be synchronized is actively pushed through the private protocol.
8. The method according to claim 7, characterized in that The data to be synchronized includes one or more data streams, the data streams include multiple target objects, and the number of the target objects in the data streams is the same as the number of the target objects in the data to be synchronized.
9. A data synchronization method, characterized in that: The data synchronization method is used to synchronize a first device with a second device, wherein the first device and the second device are connected via a message pool, and the method includes: When incremental data appears in the first device and / or the second device, receiving a synchronization message sent by the first device and / or the second device, the synchronization message including a data identifier, and the data identifier is used to globally uniquely identify the data; When the message types of the synchronization messages with the same data identifier are all modification operations and are all same-direction messages, the message contents of the synchronization messages with the same data identifier are merged, and the merged message contents are modified to the stored synchronization messages with the attribute of modification operation, and the newly received synchronization messages are not saved, and the same-direction messages are synchronization messages with the same sender; When the message types of the synchronization messages with the same data identifiers are all modification operations and are heterogeneous messages, the message contents of the synchronization messages with the same data identifiers are merged, and the merged message contents are respectively saved in heterogeneous synchronization messages, and the heterogeneous messages are synchronization messages with different senders; When a synchronization request from the second device to pull the synchronization message is received, the data identifier of the second device and / or the first device is compared with the data identifier of the synchronization message in the message pool to determine the data to be synchronized, so as to establish a data transmission link between the first device and the second device and transmit the data to be synchronized.
10. A data synchronization device, characterized in that: The data synchronization device is used to synchronize a first device with a second device, the first device and the second device are connected via a message pool, and the device includes: A synchronization message sending unit, used for, when incremental data appears in the first device and / or the second device, the first device and / or the second device sends a synchronization message of the data to be synchronized to the message pool, the synchronization message includes a data identifier, the data identifier is used to globally uniquely identify the data, when the message types of the synchronization messages with the same data identifier are all modification operations, and they are all same-direction messages, then the message contents of the synchronization messages with the same data identifier are merged, and the merged message contents are modified to the stored synchronization messages with the attribute of the modification operation, the newly received synchronization messages are not saved, and the same-direction messages are synchronization messages with the same sender; when the message types of the synchronization messages with the same data identifier are all modification operations, and they are different-direction messages, then the message contents of the synchronization messages with the same data identifier are merged, and the merged message contents are respectively saved in different-direction synchronization messages, and the different-direction messages are synchronization messages with different senders; a data identification acquisition unit, configured to acquire the data identification in the synchronization message when the second device and / or the first device pulls the synchronization message in the message pool from the message pool; A data synchronization unit is used to compare the data identifier of the second device and / or the first device with the data identifier of the synchronization message in the message pool, determine the data to be synchronized, establish a data transmission link between the first device and the second device, and transmit the data to be synchronized.
11. A data synchronization system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Data synchronization method and device
CN104168335A
Data synchronization method, device and system
CN104184756A
Data synchronization method and terminal
CN112612799A
