Embodiment
The embodiment of the present invention provides a kind of method of data synchronization, node and stores service cluster, can reduce the synchronization times of object, thereby saves computational resource.
Please refer to Fig. 1, in the embodiment of the present invention, embodiment of method of data synchronization comprises:
101, the request of obtaining the first object sending from node reception client in stores service cluster;
In the present embodiment, from node, can receive the request of obtaining the first object that client sends, the request of wherein obtaining the first object comprises the identifier of the first object, in the prior art, object is one group of data, each object has a unique identifier, and the renewal of object is only for the value of data has renewal, and identifier can not change.
102,, when storing the version number of the first object and this first object from node, from node, according to the identifier of the first object, inquire about the version number of this first object of storing host node;
In the present embodiment, when storing the version number of the first object and this first object from node, can be according to the version number of this first object of storing the identifier inquiry host node of the first object from node, in actual applications, the version number of object can, for numeral, character or array etc., not limit herein.
It should be noted that, host node with from node, belong to a stores service cluster, this stores service cluster comprises a plurality of nodes, and a selected node is as host node in a plurality of nodes, how the node in other stores service cluster, as from node, is selected herein and is not limited, can choose at random, also can select host node according to the performance of each node, for example, can be using the highest node of signal strength signal intensity as host node.
103, from node, judge that whether the version number of the first object that self stores is consistent with the front page this shop of the first object inquiring host node, if inconsistent, perform step 104, if consistent, represent that the first object does not upgrade;
104, the first object of from node, self being stored and the version number of the first object are synchronously updated to the first object and the front page this shop storing host node.
In the present embodiment, whether the described front page this shop of version number and described the first object inquiring described host node of described the first object that can judge self storage from node is consistent, if consistent, represent that the first object does not upgrade, if inconsistent, perform step 104, then the first object that self can be stored from node and the version number of the first object are synchronously updated to the first object and the front page this shop storing host node, for example, the front page this shop storing in host node is 1, from node synchronous renewal, the version number of the first object of storing from node is 1.
It should be noted that, the client in the embodiment of the present invention can obtain for moving, newly-increased or revise the device of the program of object in stores service cluster, and this client can be server, computer, handheld terminal (as, mobile phone) etc.
In the present embodiment, from node, receive the request of obtaining the first object that client sends, when storing the version number of the first object and this first object from node, from node, according to the identifier of the first object, inquire about the version number of this first object of storing host node, whether the version number that judges the first object that self stores from node is consistent with the front page this shop of the first object inquiring host node, if inconsistent, the first object of from node, self being stored and the version number of the first object are synchronously updated to the first object and the front page this shop storing host node, wherein, host node with from node a stores service cluster, like this, only when client needs reading object, from node, by contrasting the version number of the version number of the object of self storing and this object of host node storage, just can determine whether this object has renewal, and when having renewal, from node, the object upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
For the ease of understanding, below with an instantiation to being described in the method for data synchronization of the embodiment of the present invention, refer to Fig. 2, in the embodiment of the present invention, another embodiment of method of data synchronization comprises:
201, from node by from client to second object information or upgrade the information of the first object be sent to host node;
In the present embodiment, from node can by from client to second object information or upgrade the information of the first object be sent to host node, in actual applications, client is to submitting the information of second object or the information of the first object renewal to from node, wherein the information of object comprises: the identifier of object and this object.
202, host node receives the information of the first object upgrading from client or from node, and is the first object distribution front page this shop after upgrading;
In the present embodiment, when in stores service cluster, the first object has renewal, host node can be from this from node or the information of first object of this client upgrading, and be the first object distribution front page this shop after upgrading, wherein front page this shop from upgrade before the version number of the first object different, in actual applications, the version number of object can be numeral, character or array etc., do not limit herein, for example, the version number of the first object before renewal is 0, and host node is 1 for the first object after upgrading distributes front page this shop.
It should be noted that, the version number before renewal and after upgrading of same target is also different, and the version number of different objects can be identical, also can be different.
203, host node is from client or receive the information of second object from node, and is second object distribution second edition this shop;
In the present embodiment, while having new second object to generate in stores service cluster, host node is from this from node or the information of this client second object, and is second object distribution second edition this shop.
204, from node, receive the request of obtaining the first object that client sends;
In the present embodiment, from node, can receive the request of obtaining the first object that client sends, the request of wherein obtaining the first object comprises the identifier of the first object, in the prior art, object is one group of data, each object has a unique identifier, and the renewal of object is only for the value of data has renewal, and identifier can not change.
205, from node, according to the identifier of the first object, judge whether self stores the version number of the first object and the first object, if there is storage, perform step 206, if not storage performs step 210;
In the present embodiment, from node, can judge whether self stores the version number of the first object and the first object according to the identifier of the first object, if there is storage, perform step 206, if not storage performs step 210.
206, from node, according to the identifier of the first object, inquire about the version number of the first object host node;
207, from node, judge that whether the version number of the first object that self stores is consistent with the front page this shop of the first object inquiring host node, if inconsistent, perform step 208, if consistent, represent that the first object does not upgrade;
In the present embodiment, when judgment result is that of step 205 is, can be according to the version number of the first object the identifier inquiry host node of the first object from node, then from node, judge that whether the version number of the first object that self stores is consistent with the front page this shop of the first object inquiring host node, if inconsistent, perform step 208, for example, the version number of the first object of storing from node is 0, the front page this shop of host node storage is 1, perform step 208, if consistent, represent that the first object does not upgrade, in actual applications, the information of the first object that self can be stored from node is sent to client.
208, the first object of from node, self being stored and the version number of the first object are synchronously updated to the first object and the front page this shop storing host node;
In the present embodiment, in step 207 when the determination result is NO, the first object that self can be stored from node and the version number of the first object are synchronously updated to the first object and the front page this shop storing host node, for example, the front page this shop of host node storage is 1, after synchronous renewal, the Wei1(front page this shop of version number of the first object of storing from node).
209, from node, the information of the first object obtaining synchronously upgrading is sent to client;
In the present embodiment, from node, the information of the first object synchronously upgrading can be sent to the client of acquisition request the first object.
210, from node from host node, obtain information and the front page this shop of the first object.
In the present embodiment, when the determination result is NO in step 205, from node, can directly from host node, obtain information and the front page this shop of the first object.
It should be noted that, host node stores the version number of up-to-date object and this object, so when client-requested is obtained the information of object, host node can directly be sent to client by the information of object, does not have the synchronous process of data.
In the present embodiment, host node receives the information of the first object or the information of second object after upgrading, and distribute front page this shop or be second object distribution second edition this shop for the first object after upgrading, from node, receive the request of obtaining the first object that client sends, when storing the version number of the first object and this first object from node, from node, according to the identifier of the first object, inquire about the version number of this first object of storing host node, whether the version number that judges the first object that self stores from node is consistent with the front page this shop of the first object inquiring host node, if inconsistent, the first object of from node, self being stored and the version number of the first object are synchronously updated to the first object and the front page this shop storing host node, wherein, host node with from node a stores service cluster, like this, host node stores the version number of up-to-date object and this object, when client needs reading object, from node, by contrasting the version number of the version number of the object of self storing and this object of host node storage, just can determine whether this object has renewal, and when having renewal, from node, the object upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
Below to describing for carrying out the node of the embodiment of the present invention of above-mentioned method of data synchronization, its basic logical structure is with reference to figure 3, and when node is during from node, in the embodiment of the present invention, embodiment of node comprises:
Receiving element 301, query unit 302, the first judging unit 303, synchronous updating block 304 and memory cell 305;
Memory cell 305, for the information of storage object and the version number of this object;
Receiving element 301, the request of obtaining the first object sending for receiving client, the request of wherein obtaining the first object comprises the identifier of the first object;
Query unit 302, for when storing the version number of the first object and the first object, according to the version number of the first object of storing in the identifier inquiry host node of the first object from node;
The first judging unit 303, also whether consistent with the front page this shop of the first object inquiring at host node for judging the version number of the first object that memory cell 305 is stored;
Synchronous updating block 304, for when judgment result is that of the first judging unit 303 is inconsistent, is synchronously updated to by the first object of memory cell 305 storages and the version number of the first object the first object and the front page this shop storing in host node;
Wherein, host node with from node a stores service cluster.
In the present embodiment, receiving element 301 receives the request of obtaining the first object that client sends, when storing the version number of the first object and this first object from node, query unit 302 is according to the version number of this first object of storing in the identifier inquiry host node of the first object, the first judging unit 303 judges that whether the version number of the first object that memory cell 305 is stored is consistent with the front page this shop of the first object inquiring in host node, if inconsistent, synchronous updating block 304 is synchronously updated to by the first object of memory cell 305 storages and the version number of this first object the first object and the front page this shop storing in host node, wherein, host node with from node a stores service cluster, like this, only when client needs reading object, from node, just by the first judging unit 303 contrasts self version number of object of storage and the version number of this object of host node storage, determine whether this object has renewal, and when having renewal, from node, by synchronous updating block 304, the object upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
In order better to understand the above embodiments, the mutual of the unit below node being comprised and module describes the data interactive mode in node, when node is during from node, refers to Fig. 4, comprising:
Transmitting element 401, receiving element 402, the second judging unit 403, acquiring unit 404, query unit 405, the first judging unit 406, synchronous updating block 407 and memory cell 408.
Transmitting element 401 by from client to renewal the information of the first object or the information of second object, be sent to host node, making host node is that the first object after upgrading distributes front page this shop or is second object distribution second edition this shop, wherein front page this shop from upgrade before the version number of the first object different, in actual applications, client is to submitting the information of second object or the information of the first object renewal to from node, the information of object comprises: the identifier of object and this object.
Receiving element 402 receives the request of obtaining the first object that client sends, and the request of wherein obtaining the first object comprises the identifier of the first object, and then receiving element 402 is sent to the second judging unit 403 by the identifier of the first object.
The version number that the second judging unit 403 judges whether to store the first object and the first object according to the identifier of the first object receiving, if not storage, the second judging unit 403 is informed acquiring unit 404 by judged result, if there is storage, the identifier of the first object is sent to query unit 404.
Acquiring unit 404, when receiving that the determination result is NO, obtains information and the front page this shop of the first object from host node.
Query unit 405 is when judgment result is that of receiving is, the version number according to the first object of storing in the identifier inquiry host node of the first object, is then sent to the first judging unit 406 by the version number of the first object inquiring.
The first judging unit 406 judges that whether the version number of the first object that memory cell 408 is stored is consistent with the front page this shop of the first object inquiring in host node, if inconsistent, judged result is sent to synchronous updating block 407, if consistent, represent that the first object does not upgrade, in actual applications, from node, the information of the first object of memory cell 408 storages can be sent to client, for example, the version number of the first object of memory cell 408 storages is 0, the front page this shop of host node storage is 1, determines inconsistent.
Synchronous updating block 407, for when judgment result is that of the first judging unit 406 receiving is inconsistent, the first object of memory cell 408 storages and the version number of the first object are synchronously updated to the first object and the front page this shop storing in host node, for example, the front page this shop of host node storage is 1, after synchronous renewal, the Wei1(front page this shop of version number of the first object of storing from node), then the information of the first object after upgrading is sent to transmitting element 401.
Transmitting element 401 is sent to client by the information of the first object obtaining after the synchronous renewal receiving.
In the present embodiment, transmitting element 401 by from client to renewal the information of the first object or the information of second object, be sent to host node, making host node is that the first object after upgrading distributes front page this shop or is second object distribution second edition this shop, wherein front page this shop from upgrade before the version number of the first object different, receiving element 402 receives the request of obtaining the first object that client sends, the request of wherein obtaining the first object comprises the identifier of the first object, when the second judging unit 403 judgement memory cell 408 are stored the version number of the first objects and this first object, query unit 405 is according to the version number of this first object of storing in the identifier inquiry host node of the first object, the first judging unit 406 judges that whether the version number of the first object that memory cell 408 is stored is consistent with the front page this shop of the first object inquiring in host node, if inconsistent, synchronous updating block 407 is synchronously updated to by the first object of memory cell 408 storages and the version number of the first object the first object and the front page this shop storing in host node, wherein, host node with from node a stores service cluster, like this, host node stores the version number of up-to-date object and this object, when client needs reading object, from node, by contrasting the version number of the version number of the object of self storing and this object of host node storage, just can determine whether this object has renewal, and when having renewal, from node, the object upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
To describing for carrying out the node of the embodiment of the present invention of above-mentioned method of data synchronization, its basic logical structure is with reference to figure 5 below, and when node is host node, in the embodiment of the present invention, embodiment of node comprises:
Memory cell 501, receiving element 502 and transmitting element 503;
Memory cell 501, for the information of storage object and the version number of this object;
Receiving element 502, for receiving from the request of the version number of querying node the first object;
Transmitting element 503, for the front page this shop of the first object is sent to from node, make to judge that from node whether the version number of the first object that self stores is consistent with the front page this shop of the first object receiving, and when inconsistent, the first object of self being stored from node and the version number of the first object are synchronously updated to the first object and the front page this shop of storage memory cell 501.
In the present embodiment, the information of memory cell 501 storage objects and the version number of object, receiving element 502 receives from the request of the version number of querying node the first object, transmitting element 503 is sent to the front page this shop of the first object from node, make to judge that from node whether the version number of the first object that self stores is consistent with the front page this shop of the first object receiving, and when inconsistent, the first object of self being stored from node and the version number of the first object are synchronously updated to the first object and the front page this shop of storage memory cell 501, like this, only when client needs reading object, from node, just by contrasting the version number of self version number of object of storage and this object of the memory cell of host node 501 storages, determine whether this object has renewal, make from node when having renewal, object after upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
In order better to understand the above embodiments, the mutual of the unit below node being comprised and module describes the data interactive mode in node, when node is host node, please consults equally Fig. 5, comprising:
Memory cell 501, receiving element 502 and transmitting element 503.
The information of memory cell 501 storage objects and the version number of this object, wherein, the information of object comprises: the identifier of object and this object.
When in stores service cluster, the first object has renewal, receiving element 502 is from the information of client or the first object from node receives renewal, and for the first object after upgrading distributes front page this shop, wherein front page this shop is different with the version number of the first object before renewal.
While having new second object to generate in stores service cluster, receiving element 502 is from client or from node, receive the information of second object, and is second object distribution second edition this shop.
Receiving element 502 receives from the request of the version number of querying node the first object, and the request of wherein obtaining the first object comprises the identifier of the first object, and then receiving element 502 is sent to transmitting element 503 by the identifier of the first object.
Transmitting element 503 is sent to the front page this shop of the first object from node, make to judge that from node whether the version number of the first object that self stores is consistent with the front page this shop of the first object receiving, and when inconsistent, the first object of self being stored from node and the version number of the first object are synchronously updated to the first object and the front page this shop of storage memory cell 501.
In the present embodiment, when in stores service cluster, the first object has renewal, receiving element 502 is from the information of client or the first object from node receives renewal, and be the first object distribution front page this shop after upgrading, wherein front page this shop from upgrade before the version number of the first object different, while having new second object to generate in stores service cluster, receiving element 502 is from client or from node, receive the information of second object, and be second object distribution second edition this shop, then receiving element 502 receives from the request of the version number of querying node the first object, transmitting element 503 is sent to the front page this shop of the first object from node, make to judge that from node whether the version number of the first object that self stores is consistent with the front page this shop of the first object receiving, and when inconsistent, the first object of self being stored from node and the version number of the first object are synchronously updated to the first object and the front page this shop of storage memory cell 501, like this, host node stores the version number of up-to-date object and this object, when client needs reading object, from node, by contrasting the version number of the version number of the object of self storing and this object of host node storage, just can determine whether this object has renewal, and when having renewal, from node, the object upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
To describing for carrying out the stores service cluster of the embodiment of the present invention of above-mentioned method of data synchronization, its basic logical structure is with reference to figure 6 below, and in the embodiment of the present invention, embodiment of stores service cluster comprises: host node 601 and from node 602;
Host node 601, for the information of storage object and the version number of object;
From node 602 for carrying out following flow process:
Receive the request of obtaining the first object that client sends, the request of wherein obtaining the first object comprises the identifier of the first object;
When storing the version number of the first objects and the first object from node 602, according to the version number of the first object of storage in the identifier inquiry host node 601 of the first object;
Whether the version number that judges the first object that self stores is consistent with the front page this shop of the first object inquiring in host node 601;
When the version number of the first object is consistent, self the first object of storage and the version number of the first object are synchronously updated to the first object and the front page this shop of storage in host node 601.
In the present embodiment, the information of host node 601 storage objects and the version number of object, from node 602, receive the request of obtaining the first object that client sends, the request of wherein obtaining the first object comprises the identifier of the first object, when storing the version number of the first objects and the first object from node 602, from node 602, according to the identifier of the first object, inquire about the version number of the first object of storage host node 601, whether the version number that judges the first object that self stores from node 602 is consistent with the front page this shop of the first object inquiring host node 601, when the version number of the first object is consistent, the first object that self is stored and the version number of the first object are synchronously updated to the first object and the front page this shop of storage in host node 601, like this, only when client needs reading object, from node 602, by contrasting the version number of the version number of the object of self storing and this object of host node 601 storages, just can determine whether this object has renewal, and when having renewal, from node 602, the object upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
In order better to understand the above embodiments, the mutual of each node below stores service cluster being comprised describes the data interactive mode in stores service cluster, please consults equally Fig. 6, comprising:
Host node 601 and from node 602.
The information of host node 601 storage objects and the version number of this object, wherein the information of object comprises: the identifier of object and this object.
From node 602 by from client to second object information or upgrade the information of the first object be sent to host node 601, in actual applications, client to from node 602, submit the information of second objects to or upgrade the information of the first object.
When in stores service cluster, the first object has renewal, the information of first object of host node 601 from this from node 602 or the renewal of this client, and be the first object distribution front page this shop after upgrading, wherein, front page this shop from upgrade before the version number of the first object different, in actual applications, the version number of object can be numeral, character or array etc., do not limit herein, for example, the version number of the first object before renewal is 0, and host node is 1 for the first object after upgrading distributes front page this shop.
It should be noted that, the version number before renewal and after upgrading of same target is also different, and the version number of different objects can be identical, also can be different.
While having new second object to generate in stores service cluster, host node 601 is from this from node 602 or the information of this client second object, and distributes the second version for second object.
From node 602, receive the request of obtaining the first object that client sends, wherein, the request of obtaining the first object comprises the identifier of the first object, in the prior art, object is one group of data, each object has a unique identifier, and the renewal of object is only for the value of data has renewal, and identifier can not change.
From node 602, according to the identifier of the first object, judge whether self stores the version number of the first object and this first object, if there is storage, from node 602, according to the identifier of the first object, inquire about the version number of the first object host node 601, if do not store, from node 602 from host node 601, obtain information and the front page this shop of the first object.
Whether the version number that judges the first object that self stores from node 602 is consistent with the front page this shop of the first object inquiring host node 601, if consistent, represent that the first object does not upgrade, for example, the version number of the first object of storing from node 602 is 0, the front page this shop of host node 601 storages is 1, represent from version number and the front page this shop of the first object of node 602 storage inconsistent, in actual applications, if the version number of the first object of storing from node 602 is consistent with front page this shop, the information of the first object that self can be stored from node 602 is sent to client.
If version number and the front page this shop of the first object of storing from node 602 are inconsistent, the first object of from node 602, self being stored and the version number of this first object are synchronously updated to the first object and the front page this shop of storage host node 601, for example, the front page this shop of host node 601 storages is 1, after synchronous renewal, the Wei1(front page this shop of version number of the first object of storing from node 602).
From node 602, the information of the first object obtaining synchronously upgrading is sent to client.
It should be noted that, host node 601 stores the version number of up-to-date object and this object, so when client-requested is obtained the information of object, host node 601 can directly be sent to client by the information of object, does not have the synchronous process of data.
In the present embodiment, the information of the first object or the information of second object that host node 601 receives after upgrading, and distribute front page this shop or be second object distribution second edition this shop for the first object after upgrading, from node 602, receive the request of obtaining the first object that client sends, when storing the version number of the first objects and this first object from node 602, from node 602, according to the identifier of the first object, inquire about the version number of this first object of storage host node 601, whether the version number that judges the first object that self stores from node 602 is consistent with the front page this shop of the first object inquiring host node 601, if inconsistent, the first object of from node 602, self being stored and the version number of the first object are synchronously updated to the first object and the front page this shop of storage host node 601, like this, host node 601 stores the version number of up-to-date object and this object, when client needs reading object, from node 602, by contrasting the version number of the version number of the object of self storing and this object of host node 601 storages, just can determine whether this object has renewal, and when having renewal, from node 602, the object upgrading is synchronously upgraded, thereby can reduce the synchronization times of object, saved computational resource simultaneously.
The above, above embodiment only, in order to technical scheme of the present invention to be described, is not intended to limit; Although the present invention is had been described in detail with reference to previous embodiment, those of ordinary skill in the art is to be understood that: its technical scheme that still can record aforementioned each embodiment is modified, or part technical characterictic is wherein equal to replacement; And these modifications or replacement do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.