CN113133107B - Method and device for synchronizing information - Google Patents

Method and device for synchronizing information Download PDF

Info

Publication number
CN113133107B
CN113133107B CN201911397616.6A CN201911397616A CN113133107B CN 113133107 B CN113133107 B CN 113133107B CN 201911397616 A CN201911397616 A CN 201911397616A CN 113133107 B CN113133107 B CN 113133107B
Authority
CN
China
Prior art keywords
information
synchronized
data packet
data
packet
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.)
Active
Application number
CN201911397616.6A
Other languages
Chinese (zh)
Other versions
CN113133107A (en
Inventor
孙名世
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201911397616.6A priority Critical patent/CN113133107B/en
Publication of CN113133107A publication Critical patent/CN113133107A/en
Application granted granted Critical
Publication of CN113133107B publication Critical patent/CN113133107B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W56/00Synchronisation arrangements
    • H04W56/001Synchronization between nodes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The embodiment of the disclosure discloses a method and a device for synchronizing information, and relates to the field of cloud computing. One embodiment of the method comprises: in response to the detection of the information to be synchronized, packaging the information to be synchronized into a data packet to be synchronized; sending the data packet to be synchronized to a node to be synchronized through a user data protocol; and responding to the received feedback information sent by the node to be synchronized, and completing information synchronization according to the feedback information. The implementation mode reduces the data processing amount of the nodes, simplifies the information synchronization process and improves the effectiveness of the information synchronization.

Description

Method and device for synchronizing information
Technical Field
The embodiment of the disclosure relates to the technical field of cloud computing, in particular to a method and a device for synchronizing information.
Background
The same state information or configuration is generally maintained between different nodes (physical machines) deployed in the same network partition, so as to ensure stability and accuracy of externally provided services. Under the scene of large service request flow and high concurrency, how to stabilize and synchronize the information state between nodes is an important part for continuously optimizing service and excavating performance.
When synchronizing information states or configurations between nodes, multiple handshaking operations need to be established between the nodes to establish a communication connection. And then, the nodes need to be kept in communication connection for a long time in a heartbeat monitoring mode and other modes so as to ensure that synchronization is carried out smoothly.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for synchronizing information.
In a first aspect, an embodiment of the present disclosure provides a method for synchronizing information, the method including: in response to the detection of the information to be synchronized, packaging the information to be synchronized into a data packet to be synchronized; sending the data packet to be synchronized to a node to be synchronized through a user data protocol; and responding to the received feedback information sent by the node to be synchronized, and completing information synchronization according to the feedback information.
In some embodiments, the encapsulating the information to be synchronized into a data packet to be synchronized includes: inquiring the data volume of the information to be synchronized; in response to the fact that the data volume is larger than a set threshold value, dividing the information to be synchronized into at least one piece of sub information to be synchronized; and for the sub-information to be synchronized in the at least one piece of sub-information to be synchronized, packaging the sub-information to be synchronized into a sub-data packet to be synchronized.
In some embodiments, the encapsulating the sub-to-be-synchronized information into a sub-to-be-synchronized data packet includes: compressing the sub information to be synchronized into a data compression packet, and setting data packet information for the sub information to be synchronized, wherein the data packet information comprises data packet sending state information and data volume information of the data compression packet; and packaging the data compression packet and the data packet information into a sub data packet to be synchronized.
In some embodiments, the completing information synchronization according to the feedback information includes: responding to the successful transmission of the feedback information, and finishing the information synchronization operation; and in response to the feedback information being transmission failure, retransmitting the data packet to be synchronized.
In a second aspect, an embodiment of the present disclosure provides a method for synchronizing information, the method including: in response to receiving a data packet to be synchronized sent by a synchronization node, analyzing the data packet to be synchronized to obtain analysis information; and constructing feedback information through the analysis information, and sending the feedback information to the synchronization node.
In some embodiments, the analyzing the data packet to be synchronized to obtain analysis information includes: analyzing a data compression packet and data packet information from the data packet to be synchronized, wherein the data packet information comprises data packet sending state information and data volume information of the data compression packet; responding to that the data volume information in the data packet information is the same as the data volume of the data compression packet, the analysis result is correct information transmission, and decompressing from the data compression packet to obtain the information to be synchronized, otherwise, the analysis result is an information transmission error, wherein the information transmission error comprises any one of the following items: retry, empty packet, incomplete, repeat, failure.
In some embodiments, the constructing the feedback information by the parsing information includes: in response to the analysis result that the information transmission is correct, the data packet sending state information is modified into first data packet receiving state information with successful transmission content, and first feedback information is constructed according to the first data packet receiving state information; and in response to the analysis result being an information transmission error, modifying the data packet sending state information into second data packet receiving state information with the content being transmission failure, and constructing second feedback information according to the second data packet receiving state information.
In a third aspect, an embodiment of the present disclosure provides an apparatus for synchronizing information, the apparatus including: a data packet packaging unit, which is used for responding to the detection of the information to be synchronized and is configured to package the information to be synchronized into a data packet to be synchronized; the data sending unit is configured to send the data packet to be synchronized to a node to be synchronized through a user data protocol; and the information synchronization operation unit is used for responding to the received feedback information sent by the node to be synchronized and completing information synchronization according to the feedback information.
In some embodiments, the data packet encapsulation unit includes: a data size query subunit configured to query the data size of the information to be synchronized; a data dividing subunit, configured to divide the information to be synchronized into at least one piece of sub-information to be synchronized, in response to the data amount being greater than a set threshold; and the data packet packaging subunit is configured to, for the sub-to-be-synchronized information in the at least one piece of sub-to-be-synchronized information, package the sub-to-be-synchronized information into a sub-to-be-synchronized data packet.
In some embodiments, the packet encapsulation subunit includes: a compression module configured to compress the sub information to be synchronized into a data compression packet, and set data packet information for the sub information to be synchronized, wherein the data packet information includes data packet transmission status information and data volume information of the data compression packet; and the data packet packaging module is configured to package the data compression packet and the data packet information into a sub data packet to be synchronized.
In some embodiments, the information synchronization operation unit includes: a first information synchronization operation subunit, configured to complete the information synchronization operation in response to the feedback information being a transmission success; and the second information synchronization operation subunit is configured to resend the data packet to be synchronized in response to the feedback information being a transmission failure.
In a fourth aspect, an embodiment of the present disclosure provides an apparatus for synchronizing information, the apparatus including: the data packet analysis unit is used for responding to the received data packet to be synchronized sent by the synchronization node and analyzing the data packet to be synchronized to obtain analysis information; and a feedback information sending unit configured to construct feedback information through the analysis information and send the feedback information to the synchronization node.
In some embodiments, the packet parsing unit includes: the data packet analysis subunit is configured to analyze a data compression packet and data packet information from the data packet to be synchronized, wherein the data packet information comprises data packet sending state information and data volume information of the data compression packet; the analysis information acquisition subunit is configured to respond to that the data volume information in the data packet information is the same as the data volume of the data compression packet, the analysis result is that the information transmission is correct, and the information to be synchronized is obtained by decompressing from the data compression packet, otherwise, the analysis result is that the information transmission is wrong, wherein the information transmission error comprises any one of the following items: retry, empty packet, incomplete, repeat, failure.
In some embodiments, the feedback information sending unit includes: a first feedback information construction subunit, configured to modify, in response to the result of the analysis indicating that the information transmission is correct, the transmission status information of the data packet to first data packet reception status information whose content is successful in transmission, and construct first feedback information according to the first data packet reception status information; and the second feedback information construction subunit, in response to the analysis result being an information transmission error, is configured to modify the data packet sending state information into second data packet receiving state information with transmission failure, and construct second feedback information according to the second data packet receiving state information.
In a fifth aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; a memory having one or more programs stored thereon, which when executed by the one or more processors, cause the one or more processors to perform the method for synchronizing information of the first aspect or the method for synchronizing information of the second aspect.
In a sixth aspect, an embodiment of the present disclosure provides a computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method for synchronizing information of the first aspect or the method for synchronizing information of the second aspect.
According to the method and the device for synchronizing the information, firstly, when the information to be synchronized is detected, the information to be synchronized is packaged into a data packet to be synchronized; then, the data packet to be synchronized is sent to a node to be synchronized through a user data protocol; and finally, when receiving the feedback information sent by the node to be synchronized, completing information synchronization according to the feedback information. According to the method and the device, information transmission is carried out through the user data protocol when information synchronization is needed, the nodes do not need to be in communication connection for a long time through heartbeat detection, and the problems of information concurrency and the like do not need to be considered. Therefore, the data processing amount of the nodes is reduced, the information synchronization process is simplified, and the effectiveness of the information synchronization is improved.
Drawings
Other features, objects and advantages of the present disclosure will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of a method for synchronizing information, according to the present disclosure;
FIG. 3 is a flow diagram of another embodiment of a method for synchronizing information according to the present disclosure;
FIG. 4 is a schematic diagram of one application scenario of a method for synchronizing information according to the present disclosure;
FIG. 5 is a schematic diagram illustrating one embodiment of an apparatus for synchronizing information according to the present disclosure;
FIG. 6 is a schematic block diagram illustrating another embodiment of an apparatus for synchronizing information according to the present disclosure;
FIG. 7 is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and the features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 of a method for synchronizing information or an apparatus for synchronizing information to which embodiments of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include nodes to be synchronized 101, 102, a network 103, and a synchronization node 104. The network 103 serves to provide a medium for communication links between the nodes 101, 102 to be synchronized and the synchronization node 104. Network 103 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few. Wherein, the nodes to be synchronized 101 and 102 and the synchronization node 104 belong to the same network partition.
The nodes to be synchronized 101, 102 may interact with the synchronization node 104 via the network 103 to receive or send messages or the like. The nodes 101 and 102 to be synchronized may be hardware or software. When the nodes 101, 102 to be synchronized are hardware, they may be various electronic devices having data processing functions, including but not limited to tablet computers, laptop portable computers, desktop computers, and the like. When the nodes 101, 102 to be synchronized are software, they can be installed in the electronic devices listed above. It may be implemented as a plurality of software or software modules (for example, to provide distributed services), or may be implemented as a single software or software module, which is not specifically limited herein.
The synchronization node 104 may be a server providing various services, such as a server interacting with the user's terminal device and supporting synchronization with the nodes 101, 102 to be synchronized. The server can analyze and process the received data such as the data processing request sent by the terminal equipment, and feed back the processing result to the terminal equipment. When synchronization with the nodes 101 and 102 to be synchronized is required, synchronizing the information to be synchronized to the nodes 101 and 102 to be synchronized.
It should be noted that the method for synchronizing information provided by the embodiment of the present disclosure may be performed by the synchronization node 104 alone, or may also be performed by the synchronization node 104 and the nodes to be synchronized 101 and 102 together. Accordingly, the means for synchronizing information may be provided in the synchronization node 104, as well as in the nodes 101, 102 to be synchronized.
It should be noted that the nodes to be synchronized 101 and 102 and the synchronization node 104 may be hardware or software. When the nodes 101 and 102 to be synchronized and the synchronization node 104 are hardware, they may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the nodes 101, 102 to be synchronized and the synchronization node 104 are software, they may be implemented as a plurality of software or software modules (for example, to provide distributed services), or may be implemented as a single software or software module, and are not limited in this respect.
It should be understood that the number of nodes to be synchronized, the network and the synchronization nodes in fig. 1 are merely illustrative. There may be any number of nodes, networks and synchronization nodes to be synchronized, as desired for the implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for synchronizing information in accordance with the present disclosure is shown. The method for synchronizing information includes the steps of:
step 201, in response to detecting the information to be synchronized, encapsulating the information to be synchronized into a data packet to be synchronized.
In the present embodiment, an execution subject of the method for synchronizing information (e.g., the synchronization node 104 shown in fig. 1) may detect that information to be synchronized is detected through a wired connection manner or a wireless connection manner. It is noted that the wireless connection means may include, but is not limited to, a 3G/4G connection, a WiFi connection, a bluetooth connection, a WiMAX connection, a Zigbee connection, a UWB (Ultra Wideband) connection, and other wireless connection means now known or developed in the future.
In the prior art, when a node synchronizes information, multiple handshaking operations are required to establish communication connection. Thereafter, whether or not synchronization information is required, it is necessary to monitor whether or not the communication connection is normal by heartbeat. Therefore, the node has more operations when synchronizing the information, and the synchronization time is increased. The nodes need heartbeat for a long time to monitor the connection state, and the data processing burden of the nodes is increased.
When the information to be synchronized which needs to be synchronized is detected, the information to be synchronized can be firstly packaged into a data packet to be synchronized. The information to be synchronized may be node configuration information, state information, user data saved on the node by the user, and the like, and may be determined specifically according to actual needs.
In some optional implementation manners of this embodiment, the encapsulating the information to be synchronized into a data packet to be synchronized may include the following steps:
and step one, inquiring the data volume of the information to be synchronized.
In the process of synchronizing information, the data size of the synchronizing information is needed, so that the information to be synchronized can be successfully synchronized to the node to be synchronized.
And secondly, in response to the fact that the data volume is larger than a set threshold value, dividing the information to be synchronized into at least one piece of sub information to be synchronized.
When the data size of the information to be synchronized is smaller than the set threshold, the information to be synchronized can be considered to be successfully synchronized to the node to be synchronized at one time, and at this time, the execution main body can directly package the information to be synchronized into a data packet to be synchronized. When the data size of the information to be synchronized is larger than the set threshold, errors are easy to occur in the synchronization layer. To this end, the execution body may divide the information to be synchronized into at least one piece of sub-information to be synchronized. Wherein, each sub-information to be synchronized needs to set a threshold.
And thirdly, packaging the sub information to be synchronized into a sub data packet to be synchronized for the sub information to be synchronized in the at least one sub information to be synchronized.
After the sub-to-be-synchronized information is obtained, the execution main body may encapsulate each piece of to-be-synchronized information into a sub-to-be-synchronized data packet.
In some optional implementation manners of this embodiment, the encapsulating the sub-to-be-synchronized information into a sub-to-be-synchronized data packet may include the following steps:
the first step, compress the sub-information to be synchronized into data compression packet, and set data packet information for the sub-information to be synchronized.
In the process of synchronizing information, information loss may occur due to various interferences, and in order to enable the node to be synchronized to know whether information loss exists in the received data packet to be synchronized, the execution main body may set data packet information for the sub information to be synchronized. The data packet information includes data packet transmission state information and data volume information of the data compression packet. And the data packet sending state information is used for representing the state information of the sent sub information to be synchronized. The status information may be any one of: normal, empty, ignore, etc. Correspondingly, the packet transmission status information may be "110", "010", "100", and the like.
The packet information may be represented by a bit data sequence. For example, the packet information may be: "1101001100110101". Wherein, the first three bits "110" may indicate that the data packet transmission status information is "normal"; the 4 th to 7 th bits "1001" may indicate that the data size information of the data compression packet is the data size corresponding to the next 9 bits (i.e., "100110101").
And step two, packaging the data compression packet and the data packet information into a sub-packet to be synchronized.
And after the data packet information is obtained, packaging the data packet information and the data compression packet together into a sub-data packet to be synchronized. When the data volume of the information to be synchronized is smaller than the set threshold, the data packet information also needs to be set, and the data packet to be synchronized is obtained at this time.
Step 202, sending the data packet to be synchronized to a node to be synchronized through a user data protocol.
When the user data protocol transmits data, the long-time communication connection between a data transmitting party and a data receiving party is not required, and only a data packet to be synchronized needs to be transmitted to a node to be synchronized at the same time as information. In the embodiment, the data packet to be synchronized is sent through the user data protocol, so that a plurality of information interaction operations irrelevant to information synchronization in the information synchronization process can be reduced, the information synchronization process is simplified, and the information synchronization efficiency is improved.
Step 203, in response to receiving the feedback information sent by the node to be synchronized, completing information synchronization according to the feedback information.
As can be seen from the above description, the data packet to be synchronized includes data packet information. After the data packet to be synchronized is sent to the node to be synchronized, the node to be synchronized can analyze the information to be synchronized according to the data packet information in the data packet to be synchronized, and return feedback information according to the analysis result. And the execution main body completes information synchronization according to the feedback information.
Therefore, the information is transmitted through the user data protocol when the information synchronization is needed, the nodes do not need to keep communication connection for a long time through heartbeat detection, and the problems of information concurrence and the like do not need to be considered. Therefore, the data processing amount of the nodes is reduced, the information synchronization process is simplified, and the effectiveness of the information synchronization is improved.
In some optional implementation manners of this embodiment, the completing information synchronization according to the feedback information may include the following steps:
and step one, responding to the fact that the feedback information is successfully transmitted, and finishing information synchronization operation.
When the feedback information is transmitted successfully, it indicates that the node to be synchronized has received the corresponding data packet to be synchronized, and the information to be synchronized in the data packet to be synchronized is complete. At this time, the execution body may consider this time that the information synchronization has been completed.
And step two, in response to the fact that the feedback information is transmission failure, the data packet to be synchronized is retransmitted.
When the feedback information is transmission failure, it indicates that the node to be synchronized has received the corresponding data packet to be synchronized, but the information to be synchronized in the data packet to be synchronized is incomplete. Generally, the executing entity may send the data packet to be synchronized to the node to be synchronized again according to the above steps, and know that the content returned by the node to be synchronized is the feedback information of successful transmission.
With continued reference to FIG. 3, a flow 300 of one embodiment of a method for synchronizing information in accordance with the present disclosure is shown. The method for synchronizing information includes the steps of:
step 301, in response to receiving a to-be-synchronized data packet sent by a synchronization node, analyzing the to-be-synchronized data packet to obtain analysis information.
In this embodiment, an execution subject of the method for synchronizing information (for example, the nodes to be synchronized 101 and 102 shown in fig. 1) may receive the data packet to be synchronized sent by the synchronization node through a wired connection manner or a wireless connection manner.
The execution body can receive a data packet to be synchronized sent by the synchronization node. After receiving the data packet to be synchronized sent by the synchronization node, the execution main body may analyze the data packet to be synchronized to obtain analysis information.
In some optional implementation manners of this embodiment, the analyzing the data packet to be synchronized to obtain analysis information may include the following steps:
firstly, analyzing a data compression packet and data packet information from the data packet to be synchronized.
As can be seen from the above description, the data packet to be synchronized includes a data compression packet and data packet information. The execution body can analyze the data compression packet and the data packet information from the data packet to be synchronized. The data packet information may include data packet transmission status information and data volume information of the data compression packet.
And step two, responding to the data volume information in the data packet information being the same as the data volume of the data compression packet, determining that the information transmission is correct, decompressing from the data compression packet to obtain the information to be synchronized, and determining that the information transmission is wrong.
After obtaining the packet transmission status information and the data size information of the data compression packet, the execution main body may compare the data size information of the data compression packet and the data size of the data compression packet. And if the data volume information of the data compression packet is the same as the data volume of the data compression packet, indicating that no information is lost in the information transmission process. At this time, the execution body may set the parsing result to be correct for information transmission. Then, the execution body can decompress the data compression packet to obtain the information to be synchronized. If the data volume information of the data compression packet is different from the data volume of the data compression packet, the information loss occurs in the information synchronization process. At this time, the execution body may set the parsing result as an information transmission error. The information transmission error may include any one of: retry, empty packet, incomplete, duplicate, failure, etc. Wherein, the retry can indicate that the synchronization node needs to resend the data sent before; the null packet may indicate that the actual data sent is null; incomplete may mean incomplete reception of data sent by the synchronization node; a duplicate may indicate that duplicate data was received; failure may indicate that an exception occurs during the data reception process, and the message reception cannot be completed normally.
And 302, constructing feedback information through the analysis information, and sending the feedback information to the synchronization node.
After the analysis information is obtained, the execution main body can construct feedback information through the analysis information and send the feedback information to the synchronization node. Therefore, the communication connection between the nodes is not required to be maintained through heartbeat detection, and the problems of information concurrence and the like are not required to be considered. The data processing amount of the nodes is reduced, the information synchronization process is simplified, and the effectiveness of the information synchronization is improved.
In some optional implementation manners of this embodiment, the constructing the feedback information by using the analysis information may include the following steps:
and step one, in response to the analysis result that the information transmission is correct, the data packet sending state information is modified into first data packet receiving state information with the content of successful transmission, and first feedback information is constructed according to the first data packet receiving state information.
When the analysis result shows that the information transmission is correct, the execution main body can modify the data packet sending state information into the first data packet receiving state information with the content of successful transmission. For example, the first packet reception state information may be "000". Where "000" may indicate a successful transmission. Then, the execution body may construct first feedback information according to the first packet reception status information. The first feedback information may only include the first data packet receiving status information, or may also include the data volume information and the data compression packet of the data compression packet in the data packet sending status information, which is specifically determined according to the actual needs.
And a second step of modifying the data packet sending state information into second data packet receiving state information with the content of transmission failure in response to the analysis result being an information transmission error, and constructing second feedback information according to the second data packet receiving state information.
When the analysis result is that the information transmission is wrong, the execution main body can modify the data packet sending state information into second data packet receiving state information with the content of transmission failure. For example, the second packet reception state information may be "011". Where "011" may indicate incomplete. Other transmission failures may also be: "001" indicates retry; "010" means empty packet; "100" means ignore; "101" means repetition, etc. Similar to the first feedback information, the second feedback information may include only the second packet reception status information, or may include the data amount information and the data compression packet of the data compression packet in the packet transmission status information.
With continuing reference to fig. 4, fig. 4 is a schematic diagram of an application scenario of the method for synchronizing information according to the present embodiment. In the application scenario of fig. 4, when information to be synchronized is needed on the synchronization node 104, the synchronization node 104 encapsulates the information to be synchronized into a data packet to be synchronized, and sends the data packet to the node to be synchronized 101 and the node to be synchronized 102 through the network 103. Then, the node to be synchronized 101 and the node to be synchronized 102 send feedback information to the synchronization node 104 according to the received actual information. If the feedback information of the node to be synchronized 101 received by the synchronization node 104 is successful in transmission, the synchronization node 104 does not send a data packet to be synchronized to the node to be synchronized 101 any more; if the feedback information of the node to be synchronized 101 received by the synchronization node 104 is a transmission failure, the synchronization node 104 sends the data packet to be synchronized to the node to be synchronized 102 again until the node to be synchronized 102 successfully receives the data packet to be synchronized.
The method provided by the embodiment of the disclosure firstly encapsulates the information to be synchronized into a data packet to be synchronized when the information to be synchronized is detected; then, the data packet to be synchronized is sent to a node to be synchronized through a user data protocol; and finally, when receiving the feedback information sent by the node to be synchronized, completing information synchronization according to the feedback information. According to the method and the device, information transmission is carried out through the user data protocol when information synchronization is needed, the nodes do not need to be in communication connection for a long time through heartbeat detection, and the problems of information concurrency and the like do not need to be considered. Therefore, the data processing amount of the nodes is reduced, the information synchronization process is simplified, and the effectiveness of the information synchronization is improved.
With further reference to fig. 5, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for synchronizing information, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable to various electronic devices.
As shown in fig. 5, the apparatus 500 for synchronizing information of the present embodiment may include: a packet encapsulation unit 501, a data transmission unit 502, and an information synchronization operation unit 503. The data packet encapsulating unit 501, in response to detecting information to be synchronized, is configured to encapsulate the information to be synchronized into a data packet to be synchronized; the data sending unit 502 is configured to send the data packet to be synchronized to a node to be synchronized through a user data protocol; the information synchronization operation unit 503, in response to receiving the feedback information sent by the node to be synchronized, is configured to complete information synchronization according to the feedback information.
In some optional implementations of this embodiment, the data packet encapsulating unit 501 may include: a data amount query subunit (not shown), a data dividing subunit (not shown), and a packet encapsulation subunit (not shown). The data quantity query subunit is configured to query the data quantity of the information to be synchronized; a data dividing subunit, configured to divide the information to be synchronized into at least one piece of sub-information to be synchronized, in response to the data amount being greater than a set threshold; and the data packet packaging subunit is configured to, for the sub-to-be-synchronized information in the at least one piece of sub-to-be-synchronized information, package the sub-to-be-synchronized information into a sub-to-be-synchronized data packet.
In some optional implementations of this embodiment, the packet encapsulation subunit may include: a compression module (not shown) and a packet encapsulation module (not shown). The compression module is configured to compress the sub information to be synchronized into a data compression packet, and set data packet information for the sub information to be synchronized, wherein the data packet information includes data packet transmission state information and data volume information of the data compression packet; and the data packet packaging module is configured to package the data compression packet and the data packet information into a sub-to-be-synchronized data packet.
In some optional implementations of this embodiment, the information synchronization operation unit 503 may include: a first information synchronization operation subunit (not shown in the figure) and a second information synchronization operation subunit (not shown in the figure). The first information synchronization operation subunit is configured to complete the information synchronization operation in response to the feedback information being a transmission success; and the second information synchronization operation subunit is configured to resend the data packet to be synchronized in response to the feedback information being transmission failure.
With further reference to fig. 6, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an apparatus for synchronizing information, which corresponds to the method embodiment shown in fig. 3, and which is particularly applicable to various electronic devices.
As shown in fig. 6, the apparatus 600 for synchronizing information of the present embodiment may include: a packet parsing unit 601 and a feedback information transmitting unit 602. The data packet analysis unit 601, in response to receiving a data packet to be synchronized sent by a synchronization node, is configured to analyze the data packet to be synchronized to obtain analysis information; a feedback information sending unit 602 configured to construct feedback information according to the parsing information, and send the feedback information to the synchronization node.
In some optional implementations of this embodiment, the packet parsing unit 601 may include: a packet parsing subunit (not shown in the figure) and a parsing information obtaining subunit (not shown in the figure). The data packet analysis subunit is configured to analyze a data compression packet and data packet information from the data packet to be synchronized, wherein the data packet information includes data packet sending state information and data volume information of the data compression packet; the analysis information acquisition subunit is configured to respond to that the data volume information in the data packet information is the same as the data volume of the data compression packet, the analysis result is correct information transmission, and information to be synchronized is obtained by decompression from the data compression packet, otherwise, the analysis result is an information transmission error, wherein the information transmission error comprises any one of the following items: retry, null, incomplete, repeat, failure.
In some optional implementation manners of this embodiment, the feedback information sending unit 602 may include: a first feedback information construction subunit (not shown in the figure) and a second feedback information construction subunit (not shown in the figure). The first feedback information construction subunit, in response to the analysis result being that the information transmission is correct, is configured to modify the data packet sending state information into first data packet receiving state information whose content is successful in transmission, and constructs first feedback information according to the first data packet receiving state information; and the second feedback information construction subunit, in response to the analysis result being an information transmission error, is configured to modify the data packet sending state information into second data packet receiving state information with transmission failure, and construct second feedback information according to the second data packet receiving state information.
The present embodiment also provides an electronic device, including: one or more processors; a memory having one or more programs stored thereon that, when executed by the one or more processors, cause the one or more processors to perform the above-described method for synchronizing information.
The present embodiment also provides a computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the above-mentioned method for synchronizing information.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with an electronic device (e.g., the nodes 101, 102 to be synchronized or the synchronization node 104 of FIG. 1) implementing an embodiment of the present disclosure. The electronic device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 7 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer-readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described above in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: in response to the detection of the information to be synchronized, packaging the information to be synchronized into a data packet to be synchronized; sending the data packet to be synchronized to a node to be synchronized through a user data protocol; and responding to the received feedback information sent by the node to be synchronized, and completing information synchronization according to the feedback information.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, which may be described as: a processor includes a data packet encapsulation unit, a data transmission unit, and an information synchronization operation unit. Here, the names of these units do not constitute a limitation on the unit itself in some cases, and for example, the information synchronization operation unit may also be described as "a unit for performing information synchronization".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept as defined above. For example, the above features and the technical features disclosed in the present disclosure (but not limited to) having similar functions are replaced with each other to form the technical solution.

Claims (10)

1. A method for synchronizing information, comprising:
in response to detecting the information to be synchronized, encapsulating the information to be synchronized into a data packet to be synchronized, including: inquiring the data volume of the information to be synchronized; in response to the data volume being larger than a set threshold, dividing the information to be synchronized into at least one piece of sub-information to be synchronized; for sub-to-be-synchronized information in the at least one sub-to-be-synchronized information, encapsulating the sub-to-be-synchronized information into a sub-to-be-synchronized data packet, including: compressing the sub information to be synchronized into a data compression packet, and setting data packet information for the sub information to be synchronized, wherein the data packet information includes data packet sending status information and data volume information of the data compression packet, the data packet sending status information is used for representing status information of the sent sub information to be synchronized, and the status information includes: empty packaging; packaging the data compression packet and the data packet information into a sub-packet to be synchronized;
sending the data packet to be synchronized to a node to be synchronized through a user data protocol;
and responding to the received feedback information sent by the node to be synchronized, and completing information synchronization according to the feedback information.
2. The method of claim 1, wherein the completing information synchronization according to the feedback information comprises:
in response to the feedback information being successful in transmission, completing information synchronization operation;
and in response to the feedback information being transmission failure, retransmitting the data packet to be synchronized.
3. A method for synchronizing information, comprising:
responding to a received data packet to be synchronized sent by a node to be synchronized, analyzing the data packet to be synchronized to obtain analysis information, wherein the data packet to be synchronized is determined by the node to be synchronized based on the following steps: inquiring the data volume of the information to be synchronized; in response to the fact that the data volume is larger than a set threshold value, dividing the information to be synchronized into at least one piece of sub information to be synchronized; for sub-to-be-synchronized information in the at least one sub-to-be-synchronized information, encapsulating the sub-to-be-synchronized information into a sub-to-be-synchronized data packet, including: compressing the sub information to be synchronized into a data compression packet, and setting data packet information for the sub information to be synchronized, wherein the data packet information includes data packet sending status information and data volume information of the data compression packet, the data packet sending status information is used for representing status information of the sent sub information to be synchronized, and the status information includes: empty packaging; packaging the data compression packet and the data packet information into a sub-packet to be synchronized;
feedback information is constructed through the analysis information and is sent to the synchronization node;
the analyzing the data packet to be synchronized to obtain analysis information includes:
analyzing a data compression packet and data packet information from the data packet to be synchronized, wherein the data packet information comprises data packet sending state information and data volume information of the data compression packet;
responding to that the data volume information in the data packet information is the same as the data volume of the data compression packet, the analysis result is correct information transmission, and decompressing from the data compression packet to obtain the information to be synchronized, otherwise, the analysis result is an information transmission error, wherein the information transmission error comprises any one of the following items: retry, null, incomplete, repeat, failure.
4. The method of claim 3, wherein the constructing feedback information from the parsed information comprises:
in response to the analysis result that the information transmission is correct, the data packet sending state information is modified into first data packet receiving state information with successful transmission content, and first feedback information is constructed according to the first data packet receiving state information;
and in response to the analysis result being an information transmission error, modifying the data packet sending state information into second data packet receiving state information with the content being transmission failure, and constructing second feedback information according to the second data packet receiving state information.
5. An apparatus for synchronizing information, comprising:
a packet encapsulation unit, responsive to detecting information to be synchronized, configured to encapsulate the information to be synchronized into a packet to be synchronized, comprising: a data size query subunit configured to query the data size of the information to be synchronized; a data dividing subunit, configured to divide the information to be synchronized into at least one piece of sub-information to be synchronized, in response to the data amount being greater than a set threshold; a data packet encapsulating subunit, configured to, for sub-to-be-synchronized information in the at least one piece of sub-to-be-synchronized information, encapsulate the sub-to-be-synchronized information into a sub-to-be-synchronized data packet, including: a compression module configured to compress the sub information to be synchronized into a data compression packet, and set data packet information for the sub information to be synchronized, where the data packet information includes data packet transmission status information and data amount information of the data compression packet, the data packet transmission status information is used to represent status information of the transmitted sub information to be synchronized, and the status information includes: empty packaging; a data packet encapsulation module configured to encapsulate the data compression packet and data packet information into a sub-packet to be synchronized;
the data sending unit is configured to send the data packet to be synchronized to the node to be synchronized through a user data protocol;
and the information synchronization operation unit is used for responding to the received feedback information sent by the node to be synchronized and completing information synchronization according to the feedback information.
6. The apparatus of claim 5, wherein the information synchronization operation unit comprises:
a first information synchronization operation subunit configured to complete an information synchronization operation in response to the feedback information being a transmission success;
and the second information synchronization operation subunit is used for responding to the feedback information as transmission failure and is configured to resend the data packet to be synchronized.
7. An apparatus for synchronizing information, comprising:
the data packet analysis unit is used for responding to the received data packet to be synchronized sent by the node to be synchronized and analyzing the data packet to be synchronized to obtain analysis information, wherein the data packet to be synchronized is determined by the node to be synchronized based on the following steps: inquiring the data volume of the information to be synchronized; in response to the fact that the data volume is larger than a set threshold value, dividing the information to be synchronized into at least one piece of sub information to be synchronized; for the sub-to-be-synchronized information in the at least one sub-to-be-synchronized information, encapsulating the sub-to-be-synchronized information into a sub-to-be-synchronized data packet, including: compressing the sub information to be synchronized into a data compression packet, and setting data packet information for the sub information to be synchronized, wherein the data packet information includes data packet sending status information and data volume information of the data compression packet, the data packet sending status information is used for representing status information of the sent sub information to be synchronized, and the status information includes: empty packaging; packaging the data compression packet and the data packet information into a sub-packet to be synchronized;
a feedback information sending unit configured to construct feedback information from the parsed information and send the feedback information to the synchronization node;
the packet parsing unit includes:
the data packet analysis subunit is configured to analyze a data compression packet and data packet information from the data packet to be synchronized, wherein the data packet information comprises data packet sending state information and data volume information of the data compression packet;
the analysis information acquisition subunit is configured to respond to that the data volume information in the data packet information is the same as the data volume of the data compression packet, determine that the information transmission is correct, and decompress the data compression packet to obtain the information to be synchronized, otherwise, determine that the information transmission error is an information transmission error, where the information transmission error includes any one of: retry, empty packet, incomplete, repeat, failure.
8. The apparatus of claim 7, wherein the feedback information transmitting unit comprises:
the first feedback information construction subunit is used for responding to the analysis result that the information transmission is correct, modifying the data packet sending state information into first data packet receiving state information with the content of successful transmission, and constructing first feedback information according to the first data packet receiving state information;
and the second feedback information construction subunit is used for responding to the analysis result that the information transmission error is generated, modifying the data packet sending state information into second data packet receiving state information with the content of transmission failure, and constructing second feedback information according to the second data packet receiving state information.
9. An electronic device, comprising:
one or more processors;
a memory having one or more programs stored thereon,
the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of claim 1 or 2 or the method of any of claims 3-4.
10. A computer-readable medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method of claim 1 or 2 or the method of any one of claims 3 to 4.
CN201911397616.6A 2019-12-30 2019-12-30 Method and device for synchronizing information Active CN113133107B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911397616.6A CN113133107B (en) 2019-12-30 2019-12-30 Method and device for synchronizing information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911397616.6A CN113133107B (en) 2019-12-30 2019-12-30 Method and device for synchronizing information

Publications (2)

Publication Number Publication Date
CN113133107A CN113133107A (en) 2021-07-16
CN113133107B true CN113133107B (en) 2022-12-23

Family

ID=76767876

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911397616.6A Active CN113133107B (en) 2019-12-30 2019-12-30 Method and device for synchronizing information

Country Status (1)

Country Link
CN (1) CN113133107B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104794008A (en) * 2015-04-28 2015-07-22 北京数字天域科技有限责任公司 Application program synchronizing method, device and system
CN108667881A (en) * 2017-03-31 2018-10-16 中国科学院声学研究所 A kind of synchronous method of the business datum of intelligent terminal and Cloud Server
CN109922053A (en) * 2019-02-22 2019-06-21 北京三快在线科技有限公司 Data transmission method, device, electronic equipment and readable storage medium storing program for executing
CN110602250A (en) * 2019-09-29 2019-12-20 网易(杭州)网络有限公司 Data synchronization method and device, server and terminal equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10574547B2 (en) * 2018-04-12 2020-02-25 Cisco Technology, Inc. Anomaly detection and correction in wireless networks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104794008A (en) * 2015-04-28 2015-07-22 北京数字天域科技有限责任公司 Application program synchronizing method, device and system
CN108667881A (en) * 2017-03-31 2018-10-16 中国科学院声学研究所 A kind of synchronous method of the business datum of intelligent terminal and Cloud Server
CN109922053A (en) * 2019-02-22 2019-06-21 北京三快在线科技有限公司 Data transmission method, device, electronic equipment and readable storage medium storing program for executing
CN110602250A (en) * 2019-09-29 2019-12-20 网易(杭州)网络有限公司 Data synchronization method and device, server and terminal equipment

Also Published As

Publication number Publication date
CN113133107A (en) 2021-07-16

Similar Documents

Publication Publication Date Title
US20220253458A1 (en) Method and device for synchronizing node data
CN112910967B (en) Network transmission of large files in an unstable network environment
CN111694757B (en) Application program testing method and device, electronic equipment and computer readable storage medium
CN111930709B (en) Data storage method, apparatus, electronic device, and computer readable medium
CN115938013B (en) Method, apparatus, device and computer readable medium for monitoring data
CN113133107B (en) Method and device for synchronizing information
CN110719233B (en) Method and device for transmitting information
CN111858381A (en) Application program fault tolerance capability test method, electronic device and medium
CN110572805A (en) Data transmission method and device, electronic equipment and computer readable medium
CN111800223A (en) Method, device and system for generating sending message and processing receiving message
CN112507676B (en) Method and device for generating energy report, electronic equipment and computer readable medium
CN112732457B (en) Image transmission method, image transmission device, electronic equipment and computer readable medium
CN109088929B (en) Method and device for sending information
CN114202332A (en) Digital currency wallet management method, device and system
CN110532115B (en) System, method and apparatus for developing smart contracts
CN112256714A (en) Data synchronization method and device, electronic equipment and computer readable medium
CN113704079A (en) Interface testing method and device based on Protobuf
CN112230986A (en) Project file generation method and device, electronic equipment and computer readable medium
CN110928955A (en) Data interaction method and device, computer equipment and storage medium
CN110007894B (en) Method and device for transmitting audio information
CN110750424A (en) Resource inspection method and device
CN115623070B (en) IDL message processing method and device, electronic equipment and storage medium
CN111314457B (en) Method and device for setting virtual private cloud
CN116849724B (en) Communication method, device, equipment and storage medium based on surgical robot
CN116679995A (en) Data information processing method, data information feedback method, device and equipment

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
GR01 Patent grant
GR01 Patent grant