Summary of the invention
One or more problems in view of the above the invention provides the method for data synchronization between a kind of distributed system single panel.
According to the method for data synchronization between the distributed system single panel of the embodiment of the invention, may further comprise the steps: S102, when the shared data on system single board changed, system single board formed the data snapshot of region of variation, and added the version information of himself on data snapshot; S104, system single board are sent to the data snapshot of having added version information the other system veneer that is different from himself; And S106, the data snapshot that version information has been added in the utilization of other system veneer is upgraded the data trnascription on self veneer, with keep and described system single board between data sync.
Wherein, step S102 may further comprise the steps: when the shared data on system single board changed, system single board formed the data snapshot of region of variation; System single board is added on the version information of himself in the data snapshot, and the data snapshot of having added version information is divided into a plurality of packets; And system single board is linked at each packet on the synchronous chained list of himself successively.
Wherein, be that step S104 may further comprise the steps under the situation of controlled veneer at system single board: controlled veneer is sent to master control veneer with the data snapshot of having added version information; Master control veneer judges whether to have accepted to add the data snapshot of version information according to version information; And if master control veneer is accepted the data snapshot added version information, then utilize the data trnascription on data snapshot renewal self veneer that has added version information, and the data snapshot of having added version information is sent to the other system veneer that is different from controlled veneer, otherwise master control veneer abandons the data snapshot of having added version information.
Wherein, controlled veneer is sent to master control veneer by the mode of sliding window Flow Control with the data snapshot of having added version information.Version information is the time when forming data snapshot to add that an incremental change forms.
Wherein, master control veneer judges whether to have accepted to add the data snapshot of version information according to the version information that carries in first packet in the data snapshot of having added version information.Further, master control veneer judges according to the temporal information in the version information that carries in first packet whether the data snapshot of having added version information is up-to-date, if then accept, otherwise abandon.Wherein, temporal information on temporal information in the version information that carries in first packet and the master control veneer in the version information of original shared data is identical, then utilize the incremental change in the version information that carries in first packet to judge whether the data snapshot of having added version information is up-to-date, if the incremental change in the version information that carries in first packet is greater than the incremental change in the version information of original shared data on the master control veneer, judge that then the data snapshot of having added version information is up-to-date, otherwise be not.
Wherein, master control veneer preferentially is sent to the data snapshot of having added version information the system single board that the version in the other system veneer falls behind.The other system veneer utilizes the data link table of himself to receive the data snapshot added version information, and after the data trnascription on himself veneer finishes renewal, discharges the data link table of himself.
The invention solves the problem of the step-out of synchrodata, improved the stability of system.
Embodiment
Below with reference to accompanying drawing, describe the specific embodiment of the present invention in detail.
With reference to figure 1, illustrate according to the method for data synchronization between the distributed system single panel of the embodiment of the invention.Wherein, comprise a master control veneer in the distributed system, operation has the center control program on this master control veneer, is referred to as Global below, also comprises some other veneers, and operation has the node procedure of data sync on these veneers, is referred to as Local later on.Wherein, all have a data copy on the every veneer, this data trnascription is the buffer area of shared data, and purpose of the present invention is exactly the realtime uniform that will guarantee each data trnascription.
As shown in Figure 1, the method for data synchronization according to the embodiment of the invention may further comprise the steps:
S102, the data trnascription on each veneer of initialization, version number and synchronous chained list.When the shared data on the veneer changes, form the data snapshot of region of variation, and on data snapshot, add version number.
S104, if the variation of shared data occurs on the Local, then this Local sends to Global with data snapshot, if the variation of shared data occurs on the Global, then Global decides according to version number whether this data snapshot can be accepted.If can accept, then upgrade the data trnascription of oneself, and data snapshot is synchronized on other all veneers with this data snapshot, if unacceptable, then the veneer that changes to shared data sends refuse information.
S106, other Local accepts this data snapshot, and upgrades data trnascription on self veneer with this data snapshot.If it is unacceptable that this data snapshot is decided, then in system, all data of this data snapshot all are dropped.Wherein, after finishing synchronously, each veneer discharges the synchronous chained list resource of oneself.
Wherein, in step S102, form the data snapshot of region of variation, and data snapshot is divided into several packets, be linked at successively on the synchronous chained list.Wherein, each packet all comprises the version information of this data snapshot.Version information is the global system time when forming data snapshot to add that an incremental change forms.
Wherein, in step S104, Local sends to Global successively with the packet in the synchronous chained list, and the mode of transmission takes the mode of sliding window Flow Control to send.The send mode of so-called sliding window Flow Control, be that A sends packet to B, when sending, A accepts the response message that B returns to A, B is not that each bag all will be replied response message, but take the time-delay response, and send response message at set intervals one time, comprise the sequence number of the packet of receiving at last in the response message.After this response message sent, we said that the packet that this sequence number comprised this sequence number in the past all confirmed by B.If A do not receive response for a long time or received the response that repeats, then A thinks that packet loss may take place link, is then begun to carry out the repeating transmission of packet from last by the packet that B has confirmed.If B receives wrong bag, out of order bag, then can send duplicate responses, prompting A retransmits packet.A is not disposable distributing when sending bag, but sends to till the specific packet, the span of the window of being separated by between the packet that this packet and last were confirmed by B.
Wherein, in step S104, Global judges that by the version information that carries in first bag of receiving this snapshot is the up-to-date version of the overall situation.The method of judging is: at first, check that the temporal information in the version information is up-to-date, if up-to-date, think that then version is up-to-date.If the temporal information of the temporal information in the version information and original version is identical, then compare incremental change again, incremental change thinks that greatly then version is new; Otherwise think that version is not new.If version is up-to-date, then Global accepts whole snapshot datas that Local sends over, and the form of snapshot data with the packet chained list left in the synchronous chained list, and these packets are transmitted to other all Local (process of forwarding also adopts the send mode of sliding window Flow Control).When other all Local were sent packet, Global was by analyzing the version that each Local goes up data, and the Local that the searching version falls behind preferentially carries out synchronously.
Wherein, in step S106, Local accepts the packet of this data snapshot, and is stored in the synchronous chained list, and after accepting fully, Local upgrades the data trnascription of oneself with this data snapshot.
Below with reference to Fig. 2 to Fig. 6, illustrate in greater detail the specific embodiment of the present invention.
Fig. 2 is the frame diagram of application according to the system of the method for data synchronization of the embodiment of the invention.As shown in Figure 2, this system comprises master control veneer (operation has the center control program on this veneer, is referred to as Global) and some other veneers (operation has the node procedure of data sync on these veneers, is referred to as Local).Wherein, all have a data copy on the every veneer, this data trnascription is the buffer area of shared data, and purpose of the present invention is exactly the realtime uniform that will guarantee each data trnascription.
Fig. 3 carries out synchronous schematic diagram according to the data after the variation of the embodiment of the invention between plate.Wherein, G representative operation has the veneer of Global, and L1 and L2 are respectively the veneers that two operations have Local.The version number of supposing thezone 3 on these three veneers when initial all is 100.As shown in Figure 3, the step of data sync is as follows:
S302, the user program on the L1 veneer has carried out write operation to shareddata zone 3, and the Local on the L1 carries out snapshot tozone 3, and forms version number according to the length of a game of system, is assumed to be 120.
S304, the Local on the L1 is split as the plurality of data bag with data snapshot, is stored under the synchronous chained list, and packet is sent to Global.
S306, when Global receives first packet, decide according to version number, because version number 120 is newly in version number 100, so this snapshot is can be received, so Global accepts remaining packet, they is organized into data snapshot, and upgradezone 3 in the own data trnascription, and be notified to the user program data trnascription and revise with it.
S308, Global is with the Local (Local L2 on) of the data packet delivery in the synchronous chained list to other, and L2 has accepted all packets, is organized into data snapshot then, and upgradezone 3 in the own data trnascription, and notice user program data trnascription changes.At last, each veneer discharges synchronous chained list.
Fig. 4 is the sliding window schematic diagram according to the embodiment of the invention.Wherein, there are 9 packets (sequence number is 0 to 8) to be hung under the synchronous chained list.This cunning window is of a size of 5, wherein, 0,1 two packets are to send and be identified, No. 2 packets are tops of sliding window, 2,3 two packets are issued but also are not identified, 4,5,6 three packets are can send but the packet that also in time sends, and No. 6 packets are bottoms of sliding window, and 7,8 two packets are not allow the packet that sends.
Fig. 5 be according to the utilization of the embodiment of the invention packet of sliding window control carry out the schematic diagram that transmits between plate.Wherein, suppose that Global sends packet to Local, its process can be done following decomposition:
S502, Global have sent packet No. 0, and this moment, sliding window top was positioned at packet No. 0, and Local has started the ACK_TIME timer after receiving No. 0 packet.
S504, Global continue to give out a contract for a project, and have been dealt into packet successively No. 2, and Local accepts.
S506, the ACK_TIME on the Local is triggered, and sends response to Global, confirms No. 2 packet.
S508, Global receive the sliding window in response back and move down, and the top moves to packet No. 3; And continue to send bag, touch the bottom of sliding window when sending to No. 6 packets, wait for the response message of Local.
S510, the ACK_TIME on the Local sets out once more, sends response to Global, confirms No. 5 packet.Global receives the sliding window in response back and moves down, and the top moves to packet No. 6, and continues to give out a contract for a project.
Fig. 6 is the schematic diagram that transmits according between the data wrapper sheet under the situation of the appearance packet loss of the embodiment of the invention.Wherein, suppose that Global gives out a contract for a project to Local, No. 2 packet loss appears in packet when sending, all think to have received out of order bag so during 3,4, No. 5 packets after receiving of Local, so Local can reply duplicate responses, Global retransmits No. 2 packets after receiving duplicate responses.
In sum, at data step-out problem, the present invention is by carrying out data snapshot to shared data, and data snapshot is synchronized on each veneer, eliminated the data step-out.In addition, the present invention is by being divided into shared data in different zones, and each is carried out snapshot to the zone that changes, thereby improved efficient.And the present invention has also added version number's (version number comprises temporal information and an incremental change) for data, and version number is used to define the new and old of data; Version number according to data on each veneer distributes, and is preferably the backward veneer of version and carries out data sync, thereby improved synchronous efficiency; Simultaneously, the present invention has also solved the concurrency conflict problem of shared data well by the priority that compares version number.At last, aspect communication between plates, the present invention takes sliding window fluidics, has avoided the congested stability that influences system of communication link.
Compared with prior art, the present invention has improved the reliability of data sync greatly, has improved the efficient of transfer of data simultaneously by sliding window control.In addition, because the present invention has taked version number's strategy, make data sync stable more more real-time.
The above is embodiments of the invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within the claim scope of the present invention.