Background
The current information synchronization is mainly based on a server environment, has large synchronous data volume and is not suitable for ad hoc networks or similar micro networks.
Under a low-bandwidth and unstable network environment, any one node may be unsafe and may fail. How to achieve low-load data synchronization in such a network is an urgent problem to be solved.
Disclosure of Invention
The invention provides a centerless information synchronization method and a centerless information synchronization device, which can realize information synchronization under the condition of centerless servers, so that the system operation cannot be influenced by any node realization.
In order to solve the above technical problem, the present invention provides a centerless information synchronization method, which includes:
in response to a computing device accessing a network, broadcasting a request for a unique version number of query information within the network;
each of all other computing devices within the network, in response to receiving the request, determines whether it has the information recorded thereon;
each of all other computing devices within the network, in response to being recorded with the information, broadcasts within the network its recording with the information in response;
the computing device broadcasting the request selects one from the responding computing devices as a synchronization object;
the information is synchronized between the selected synchronization object and the computing device broadcasting the request.
As an improvement of the method of the present invention, the method further comprises: a computing device within the network generating and broadcasting a new unique version number within the network in response to generating or modifying a message; each of all other computing devices within the network records the new unique version number in response to receiving the broadcast of the new unique version number.
As another refinement of the method of the present invention, each of all other computing devices within the network, in response to being recorded with the information, broadcasting within the network its recorded information in response comprises: randomly waiting a first period of time before broadcasting it with the information recorded as a response.
As a further refinement of the method of the present invention, each of all other computing devices within the network, in response to being recorded with the information, broadcasting within the network its recorded information in response further comprises: determining whether it has previously completed synchronization of the information before broadcasting it with the information recorded as a response; in response to its previous incomplete synchronization of the information, it is not broadcast within the network that it recorded the information.
As a further improvement of the method of the present invention, the selecting, by the computing device broadcasting the request, one of the responding computing devices as a synchronization object to synchronize the information comprises: waiting for a second period of time before selecting one as the synchronization object.
In order to solve the above technical problem, the present invention provides a device for implementing a centerless information synchronization method, wherein the device comprises:
a request broadcasting module for broadcasting a request for a unique version number of query information within a network in response to a computing device accessing the network;
a determination module for each of all other computing devices within the network, in response to receiving the request, determining whether it has the information recorded thereon;
a response broadcast module for each of all other computing devices within the network, in response to being recorded with the information, broadcasting within the network its recorded information as a response;
a selection module for selecting one of the computing devices broadcasting the request as a synchronization object from the responding computing devices;
a synchronization module to synchronize the information between the selected synchronization object and the computing device broadcasting the request.
As an improvement of the apparatus of the present invention, the apparatus further comprises: a version number generation and broadcast module for a computing device within the network to generate and broadcast a new unique version number in response to generating or modifying a message; a recording module for each of all other computing devices within the network to record a new unique version number in response to receiving a broadcast of the new unique version number.
As another improvement of the apparatus of the present invention, the response broadcasting module includes: a wait submodule for randomly waiting a first period of time before a computing device broadcasts a record of the information as a response.
As a further improvement of the apparatus of the present invention, the response broadcasting module further includes: a status determination submodule for determining whether synchronization of the information has been previously completed before a computing device broadcasts the information recorded with the information as a response; a broadcast inhibit sub-module for not broadcasting its recorded information within the network in response to a computing device previously not completing synchronization of the information.
To solve the above technical problem, the present invention provides a tangible computer-readable medium including a computer program for executing the above centerless information synchronization method.
To solve the above technical problem, the present invention provides an apparatus, comprising at least one processor; and at least one memory including a computer program, the at least one memory and the computer program configured to, with the at least one processor, cause the apparatus to perform at least some of the steps of the centerless information synchronization method of the present invention.
According to the invention, under an unstable network environment, a synchronization strategy is negotiated among the nodes based on the unique version number of the information, a central server is not needed, and the condition that the system operation cannot be influenced by the failure of any node is ensured to the maximum extent. In addition, any node randomly waits before making a synchronous response, so that simultaneous response of all nodes is avoided, and network congestion is caused.
Other features and advantages of the present invention will become more apparent from the detailed description of the embodiments of the present invention when taken in conjunction with the accompanying drawings.
Detailed Description
Embodiments and examples of the present invention will be described in detail below with reference to the accompanying drawings.
The scope of applicability of the present invention will become apparent from the detailed description given hereinafter. It should be understood, however, that the detailed description and the specific examples, while indicating preferred embodiments of the invention, are given by way of illustration only.
In a network environment, the addresses of all nodes are known, as are the number of nodes. The network environment may be a TCP/IP or other customized ad hoc network. Under an unstable network, any one node may be unsafe and fail. For example, in a conventional server environment, a network between a terminal and a server may be disconnected, and thus synchronization between the terminal and the server may not be performed, so that the system may not operate normally.
Fig. 1 shows a flow chart of an embodiment of a centerless information synchronization method according to the present invention. An embodiment of the method of the present invention is described in detail below with reference to the flow chart shown in fig. 1.
To apply the method of the present invention, a unique version number, such as a globally unique version number, is generated, published, and recorded for each piece of information within the network, such as group total information, group details, and the like. When a new message is generated for the first time, a globally unique version number is generated for the message and is issued, the issued content comprises the version number and the message, and each computing device in the network records the version numbers of all messages. Each time a modification is made to information at a computing device, a new unique version number is generated and broadcast within the network, a new version number is generated each time a modification is made, and each of all other computing devices within the network records the new unique version number in response to receiving the broadcast of the new unique version number. Similarly, deleting some kind of information also needs to be released. A Globally Unique version number (GUID) is, for example, a 128-bit (16-byte) binary value generated from the identification number on the network card (each network card has a Unique identification number) and the Unique number of the CPU clock, which ensures that it is Unique to all machines in the same air, and that no duplicate GUID value is generated by any two computers in the world. The globally unique version number may be used to determine the information and its version. Furthermore, the set of all globally unique version numbers may be recorded in a table, for example.
In S102, when each computing device accesses the network, after security verification, a request broadcast for querying a global information version number is issued in the network.
At S104, each of all other computing devices within the network determines whether it has the information recorded in response to receiving the request. If it is determined that the information is recorded, the process proceeds to step S106; otherwise, the process proceeds to step S120, and the corresponding computing device does not perform any action.
At S106, each of all other computing devices within the network randomly waits for S milliseconds in response to recording the information, where S may be, for example, a multiple of 10, such as 50, 60, 70, 80, etc., and other sequences, such as fibonacci, etc., may also be used to avoid network congestion caused by multiple computing devices responding simultaneously.
At S108, each of all other computing devices within the network broadcasts its recorded information as a response within the network after randomly waiting S milliseconds in response to being recorded with the information.
At S110, the computing device broadcasting the request selects one of the computing devices responding within a preset wait time, which may be, for example, 100 milliseconds or another time length, for example, the earliest responder may be selected as the data synchronization source object.
At S112, the information is synchronized between the selected synchronization object and the computing device broadcasting the request. Two data synchronization modes are available, one mode is consistency synchronization, and after synchronization, the information and the version number of the two parties are consistent. This type of synchronization is suitable for scenes with small amounts of information. For a large amount of data such as a chat message, a synchronization range can be specified, and segment synchronization can be performed. From version 1 to version n, which can be viewed as a chain of versions, the initiator can specify a range of versions to synchronize [ a, b ] data. In other words, for scenarios where the message class only cares about the most recent recording, segment synchronization is more suitable.
The method solves the problem of centerless information acquisition and avoids the influence on the overall use of the system after the cluster head node is busy in task or fails.
According to one embodiment of the method of the present invention, there may be cases where the version numbers of the information of the responding computing devices are not consistent for various reasons, for which it is determined whether a computing device has previously completed synchronization of the information before broadcasting it with the information recorded as a response within the network in response to recording the information; in response to its previous incomplete synchronization of the information, indicating that its information is not up-to-date, it is not broadcast within the network with which it is recorded. For example, a flag bit indicating whether synchronization is completed or not may be added, and the flag bit is set to "no" each time the network is disconnected, and then the version is synchronized first and synchronization is completed, and the flag bit is set to "yes" when the network is accessed. Computing devices that do not themselves complete synchronization do not respond to synchronization requests, thereby ensuring that all responding devices are synchronized and have consistent version numbers.
Fig. 2 is a schematic structural diagram of an embodiment of an apparatus for implementing a centerless information synchronization method according to the present invention, where the apparatus of the embodiment includes: a version number generation and broadcast module 202 for a computing device within the network to generate and broadcast a new unique version number in response to generating or modifying a message; a recording module 204 for each of all other computing devices within the network to record a new unique version number in response to receiving a broadcast of the new unique version number; a request broadcast module 206 for broadcasting a request for a unique version number of query information within a network in response to a computing device accessing the network; a determination module 208 for each of all other computing devices within the network, in response to receiving the request, determining whether it has the information recorded thereon; a response broadcasting module 210 for each of all other computing devices within the network broadcasting its recorded information within the network in response to being recorded with the information; a selection module 212, configured to broadcast the requested computing device to select one of the responding computing devices as a synchronization object; a synchronization module 214 to synchronize the information between the selected synchronization object and the computing device broadcasting the request.
According to one embodiment of the apparatus, the response broadcasting module includes a waiting sub-module for randomly waiting a first period of time before a computing device broadcasts the recorded information as a response.
According to another embodiment of the apparatus of the present invention, the response broadcasting module further comprises: a status determination submodule for determining whether synchronization of the information has been previously completed before a computing device broadcasts the information recorded with the information as a response; a broadcast inhibit sub-module for not broadcasting its recorded information within the network in response to a computing device previously not completing synchronization of the information.
The particular features, structures, or characteristics of the various embodiments described herein may be combined as suitable in one or more embodiments of the invention. Additionally, in some cases, the order of steps depicted in the flowcharts and/or in the pipelined process may be modified, as appropriate, and need not be performed exactly in the order depicted. In addition, various aspects of the invention may be implemented using software, hardware, firmware, or a combination thereof, and/or other computer implemented modules or devices that perform the described functions. Software implementations of the present invention may include executable code stored in a computer readable medium and executed by one or more processors. The computer readable medium may include a computer hard drive, ROM, RAM, flash memory, portable computer storage media such as CD-ROM, DVD-ROM, flash drives, and/or other devices, for example, having a Universal Serial Bus (USB) interface, and/or any other suitable tangible or non-transitory computer readable medium or computer memory on which executable code may be stored and executed by a processor. The present invention may be used in conjunction with any suitable operating system.
As used herein, the singular forms "a", "an" and "the" include plural references (i.e., have the meaning "at least one"), unless the context clearly dictates otherwise. It will be further understood that the terms "has," "includes" and/or "including," when used in this specification, specify the presence of stated features, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and/or groups thereof. The term "and/or" as used herein includes any and all combinations of one or more of the associated listed items.
The foregoing describes some preferred embodiments of the present invention, but it should be emphasized that the invention is not limited to these embodiments, but can be implemented in other ways within the scope of the inventive subject matter. Various changes and modifications of the present invention can be made by those skilled in the art without departing from the spirit and scope of the present invention, and these changes and modifications still fall within the scope of the present invention.