Background technology
Along with popularizing of network, the network user is in continuous increase, and the network communicating system scale is also in continuous expansion.Comprise in the network communicating system that a large amount of network equipments support the communication between the network user of One's name is legion,, will realize between each network equipment for this reason such as data synchronization such as user online status.Such as: for instant messaging (IM, Instant Messaging) system, each instant communication server will be preserved the user online status information (that is: all user's online state informations in the current instantaneous communication system) of the overall situation, so that the user can log-in instant communication server lookup user-specific information or is obtained the online situation of good friend etc., and realization communication based on this overall user online status information ability precise and high efficiency, therefore, the overall user online status information of preserving on each instant communication server will be consistent (that is: synchronous).
The technology of existing realization data sync roughly can be divided into two classes: 1, the mode of center Control Server automatic regular polling, 2, the mode that initiatively reports of branch server.Wherein, in instant communicating system, comprising: a plurality of branch servers of center Control Server and connection thereof.Fig. 1 is the handling process schematic diagram of available data method for synchronous.Among this figure, the center Control Server connects branch server 1 and branch server 2, and center Control Server, branch server 1 and branch server 2 are preserved the user data (that is: all user's data of system's administration) of the overall situation respectively.And, branch server 1 and branch server 2 can know separately the user's data of having jurisdiction over change, and can real-time update the user's data of having jurisdiction over separately.Be example in the data sync mode between branch server 1 and branch server 2 and the center Control Server respectively below, above-mentioned two class data sync modes are illustrated.Wherein, the method for synchronization between center Control Server and the branch server 1 is the automatic regular polling mode; The method of synchronization between center Control Server and the branch server 2 is for initiatively reporting mode.
The mode of so-called center Control Server poll is exactly: the center Control Server is regularly inquired about the data of each branch server.As shown in Figure 1, Control Server timed sending query requests in center is given branch server 1, and branch server 1 returns self current user data to the center Control Server again.When upgrading appearred in the user data of branch server, the overall user data after the overall user data of center Control Server renewal self and transmission are upgraded was to other each branch server, to upgrade the overall user data of other each branch server.
The mode that so-called branch server initiatively reports is: each branch server change at self user data (such as: new user's login is arranged or user's off-line is just arranged) time, initiatively report self current up-to-date user data to the center Control Server.As shown in Figure 1, branch server 2 initiatively sends current up-to-date user data to the center Control Server when self user data changes.The center Control Server is after receiving the user data that branch server initiatively reports, the overall user data of self preserving is upgraded, and the overall user data after will upgrading sends to other each branch server, the overall user data separately thereby each other branch server also can upgrade in time is to realize data sync.
Existing two kinds of simultaneous techniquess can to a certain degree satisfy the demands in application separately, but when being applied to hicap, all have more serious problem.When adopting the mode of center Control Server automatic regular polling, the packet amount of center Control Server input and output will reach unacceptable degree, and this packet amount will be linear growth along with the expansion of system scale, thereby the center Control Server of making almost can't be realized; When the mode that adopts branch server initiatively to report, though can to a certain degree reduce the packet amount of center Control Server output, can not effectively reduce the packet amount of input, this kind mode can't be applied among the jumbo system equally.
Summary of the invention
In view of this, it is a kind of based on distributed method of data synchronization and system that main purpose of the present invention is to provide, and can realize distributed data sync, alleviates the processing burden of center Control Server, is suitable for the data sync of high Capacity Communication System.
For achieving the above object, technical scheme of the present invention is achieved in that
The invention discloses a kind ofly based on distributed method of data synchronization, this method is applied to comprise: the system of center Control Server and at least one branch server; Described at least one branch server is divided at least one synchronous chain, serve as reasons non-intersection chain that at least one branch server is linked into and only comprise a branch server of each synchronous chain as head node; This method also comprises:
Each branch server is when self user data of users of having jurisdiction over changes or regularly initiatively report self institute's user data of having jurisdiction over to the center Control Server, this center Control Server upgrades the overall user data of self preserving by the user data of being received, described overall user data is all user's data of whole system administration;
The overall user data of the current preservation of this center Control Server timed sending self is to each branch server as head node, and each upgrades the overall user data that each branch server in self synchronous chain in place is preserved after receiving from the overall user data of center Control Server as the branch server of head node.
Wherein, described branch server initiatively report self the user data of having jurisdiction over be for the center Control Server: current self all user's that have jurisdiction over of this branch server up-to-date user data or self have jurisdiction over the current user data that changes in the user data of users.
Wherein, when synchronous chain only comprised a branch server, this branch server was described branch server as head node;
The overall user data that described branch server as head node is preserved each branch server in self synchronous chain in place carries out method for updating and comprises: this as branch server of head node by overall user data, to upgrading except that all customer data of self having jurisdiction over the user data in the overall user data of self preserving from the center Control Server.
Wherein, when synchronous chain comprised a plurality of branch server, this synchronous chain further comprised: as the branch server of tail node;
The overall user data that described branch server as head node is preserved each branch server in self synchronous chain in place carries out method for updating and comprises:
This branch server as head node is pressed the overall user data from the center Control Server, to upgrading except that all customer data of self having jurisdiction over the user data in the overall user data of self preserving, the overall user data after output is upgraded again is to described branch server as tail node; This upgrades the overall user data of self preserving after as the overall user data of branch server after receiving described renewal of tail node.
Wherein, when synchronous chain comprised more than two branch server, this synchronous chain further comprises: at least one was as the branch server of intermediate node;
The overall user data that described branch server as head node is preserved each branch server in self synchronous chain in place carries out in the method for updating, and the overall user data after described branch server output as head node is upgraded to the processing as the branch server of tail node comprises:
Overall user data after this branch server output as head node is upgraded is to the branch server as intermediate node that self connects; Each upgrades the overall user data of self preserving receiving after as the overall user data after the renewal of the branch server of head node or intermediate node as the branch server of intermediate node, and the overall user data of output after upgrading is to the branch server as intermediate node or tail node that self connects; Described branch server as tail node receives overall user data after the described renewal from described branch server as intermediate node.
Wherein, described user data is a user online status information, and described overall user data is overall user online status information.
Wherein, described overall user online status information is present among center Control Server and each branch server with the form of overall presence table.
The invention also discloses a kind ofly based on distributed data synchronous system, this system comprises: center Control Server and at least one branch server; This system comprises: at least one the synchronous chain that is divided into by described at least one branch server; Serve as reasons non-intersection chain that at least one branch server is linked into and only comprise a branch server of each synchronous chain as head node;
Each branch server is used for when self user data of users of having jurisdiction over changes or regularly exports self institute's user data of having jurisdiction over and give the center Control Server; In each synchronous chain, described branch server as head node is used for receiving overall user data from described center Control Server, and the overall user data that each branch server in self synchronous chain in place is preserved upgrades, and described overall user data is all customer data of this system's administration;
Described center Control Server is used for upgrading from described branch server receiving subscriber data and to the overall user data of self preserving, and the overall user data of the current preservation of timed sending self is to each branch server as head node.
Wherein, when synchronous chain only comprises a branch server, this branch server is described branch server as head node, in this synchronous chain, described branch server as head node is used for by described overall user data from the center Control Server, to upgrading except that all customer data of self having jurisdiction over the user data in the overall user data of self preserving;
When synchronous chain comprised a plurality of branch server, this synchronous chain further comprised: as the branch server of tail node; Described branch server as head node is used for by described overall user data from the center Control Server, remove all customer data of self having jurisdiction over the user data in the overall user data that self is preserved and upgrade, and the described branch server as tail node extremely of the overall user data after the output renewal; This branch server as tail node is used for upgrading the overall user data of self preserving behind the overall user data after receiving described renewal.
Wherein, when synchronous chain comprised more than two branch server, this synchronous chain further comprises: at least one was as the branch server of intermediate node;
Described branch server as head node is used to export overall user data after the renewal to the branch server as intermediate node that self connects;
Each branch server as intermediate node is used for after the overall user data after receiving renewal the overall user data of self preserving being upgraded, and the overall user data of output after upgrading is to the branch server as intermediate node or tail node that self connects;
Described branch server as tail node is used for receiving overall user data after the described renewal from described branch server as intermediate node.
By such scheme as can be seen, key of the present invention is: each branch server initiatively reports the more new situation of user data separately to give the center Control Server; Each branch server is divided at least one synchronous chain, and to be unit with synchronous chain upgrade the user data of each branch server the center Control Server.
Therefore, provided by the present invention based on distributed method of data synchronization and system, can be the data sync that unit (i.e. mode to distribute) realizes each branch server with synchronous chain, and the data of utilizing the mode that initiatively reports to come real-time update center Control Server simultaneously, thereby be beneficial to the data sync that realizes hicap, the packet amount of center Control Server input and output be can significantly reduce with respect to prior art, the realization and the dilatation of center Control Server are easy to.
Embodiment
The present invention is further described in more detail below in conjunction with drawings and the specific embodiments.
The invention provides a kind ofly based on distributed data synchronous system, (that is: one or more, as also to can be described as at least one) branch server constitutes by the center Control Server with more than one in this system.Wherein, the center Control Server is as center control nodes, and described more than one branch server is then formed more than one synchronous chain.In each synchronous chain, each node is exactly a branch server, and each node links to each other successively and is non-intersection chain structure, and a head node is only arranged.So-called non-intersection chain structure each node in other words is the arrangement of " one " font; Wherein,, then only comprise head node,, then comprise the tail node of head node and connection thereof if comprise two nodes in the non-intersection chain if only comprise a node in the non-intersection chain; If comprise in the non-intersection chain more than two nodes, then comprise head node, at least one intermediate node and tail node, this head node only connects a next stage node (being intermediate node), and each intermediate node only connects an even higher level of node (head node or intermediate node) and only connect a next stage node (intermediate node or tail node), and tail node then only connects an even higher level of node (intermediate node).In addition, only to the head node dateout of each synchronous chain, the node in each synchronous chain also can only be to next stage node dateout separately for center control nodes; And on the other hand, each node (that is: branch server) in the chain all directly connects center control nodes (that is: center Control Server) synchronously, like this, each branch server can initiatively report the more new situation of user data separately to the center Control Server respectively, and the center Control Server of making can obtain up-to-date overall user data in real time.
Fig. 2 is the annexation schematic diagram of system of the present invention one preferred embodiment.As shown in Figure 2, connect the head node of three synchronous chains as the center Control Server of center control nodes, these three synchronous chains comprise: chain 1, chain 2 and chain 3 synchronously synchronously synchronously; Its head node separately is respectively: head node 1, head node 2 and head node 3.In synchronous chain 1, comprising: head node 1 and next stage node---the node 11 that connects thereof, and next stage node---the node 12 of these node 11 connections; In synchronous chain 2, comprising: head node 2 and next stage node---the node 21 that connects thereof; In synchronous chain 3, comprising: head node 3 and next stage node---the node 31 that connects thereof, next stage node---the node 32 that this node 31 connects, next stage node---the node 33 that this node 32 connects.Here, except that center control nodes, each node is all represented a branch server, and the following stated center control nodes is represented the center Control Server, and other node except that center control nodes is just represented branch server.In fact, each node except that center control nodes all connects center control nodes, in Fig. 2, and for the annexation that makes synchronous chain is more clear, and being connected of not shown these nodes and center control nodes.
Wherein, each node of other except that center control nodes is all being administered the user of certain limit, they can know in real time separately the user's data of having jurisdiction over change, reach the standard grade/situation of off-line such as: user.When the user data of a certain node changes, such as: have new user to reach the standard grade or when user's off-line has just been arranged, this node will be initiatively to center control nodes report self current up-to-date user data (such as: user online status information).Like this, center control nodes can obtain up-to-date overall user data in real time.Here, the up-to-date user data that each node reports to center control nodes can be for self having jurisdiction over the current up-to-date user data of all users, also can be for self having jurisdiction over the current user data that changes in the user data of users.
Simultaneously, center control nodes is also regularly upgraded the overall user data of each other node, can be synchronous with the overall user data that each node in the assurance system is preserved.This center control nodes is that unit carries out to the renewal of other each node with synchronous chain.At first, center control nodes exports self current up-to-date overall user data the head node of each the synchronous chain that self connects to respectively, as head node 1, head node 2 and the head node 3 of Fig. 2.Then, each head node carries out the renewal processing of overall user data in chain inside synchronously at this again.
In synchronous chain 1, head node 1 upgrades the overall user data that self preserves after receiving from the overall user data of center control nodes, and the overall user data after transmission is upgraded then is to the next stage node (that is: node 11) that self connects; This node 11 upgrades the overall user data of self preserving by the overall user data of being received, and the overall user data after the output renewal is to the next stage node (that is: node 12) that self connects.This node 12 finishes the overall user data of overall user data update for receiving from node 11 of self preserving the renewal of the overall user data of this synchronous chain 1 and handles.In synchronous chain 2, head node 2 upgrades the overall user data that self preserves after receiving from the overall user data of center control nodes, and the overall user data after transmission is upgraded then is to the next stage node (that is: node 21) that self connects; This node 21 upgrades the overall user data of self preserving by the overall user data of being received, thereby the renewal that finishes the overall user data of this synchronous chain 2 is handled.Similarly, in synchronous chain 3, head node 3 be a up-to-date overall user data from center control nodes with the overall user data update of self preserving, and the overall user data of output after upgrading is to the next stage node (that is: node 31) of self connection; This node 31 is the overall user data of receiving from even higher level of node (that is: head node 3) with the overall user data update of self preserving also, and to the up-to-date overall user data of next stage node (that is: node 32) output that self connects; This node 32 is identical with the processing of node 31, and by the overall user data of preserving from the overall user data update self of even higher level of node (that is: node 31), and the overall user data after will upgrading is exported to next stage node (that is: node 33); After this node 33 is received overall user data from node 32, upgrade the overall user data of self preserving, thereby the overall user data update that finishes this synchronous chain 3 is handled.Here, above-mentioned each node is after having upgraded the overall user data of self preserving, the overall user data that can issue immediately after the renewal is given its next stage node, also can regularly send the up-to-date overall user data of self preserving to its next stage node by preset period.Here, each intermediate node is when pressing the overall user data of preserving from the overall user data update self of even higher level of node, upgrade be in the overall user data except that other user data of self having jurisdiction over the user data, that is: will be from having jurisdiction over other user data the user data except that this intermediate node in the overall user data of even higher level of node except that self having jurisdiction over other user data update the user data in the overall user data of self preservation.
Annexation and operation principle based on the invention described above system, the invention allows for a kind of based on distributed method of data synchronization, this method mainly comprises two parts: one, branch server upgrades center Control Server data, that is: each branch server is when the user data of self preserving changes or regularly initiatively report self institute's user data of having jurisdiction over to give the center Control Server, the overall user data of user data real-time update self preservation that this center Control Server initiatively reports by each branch server; Two, the center Control Server upgrades the overall user data of each branch server, that is: the center Control Server regularly issues up-to-date overall user data to each synchronous chain, and each synchronous chain is finished the renewal of inner each branch server overall situation user data of this synchronous chain separately respectively.Below in conjunction with Fig. 3 and Fig. 4 the processing of the inventive method is elaborated, among the embodiment of this method, carry out synchronous user data is user online status information, and then overall user data is overall user online status information just.
Fig. 3 is the process chart that branch server upgrades center Control Server data in the inventive method.As shown in Figure 3, for a branch server, its processing of upgrading center Control Server data specifically comprises:
Step 301: branch server regularly detects each user's online state of self having jurisdiction over.
Step 302: judge whether to have detected new user and just reached the standard grade or user's off-line is just arranged, if then execution in step 303; Otherwise return step 301.
Step 303: the user online status information that this branch server is preserved self is upgraded, and the user online status information that initiatively reports self current preservation is to the center Control Server.Here, the user online status information that branch server reports can be the up-to-date user online status information of all users of self having jurisdiction over of its current preservation, also can be the user online status information that changes in self all user's that have jurisdiction over the user online status information (such as: just off-line and/or the user's online state information of just having reached the standard grade)
Step 304: the overall user online status information that the center Control Server is preserved by the user online status information updating that receives self, return step 301 then.Wherein, if what receive is the user's online state information that changes, then upgrade these user's online state informations that change in the overall user online status information of self preserving; If what receive is that certain branch server is had jurisdiction over the up-to-date user online status information of all users, then all users' that this branch server is had jurisdiction over of current preservation user online status information is all replaced with this branch server of being received and have jurisdiction over the up-to-date user online status information of all users.
Fig. 4 upgrades the process chart of each branch server data for center Control Server in the inventive method.The center Control Server will carry out Data Update at each synchronous chain that is made of some branch servers to be handled, and wherein the renewal of carrying out at a synchronous chain is handled as shown in Figure 4, and concrete steps comprise:
Step 401: the center Control Server is regularly to upgrading overall user online status information as the branch server request of head node in the preamble chain, and the overall user online status information that sends self current preservation is to this branch server as head node
Step 402:this branch server as head node is pressed the overall user online status information from the center Control Server; All user online status information in the overall user online status information that self is preserved except self jurisdiction user's user online status information are upgraded (that is: with other user online status information update all except self all user online status information of jurisdiction in the overall user online status information of self preserving for from other user online status information except this user online status information of administering as the branch server of head node in the overall user online status information of center Control Server), and export after this renewal overall user online status information to self connection as next stage node branch server.
When synchronous chain only comprises a branch server, this branch server is exactly the branch server as head node, so after this branch server as head node has upgraded the overall presence information of self preserving, just needn't be to having exported overall user online status information as next stage node branch server, follow-up step 403 also needn't be carried out.
When synchronous chain comprised two branch servers, this synchronous chain also comprised except comprising the branch server as head node: as the branch server of tail node; At this moment, what receive overall user online status information from the branch server as head node in this step 402 is exactly this branch server as tail node as next stage node branch server, just upgrade the overall user online status information of self preserving so after the overall user online status information after this branch server as tail node is received described renewal, thereby the renewal that finishes this synchronous chain is handled, so following step 403 also needn't be carried out.
When synchronous chain comprised more than two branch server, this synchronous chain is handled and comprised that the branch server as head node and tail node also further comprises: at least one was as the branch server of intermediate node; What receive overall user online status information from the branch server as head node in this step 402 is exactly branch server as intermediate node as next stage node branch server.
Step 403: each as the branch server of intermediate node after the overall user online status information of receiving from even higher level of node (head node or intermediate node), self overall user online status information is upgraded, sent overall user online status information to the branch server that self connects again as next stage node (intermediate node or tail node); , self overall user online status information is upgraded, thereby the renewal that finishes this synchronous chain is handled then after the overall user online status information of receiving from even higher level of node (intermediate node) as the branch server of tail node
Fig. 5 is the data synchronization processing schematic diagram of a preferred embodiment of the present invention.In the present embodiment, comprising: center Control Server and two synchronous chains---chain 1 and chain 2 synchronously synchronously.Wherein, synchronous chain 1 only comprises branch server N, and the head node of this synchronous chain 1 of this branch server N conduct and while be the tail node of the synchronous chain 1 of conduct also; Chain 2 comprises synchronously: branch server C, branch server B and branch server A, and this branch server C is a head node, and branch server A is a tail node.
Referring to each points to the dotted arrow of center Control Server among Fig. 5, each branch server also links to each other with the center Control Server respectively, is used for respectively regularly initiatively reporting the current user online status change in information situation of self having jurisdiction over to the center Control Server when self having jurisdiction over the user's online state and change or by predetermined period.Thereby, the center Control Server can be preserved the user online status information of the overall situation in real time, this overall situation user state information can overall presence table form be kept in the Control Server of center, so so-calledly upgrade overall user online status information and upgrade this overall situation presence table exactly.
On the other hand, the center Control Server also regularly upgrades to each branch server request as head node.As shown in Figure 5, the center Control Server regularly upgrades to branch server N and branch server C request, and issues current up-to-date overall user online status information simultaneously to branch server N and branch server C.Branch server N upgrades the overall user online status information that self preserves after receiving from the overall user online status information of center Control Server, thereby finishes the renewal of the overall user online status information of synchronous chain 1.In addition, branch server C also upgrades the overall user online status information that self preserves after the overall user online status information of receiving from the center Control Server, and the overall user online status information of exporting after this renewal is given its next stage node---branch server B; Other user online status information updating in the overall user online status information that branch server B preserves self except that self has jurisdiction over user online status information is from having jurisdiction over other user online status information the user online status information except that this branch server B in the overall user online status information of branch server C, and the overall user online status information after this renewal exported is to its next stage node---branch server A; This branch server A is the tail node of this synchronous chain 2, the overall user state information of only preserving then by the overall user online status information updating self that receives, thus finish the overall user online status information synchronization of this synchronous chain 2.Here, the form that each branch server also can overall presence table is preserved this overall situation user online status information, upgrades overall user online status information so and upgrades this overall situation presence table exactly.
In addition, in Fig. 5, branch server A is in charge of user terminal A, branch server N is managing user terminal B then, because branch server A and branch server N can realize the synchronous of overall user online status information with greater efficiency behind employing the present invention, therefore, branch server N equally also can accurately preserve the user online status information of user terminal A, accurately inquires about the user online status information that obtains user terminal A thereby user terminal B can login branch server N.
According to above embodiment as can be known, the mode that the present invention initiatively reports by branch server is come the overall user data of real-time update center Control Server, to reduce the packet amount of input center Control Server, simultaneously by mechanism based on overall user data in the renewal branch server of synchronous chain, can also significantly reduce the packet amount of center Control Server output, thereby can alleviate the processing burden of center Control Server greatly, be beneficial to the realization and the dilatation of hicap.And because each branch server can efficiently be realized the synchronous of overall user data fast, the user of a certain business just can obtain own good friend or other people presence information apace in the system, thereby helps improving quality of service.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention.All any modifications of being done within the spirit and principles in the present invention, be equal to replacement, improvement etc., all be included in protection scope of the present invention.