CN106953767B - Method, device and system for networking between devices - Google Patents

Method, device and system for networking between devices Download PDF

Info

Publication number
CN106953767B
CN106953767B CN201710220955.1A CN201710220955A CN106953767B CN 106953767 B CN106953767 B CN 106953767B CN 201710220955 A CN201710220955 A CN 201710220955A CN 106953767 B CN106953767 B CN 106953767B
Authority
CN
China
Prior art keywords
candidate
master
devices
equipment
main
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710220955.1A
Other languages
Chinese (zh)
Other versions
CN106953767A (en
Inventor
余泽健
林浩钦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201710220955.1A priority Critical patent/CN106953767B/en
Publication of CN106953767A publication Critical patent/CN106953767A/en
Application granted granted Critical
Publication of CN106953767B publication Critical patent/CN106953767B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0893Assignment of logical groups to network elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0876Aspects of the degree of configuration automation
    • H04L41/0886Fully automatic configuration
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/12Discovery or management of network topologies
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Automation & Control Theory (AREA)
  • Telephonic Communication Services (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention discloses a method, a device and a system for networking among equipment; the embodiment of the invention adopts the steps of acquiring candidate list information, then sending a first main device negotiation request to other candidate main devices in the device cluster except the device according to the candidate list information, receiving a negotiation result returned by the other candidate main devices according to the first main device negotiation request, determining whether the device is the main device according to the negotiation result returned by the other candidate main devices, and if so, establishing a communication channel with the other devices in the device cluster except the device to form a network. The scheme can improve the networking speed and efficiency among the devices.

Description

Method, device and system for networking between devices
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method, an apparatus, and a system for networking between devices.
Background
Currently, when designing a data communication system cache, each device in an access stratum cluster needs to store common data in a process in order to use the cache more recently (faster speed). The sources of these common data are different and the cost of obtaining them from the information sources is high, so that in order to increase cache utilization and maintain consistency in the cluster, it is necessary to synchronize the cache data between the devices in the cluster.
In the process of cache data synchronization, firstly, a network among devices needs to be established through networking of the devices in the cluster, and then, cache data synchronization among the devices in the cluster is realized based on the network. In the process of cache data synchronization, a master/slave model is adopted for networking.
However, in the current master/slave networking mode, a large amount of complex manual configuration needs to be performed, for example, which devices are manually configured on each device in a cluster as a master and which devices are manually configured as a slave; therefore, networking efficiency between devices is reduced.
Disclosure of Invention
The embodiment of the invention provides a networking method, a networking device and a networking system among equipment, which can improve the networking efficiency among the equipment.
The embodiment of the invention provides a networking method among devices, which comprises the following steps:
acquiring candidate list information, wherein the candidate list information comprises network addresses of candidate main equipment in an equipment cluster;
sending a first main device negotiation request to other candidate main devices except the device in the device cluster according to the candidate list information;
receiving a negotiation result returned by the other candidate main equipment according to the negotiation request of the first main equipment;
determining whether the equipment is the main equipment or not according to the negotiation result returned by other candidate main equipment;
if yes, establishing a communication channel with other equipment except the equipment in the equipment cluster to form a network.
Correspondingly, an embodiment of the present invention further provides an apparatus for networking between devices, including:
an obtaining unit, configured to obtain candidate list information, where the candidate list information includes network addresses of candidate master devices in a device cluster;
a sending unit, configured to send a first master device negotiation request to other candidate master devices in the device cluster except for the device according to the candidate list information;
a result receiving unit, configured to receive a negotiation result returned by the other candidate master devices according to the first master device negotiation request;
the first determining unit is used for determining whether the equipment is the main equipment or not according to the negotiation result returned by other candidate main equipment;
and the communication establishing unit is used for establishing a communication channel with other equipment except the equipment in the equipment cluster to form a network when the determining unit determines that the equipment is the main equipment.
Correspondingly, the embodiment of the invention also provides a networking system between the devices, which comprises the networking device between any one of the devices provided by the embodiment of the invention.
The embodiment of the invention adopts the steps of obtaining candidate list information, wherein the candidate list information comprises network addresses of candidate main devices in a device cluster, then sending a first main device negotiation request to other candidate main devices except the device in the device cluster according to the candidate list information, receiving negotiation results returned by the other candidate main devices according to the first main device negotiation request, determining whether the device is the main device according to the negotiation results returned by the other candidate main devices, and if so, establishing communication channels with the other devices except the device in the device cluster to form a network. The scheme can automatically select the main equipment through an auto-negotiation mechanism among the equipment so as to realize the networking among the equipment; a large amount of complex manual configuration is not required to be carried out on each device, so that the networking speed and efficiency among the devices can be improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1a is a schematic view of a scenario of a networking system between devices according to an embodiment of the present invention;
fig. 1b is a schematic flowchart of a networking method between devices according to an embodiment of the present invention;
fig. 1c is a schematic diagram of an apparatus cluster according to an embodiment of the present invention;
fig. 1d is a schematic diagram of another device cluster according to an embodiment of the present invention;
FIG. 1e is a diagram of a negotiation election master device according to an embodiment of the present invention;
FIG. 1f is a schematic diagram of a networking provided by an embodiment of the invention;
fig. 2 is a flowchart of a negotiation master device according to an embodiment of the present invention;
FIG. 3 is a flow diagram of request processing provided by an embodiment of the invention;
FIG. 4 is a schematic diagram of a shopping number system according to an embodiment of the present invention;
fig. 5a is a schematic processing flow diagram of a candidate server in a negotiation process according to an embodiment of the present invention;
fig. 5b is a schematic processing flow diagram of a candidate server in a negotiation process according to an embodiment of the present invention;
fig. 6a is a schematic structural diagram of a networking device between devices according to an embodiment of the present invention;
fig. 6b is a schematic structural diagram of a second configuration of a networking device between devices according to an embodiment of the present invention;
fig. 6c is a schematic structural diagram of a networking apparatus between devices according to an embodiment of the present invention;
fig. 6d is a schematic diagram of a fourth structure of a networking device between devices according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a method, a device and a system for networking among devices.
The embodiment of the present invention provides a networking system between devices, where the system may include any one of the networking devices between devices provided in the embodiments of the present invention, referring to fig. 1a, taking a device as an example, the networking device between devices may be specifically integrated in a server. In fig. 1a, the networking apparatus may be integrated in each candidate master device, i.e. candidate server. In addition, the networking system between the devices may also include other devices, for example, a slave device subordinate to the master device, and the like. Wherein, the slave device can be used for establishing a communication channel with the master device after determining the master device to realize networking and the like.
As shown in fig. 1a, when networking is required, for example, when networking is required in a process of synchronizing cache data, a candidate master device (e.g., a candidate server) may obtain candidate list information, where the candidate list information includes a network address of the candidate master device in an equipment cluster, then send a first master device negotiation request to other candidate master devices in the equipment cluster except for the own device according to the candidate list information, receive a negotiation result returned by the other candidate master devices according to the first master device negotiation request, determine whether the own device is a master device according to the negotiation result returned by the other candidate master devices, and if so, establish a communication channel with the other devices in the equipment cluster except for the own device to form a network.
In addition, when determining that the candidate master device is not the master device, the candidate master device may determine that the candidate master device is the slave device, and establish a communication channel with the current master device to implement networking. For example, when it is determined that the device is not a master device and a master device already exists, the device may be determined to be a slave device.
The details will be described below separately.
The first embodiment,
In this embodiment, a networking device between devices will be described from the perspective, and the networking device between the devices may be specifically integrated in a network device such as a server.
A method for networking between devices comprises the following steps: acquiring candidate list information, wherein the candidate list information comprises network addresses of candidate main devices in a device cluster, then sending a first main device negotiation request to other candidate main devices in the device cluster except the device according to the candidate list information, receiving negotiation results returned by the other candidate main devices according to the first main device negotiation request, determining whether the device is the main device according to the negotiation results returned by the other candidate main devices, and if so, establishing communication channels with the other devices in the device cluster except the device to form a network.
As shown in fig. 1b, a specific process of the networking method between the devices may be as follows:
101. candidate list information is obtained, wherein the candidate list information comprises network addresses of candidate master devices in the device cluster.
The candidate list information may be configured in advance and stored in the storage unit of the device, for example, the candidate list information may be configured in advance in the candidate master device. At this time, the candidate master device may extract the candidate list information from the local storage unit.
In this embodiment, the candidate master device may use a plurality of candidate devices providing the hosting service, and in this case, the candidate list information may include a network address of each candidate master device. In practical applications, the network Address may be an IP (Internet Protocol Address) of the candidate host device, and the like.
For example, referring to fig. 1c, the candidate master devices may be servers, and the number is 3, that is, the device cluster includes candidate server 1, candidate server 2, and candidate server 3; at this time, the candidate list information may include the IP of the candidate server 1 as IP1, the IP of the candidate server 2 as IP2, and the IP of the candidate server 3 as IP 3.
In practical applications, the device cluster may further include a slave device, that is, candidate master devices and slave devices exist in the device cluster. That is, in the initial stage of networking, two devices exist in the device cluster, one is a candidate master device, and the other is an already determined slave device. Referring to fig. 1d, the device cluster includes: candidate server 1, candidate server 2, and candidate server 3, and slave server 1, slave server 2, and slave server 3.
102. And sending a first main device negotiation request to other candidate main devices except the device in the device cluster according to the candidate list information.
Specifically, for example, the candidate master devices respectively integrate the networking apparatuses among the devices, the candidate master devices may respectively send first master device negotiation requests to the other candidate master devices to negotiate with the other candidate master devices or inquire whether the candidate master devices can provide the host service, that is, negotiate with the candidate master devices or inquire whether the candidate master devices can become the master device.
For example, referring to fig. 1e, candidate server 1 may send master negotiation requests to candidate server 2 and candidate server 3, respectively. Similarly, candidate server 2 may send a master device negotiation request to candidate server 1 and candidate server 3, respectively, and candidate server 3 may send a master device negotiation request to candidate server 1 and candidate server 2, respectively; the candidate servers directly send negotiation requests to each other, so that the candidate servers can negotiate with each other to elect the master device.
In practical application, the first master device negotiation request may also carry a network address of the device, such as an IP of the device, so that other candidate master devices may return a corresponding negotiation result based on the network address of the candidate master devices and the network address of the request sender.
103. And receiving a negotiation result returned by the other candidate main equipment according to the negotiation request of the first main equipment.
Wherein, the negotiation may result in: indication information for indicating agreement with the request sender device as a master device, and indication information for indicating disagreement with the request sender device as a master device.
For example, when the device with the largest device IP address is selected as the master device, and when the IP of other candidate master devices is greater than the IP of the request sender device, the indication information that the request sender device is not approved as the master device is returned; and when the IP of other candidate main devices is not larger than the IP of the request sender device, returning indication information for agreeing to the request sender device as the main device. Or, for another example, when other candidate master devices have been elected as master devices, indication information that does not agree to request the sender device as a master device may be returned; or when the storage space of other candidate main devices is insufficient or the network connection is unstable, returning indication information for agreeing to the request sender device as the main device.
In practical applications, the value of the specific parameter may be used to indicate that the sender is approved or not approved as the device, that is, the indication information of this embodiment may include an indication parameter for indicating whether the sender device is approved as the master device.
The indication parameter may be a parameter indicating whether the request sender device is approved as the master device, for example, different parameter values of the indication parameter may represent attitudes (approved or not approved) for the request sender device as the master device.
For example, when the parameter value indicating the parameter is 0, it means: agreeing to the request sender device as the master device; when the parameter value of the indicated parameter is 3, it means that: the request sender device is not granted as a master device.
As another example, the content of different fields of the indication parameter may indicate the attitude (agreement or disagreement) for the request sender device as the master device; for example, when the indication parameter is Y, it indicates that: agreeing to the request sender device as the master device; when the indication parameter is N, the following conditions are represented: the request sender device is not granted as a master device.
Referring to fig. 1e, after the candidate server 1 sends the primary device negotiation requests to the candidate server 2 and the candidate server 3, respectively, the candidate server 2 and the candidate server 3 will return corresponding negotiation results according to the requests. The negotiation result may be used as an indication parameter indicating whether the request sender device is granted as a master device. For example, the negotiation result may include: the parameter value of the indicator parameter 1 may be 0, and the parameter value of the indicator parameter 2 may be 3.
104. And determining whether the device is the master device according to the negotiation result returned by the other candidate master devices, and if so, executing step 105.
Specifically, the negotiation result includes: the step "determining whether the device is the master device according to the negotiation result returned by the other candidate master devices" may include:
acquiring the number of indication parameters indicating that the device is agreed as a master device;
when the number is larger than or equal to a preset threshold value, determining that the equipment is the main equipment;
when the number is smaller than the preset threshold, it is determined that the device is not a master device, for example, it may be determined that the device is a slave device.
The preset threshold may be set based on the number of candidate master devices, and preferably, the preset threshold may be one less than the total number of candidate master devices; that is, when all the other candidate master devices agree that the device is the master device, the device is determined to be the master device. For example, the number of candidate masters is N (N > 1, and is a positive integer), and the preset threshold may be N-1.
For another example, in some cases, a candidate master device is already determined as a master device before networking, and then the negotiation result may further include: in practical applications, different parameter values may be used to indicate whether the other candidate master device is the master device, for example, the other candidate master device may be referred to as the master device with the indication parameter having the parameter value of 1. At this time, "determining whether the device is the master device according to the negotiation result returned by the other candidate master devices" may include:
when the negotiation result comprises an indication parameter for indicating that other candidate main equipment is the main equipment, determining that the equipment is not the main equipment;
when the negotiation result does not comprise an indication parameter for indicating other candidate main equipment as the main equipment, acquiring the number of the indication parameters indicating that the equipment agrees to be the main equipment;
and determining whether the equipment is the main equipment or not according to the number.
For example, the number may be compared with a preset threshold, and when the number is greater than the preset threshold, it is determined that the device is the master device, otherwise, it is determined that the device is not the master device.
Optionally, in some cases, the candidate master device is already determined to be a slave device before networking, and the negotiation result may further include: indication information, such as an indication parameter, for indicating that the requesting receiver device, i.e., the other candidate master devices, is a slave device; in practical applications, whether the other candidate master device is a slave device may be indicated by an indication parameter with a different parameter value, for example, the other candidate master device may be indicated as a slave device by an indication parameter with a parameter value of 2; at this time, the step of "determining whether the own device is the master device according to the number" may include:
setting a preset threshold according to the number of indication parameters for indicating other candidate master devices as slave devices and the total number of the candidate master devices;
comparing the number of the indication parameters which indicate that the device agrees to be used as the main device with the preset threshold value;
when the current device is larger than or equal to a preset threshold value, determining that the current device is a main device; otherwise, it is not the master.
For example, if the number of candidate masters is N, and if the number of indication parameters for indicating that other candidate masters are slaves is M, then the preset threshold may be N-M.
105. And establishing a communication channel with other equipment except the equipment in the equipment cluster so as to realize networking.
The capacity expansion and the capacity reduction of the equipment network are facilitated; in this embodiment, a communication channel is established with other devices, and the other devices in the device cluster may actively search for the master device and initiate a communication connection, so as to implement automation of capacity expansion and capacity reduction. That is, the step of "establishing a communication channel with other devices in the device cluster except the device" may include:
receiving a main equipment inquiry request initiated by other equipment in the equipment cluster;
returning response information for indicating that the equipment is the main equipment according to the inquiry request of the main equipment;
receiving a communication establishment request sent by the other equipment according to the response information;
and establishing a communication channel with the other candidate master equipment according to the communication establishment request.
The device cluster in this embodiment may include one device, which is a candidate master device, or may include two devices, which are a candidate master device and a slave device. When the device cluster only comprises the candidate master device, other devices in the device cluster refer to the candidate master devices except the device; when the device cluster includes candidate master devices and slave devices, the other devices in the device cluster refer to the candidate master devices and slave devices except the device.
Referring to fig. 1e, candidate server 1, candidate server 2, and candidate server 3 negotiate with each other to elect candidate server 3 as the master. Referring to fig. 1f, the candidate server 1, the candidate server 2, the slave server 1, the slave server 2, and the slave server 3 actively search or inquire the current master device according to the candidate list information, and specifically, these devices actively send master device inquiry requests to the other devices in the device cluster according to the candidate list information to search or inquire the current master device; taking the master device as the candidate server 3 as an example, then the candidate server 1, the candidate server 2, the slave server 1, the slave server 2, and the slave server 3 will actively establish a communication channel with the candidate server 3 to complete networking.
The above describes a procedure in which the present device establishes communication with another device when it is determined that the present device is the master device. The following describes a process of establishing communication between the device and other devices in order to facilitate capacity expansion and capacity reduction of the device network when the device is determined to be a slave device. Specifically, the method according to the embodiment of the present invention may further include, after determining that the device is a slave device:
sending a main equipment inquiry request to the other candidate main equipment according to the candidate list information;
receiving response information returned by the other candidate main equipment according to the main equipment inquiry request;
and determining the currently negotiated main equipment according to the response information, and establishing a communication channel with the main equipment.
The embodiment of the invention adopts the mode that the slave equipment actively searches the currently selected master equipment and actively establishes communication with the master equipment, can facilitate the capacity expansion and the capacity reduction of the network and can support the hot plug and pull type capacity expansion and capacity reduction. For example, when a new slave device joins in, the new slave device only needs to search for the current master device, then actively establishes a communication channel with the master device, does not need to stop or restart the service, and modifies the configuration information of each device; similarly, during capacity reduction, the capacity reduction equipment is only required to be disconnected from the main equipment, service does not need to be stopped or restarted, and configuration information of each equipment is modified; compared with the existing networking mode (the existing networking mode is that the master device is connected with each slave device to form a network, and a server needs to be stopped or restarted to modify master-slave configuration information on the manual modification device during capacity expansion or capacity reduction, and the like), the scheme of the invention can improve the capacity expansion speed and efficiency.
Optionally, when determining that the device is not the master device, determining that the device is the slave device; specifically, the networking method of this embodiment may further include:
when the equipment is determined not to be the main equipment, determining whether the main equipment exists at present;
and if so, determining that the equipment is the slave equipment.
That is, after the candidate master devices negotiate with each other to form a master device, other candidate master devices in the device cluster actively become slave devices, and actively establish a communication channel with the elected master device to form a network.
Optionally, after determining that the device is a master device or after determining that the device is a slave device, the state identifier of the device may be modified, so that the modified state identifier indicates that the device is a master device or a slave device. For example, the status flag may be a parameter, that is, a status parameter, and a parameter value of the status parameter may indicate that the device is a master device, a slave device, or the like. For example, the state parameter may be a state, which indicates that the device is in an initial state when the state is 0, indicates that the device is a master device when the state is 1, and indicates that the device is a slave device when the state is 2.
For example, in the initial stage, when the present apparatus is determined to be the master apparatus, the value of the state may be modified to change the value of the state from 0 to 1 so that the state becomes 1; when the present device slave is determined, the value of the state is changed from 0 to 2 so that the state becomes 2.
Based on the above description, referring to fig. 2, for a candidate master device, in case that there is no master device and no slave device before networking, the process of negotiating the master device may be as follows:
200. candidate list information is obtained, wherein the candidate list information comprises network addresses of candidate master devices in the device cluster.
201. And sending a main equipment negotiation request to other candidate main equipment in the equipment cluster according to the candidate list information.
For example, candidate server 1 sends master negotiation requests to candidate server 2 and candidate server 3, respectively.
202. Receiving a negotiation result returned by other candidate main equipment according to the request, wherein the negotiation result comprises: an indication parameter for indicating whether the other candidate master devices agree that the device is the master device.
For example, the candidate server 1 receives the indication parameter returned by the candidate server 2 to indicate whether the candidate server 2 agrees with the device as the master device, and the candidate server 1 receives the indication parameter returned by the candidate server 3 to indicate whether the candidate server 2 agrees with the device as the master device.
The indication parameter for indicating whether the other candidate master devices agree with the device as the master device may be expressed by different values, for example, a value of 0 indicates agreement, and a value of 3 indicates disagreement.
203. And acquiring the number of indication parameters for agreeing to the equipment as the main equipment.
For example, when a value of 3 indicates that the device is not approved as a parameter of the master device, the number of 3 is acquired.
204. It is determined whether the number is equal to the total number of candidate masters, if so, step 205 is performed, and if not, step 206 is performed.
In the case that no master-slave device exists before networking, the embodiment of the present invention may determine whether the number of the indication parameters agreeing to the device as the master device is equal to the total number of the candidate master devices, that is, whether the whole ticket is called as the master device by the device.
For example, whether the number of the number 3 is equal to the total number of the candidate servers, that is, 2 is determined, and if the number of the number 3 is 2, it indicates that both the candidate server 2 and the candidate server 3 agree with the candidate server 1 as the master device, and at this time, it is determined that the candidate server 1 is the master device.
205. And changing the state identifier of the equipment so that the state identifier indicates that the equipment is the main equipment.
For example, the value of the state flag is changed from 0 to 1 so that state becomes 1.
206. And judging whether the main equipment exists at present, if so, executing the step 207, and if not, returning to the step 200.
In this embodiment, when the master device has been negotiated or determined, all candidate master devices may be taken as slave devices.
207. And changing the state identifier of the equipment so that the state identifier indicates that the equipment is slave equipment.
For example, the value of the state flag is changed from 0 to 2 so that state becomes 2.
However, in the mutual negotiation process between the devices, a device not only needs to send a negotiation request to the other candidate master device to inquire whether the device is the master device, but also needs to receive the negotiation request sent by the other candidate master device and to respond or respond to the negotiation request so that the other candidate master device can determine whether the device itself is the master device. The following will describe in detail the processing procedure of the candidate master device for the negotiation request sent by the other candidate master devices:
on the basis of the above step content, the networking method of this embodiment may further include:
receiving a second main device negotiation request sent by other candidate main devices according to the candidate list information, wherein the second main device negotiation request carries network addresses of the other candidate main devices;
and returning corresponding negotiation results to other candidate main equipment according to the network address of the equipment and the network addresses of other candidate main equipment.
For example, the candidate server 1 receives a main device negotiation request sent by the candidate server 2, where the request carries an IP address, i.e., IP2, of the candidate server 2, and the candidate server 1 may return a corresponding negotiation result to the candidate server 2 according to its own IP address (i.e., IP1) and the IP address of the candidate server.
When the negotiation result includes indication information, such as an indication parameter, for indicating whether to approve the other candidate master device as the master device, the candidate master device may return the indication parameter of approving or disapproving the other candidate master device as the master device to the other candidate master device according to the network address of the candidate master device and the network of the other candidate master device. For example, when agreement or disagreement of other candidate master devices as master devices is indicated by parameter values of the indicating parameters, the indicating parameters of different parameter values may be returned to the other candidate master devices. If the parameter value is 0, an indication parameter can be returned to the other candidate main devices to indicate that the other candidate main devices are agreed to be used as the main devices; another example is to return an indication parameter with a parameter value of 3 to the other candidate master device to indicate that the other candidate master device is not approved as the master device.
In this embodiment, there are various ways to return the negotiation result according to the network addresses of the device and the other candidate master devices, for example, two network addresses may be compared, and the negotiation result of the response may be returned according to the comparison result. That is, the step of returning the corresponding negotiation result to the other candidate master device according to the network address of the local device and the network addresses of the other candidate master devices may include:
comparing the network address of the equipment with the network addresses of other candidate main equipment to obtain a comparison result;
and returning corresponding negotiation results to the other candidate main equipment according to the comparison result.
Taking the network address as an IP example, the IP sizes of the device and other candidate master devices may be compared, for example, when the IP of the device is smaller than the IP of the other candidate master devices, an indication slave parameter indicating that the other candidate master devices are allowed to be used as the master devices is returned to the other candidate master devices; and when the IP of the equipment is not less than the IP of other candidate main equipment, returning an indication slave parameter for indicating that the other candidate main equipment is not approved as the main equipment to the other candidate main equipment.
For example, after the candidate server 1 receives the main device negotiation request sent by the candidate server 2, the request carries the IP address of the candidate server 2, i.e., IP2, and when the IP address of the candidate server 1 itself (i.e., IP1) is smaller than IP2, an indication parameter with a parameter value of 0 is returned to the candidate server 2 to inform the candidate server 2 that the candidate server 2 agrees to the candidate server 2 as the main device; when the IP1 is not less than the IP2, returning the parameter of 3 indicates a parameter to the candidate server 2 to inform the candidate server 2 that it does not agree with the candidate server 2 as the master. Similarly, the candidate server 1 also applies to the negotiation request sent by the candidate server 3.
It should be understood that: in some other embodiments, the candidate master device with the smallest IP may also be selected as the master device, and the selection process is similar to the selection of the candidate master device with the largest IP as the master device, which is not described herein again.
Optionally, considering that in some cases, some candidate master devices are already master devices or slave devices before networking, at this time, after receiving the negotiation request sent by other candidate master devices, the judgment of the master device and the slave device needs to be performed first, so that it can be quickly determined that the master device performs networking. That is, after receiving the negotiation request of the second device and before returning the negotiation result, the method of the embodiment of the present invention may further include:
judging whether the equipment is a main equipment at present;
if not, judging whether the equipment is the slave equipment currently;
if not, the step of returning the corresponding negotiation result to the other candidate main equipment is executed according to the network address of the equipment and the network addresses of the other candidate main equipment.
Optionally, when the current device is judged to be the master device or the slave device, a corresponding negotiation result to other candidate master devices may also be obtained; at this time, the negotiation result may include: indication information for indicating that the device is a master device or a slave device; for example, an indication parameter for indicating that the device is a master device or a slave device may be included. In practical application, the device can be indicated as a master device or a slave device through indication parameters of different parameter values. For example, the device may be represented as a master device by an indication parameter with a parameter value of 1, and may be represented as a slave device by an indication parameter with a parameter value of 2, and so on.
Referring to fig. 3, for a candidate master device, the process flow after receiving the master device negotiation request may be as follows:
301. receiving a main device negotiation request sent by other candidate main devices in the device cluster, wherein the request carries network addresses, such as IP, of the other candidate main devices.
302. And judging whether the equipment is the main equipment currently, if not, executing step 303, and if so, executing step 307.
303. And judging whether the equipment is the slave equipment currently, if not, executing the step 304, and if so, executing the step 308.
304. And judging whether the IP of the device is smaller than the IP of other candidate main devices, if so, executing the step 305, and if not, executing the step 306.
305. And returning a first indication parameter for indicating agreement of the other candidate main devices as the main devices to the other candidate main devices.
306. And returning a second indication parameter for indicating that the other candidate main devices are not approved as the main devices to the other candidate main devices.
307. And returning a third indication parameter for indicating that the equipment is the main equipment to other candidate main equipment.
308. And returning a fourth indication parameter for indicating that the device is the slave device to other candidate master devices.
The first indication parameter, the second indication parameter, the third indication parameter, and the fourth indication parameter may be indication parameters with different parameter values, for example, the first indication parameter may be 0, the second indication parameter may be 3, the third indication parameter may be 1, and the fourth indication parameter may be 2.
For example, after receiving a negotiation request sent by the candidate server 2, the candidate server 1 may determine whether itself is a master device, if so, return an indication parameter with a parameter value of 1 to the candidate server 2 to inform the candidate server 2 that the candidate server 1 is a master device, if not, the candidate server 1 further determines whether itself is a slave device, and if so, return an indication parameter with a parameter value of 2 to the candidate server 2; if the device is not a slave device, the candidate server 1 needs to compare the IP of the candidate server 2 with the IP of the candidate server 1, if the IP of the candidate server 2 is smaller than the IP of the candidate server 2, an indication parameter with a parameter value of 0 is returned to the candidate server 2, and if the IP of the candidate server 2 is not smaller than the IP of the candidate server, an indication parameter with a parameter value of 3 is returned to the candidate server 2.
Optionally, in order to improve the stability of the device network and reduce the network maintenance cost, in this embodiment, after the master device is selected, if the master device goes down, another master device is automatically selected again through the negotiation mechanism to continue the service. For example, in the normal established communication phase, if the master crashes, the entire network automatically falls back to the negotiation phase, and the remaining master candidate masters use the same negotiation mechanism to determine the new master. That is, after determining that the device is a slave device, the method of this embodiment may further include: when the current master device is detected to be down, the step 101 and 105 may be returned to be executed to perform the networking again.
The networking method provided by the embodiment of the invention can be applied to the synchronization process of the cache data, after networking, the slave devices in the device cluster send respective cache data to the master device, and the slave devices forward to other slave devices through the master device so as to achieve the purpose of cache data synchronization; the networking method can improve the efficiency of cache data synchronization. For example, the networking method provided by the embodiment of the present invention may be applied to a shopping number system, and referring to fig. 4, the shopping number system includes a data service cluster and a Web service cluster. The data service cluster can adopt the networking mode provided by the embodiment of the invention to select the master equipment to form a network so as to carry out data cache synchronization. As shown in fig. 4, after receiving a request, a web server in a web service cluster reads data from a local cache, and when the data is successfully read from the local cache, the web server executes a front-end data processing logic and then returns a corresponding request result; when the data reading from the local data cache fails, the web server can acquire the data from the data server cluster, and at the moment, the web server triggers the servers in the data server cluster to realize networking by adopting the networking method provided by the embodiment of the invention, so that the servers in the data server cluster perform cache data synchronization, and send the synchronized cache data to the corresponding web server, and the web server executes the front-end data processing logic and then returns the corresponding request result.
As can be seen from the above, in the embodiment of the present invention, the master device is automatically elected in an inter-device auto-negotiation manner to implement networking between devices, and it is not necessary to perform a large amount of complicated manual configuration on each device, so that networking speed and efficiency between devices can be improved. In addition, the slave device automatically searches the master device and establishes communication, so that the automation of capacity expansion and capacity reduction is realized, and the scheme supports hot plug and pull capacity expansion and capacity reduction (wherein plug and play means that the online and offline of the slave does not influence the operation of the conventional networking device and does not need configuration change). Because the scheme does not need to restart the service to carry out equipment configuration again during capacity expansion or capacity reduction, the capacity expansion and reduction speed and efficiency are improved, and the influence of the capacity expansion and reduction on the networking equipment is reduced.
In addition, the networking scheme provided by the embodiment of the invention can also reduce the number of communication channels and save communication resources. For example, when n devices are networked in the existing networking manner, n × n (n-1)/2 communication channels are required; the networking scheme provided by the embodiment of the invention can realize the communication between any two machines in the cluster only by n-1 communication channels in the networking of n devices, thereby realizing the minimization of the communication channels and saving the communication resources.
Example II,
The method described in the first embodiment is further illustrated by way of example.
In this embodiment, a description will be given taking an example in which a networking device between devices is integrated in each candidate server.
Referring to fig. 1d, the device cluster may include a candidate server 1, a candidate server 2, and a candidate server 3 as well as a slave server 1, a slave server 2, and a slave server 3. The candidate server 1, the candidate server 2, and the candidate server 3 are all integrated with the networking device provided by the embodiment of the present invention.
When networking is needed, all the candidate servers mutually send main equipment negotiation requests, and the same processing process is executed to elect the main server. The same processing procedure performed by each candidate master device during the negotiation procedure will be described below from the perspective of the candidate server 1.
On one hand, the candidate server 1 needs to send a negotiation request to other candidate servers in the negotiation process to determine whether the candidate server can be used as a main device; as shown in fig. 5a, the processing flow of the candidate server 1 in the master device negotiation process is as follows:
400. the candidate server 1 obtains candidate list information including network addresses of the candidate servers within the device cluster.
401. And the candidate server 1 respectively sends a main equipment negotiation request to the candidate server 2 and the candidate server 3 according to the candidate list information, wherein the request carries the IP of the candidate server 1.
402. The candidate server 2 and the candidate server 3 respectively return corresponding negotiation results to the candidate server 1 according to the main device negotiation request.
Wherein, the negotiation result may include: an indication parameter for indicating whether the candidate server 1 is agreed to be the master device, or an indication parameter for indicating that itself is the master device or the slave device.
For example, the present embodiment may indicate whether the candidate server 1 is agreed as the master device by different parameter values, for indicating whether it is the master device or the slave device. For example, when the parameter value is 0, it indicates that the request receiver (candidate server 2 or candidate server 3) agrees with the candidate server 1 as the master, when the parameter value is 1, it indicates that the request receiver (candidate server 2 or candidate server 3) is the master, when the parameter value is 2, it indicates that the request receiver (candidate server 2 or candidate server 3) is the slave, and when the parameter value is 3, it indicates that the request receiver (candidate server 2 or candidate server 3) does not agree with the candidate server 1 as the master.
403. The candidate server 1 determines whether itself is the main server according to the negotiation result returned by the candidate server 2 and the candidate server 3, if not, step 404 is executed, and if so, step 406 is executed.
For example, when there is an indication parameter with a parameter value of 1, the candidate server 1 determines that it is not the master device; when the indicating parameters with the parameter values of 1 and 2 do not exist, the candidate server 1 counts the number of the indicating parameters with the parameter values of 0, and if the number of the indicating parameters is equal to the total number of the candidate servers of 3, the candidate server can be determined to be the main server; for another example, when there is no indicating parameter with a parameter value of 1 and an indicating parameter with a parameter value of 2, the number a of indicating parameters with a parameter value of 0 and the number b of indicating parameters with a parameter value of 2 may be counted; if a is equal to c-b, then it is determined to be the primary server, and c is the total number of candidate servers, here 3.
404. The candidate server 1 determines whether a main server exists currently, if yes, step 405 is executed, and if not, step 400 is executed again to perform renegotiation.
405. The candidate server 1 marks itself as the slave server.
For example, the candidate server 1 changes the state identifier of the device, so that the state identifier indicates that the device is a slave server.
406. The candidate server 1 marks itself as the primary server.
For example, the candidate server 1 changes the state identifier of the device, so that the state identifier indicates that the device is the main server.
In this embodiment, when the candidate server 1 is used as a master server, the other servers in the device cluster, such as the candidate server 2 and the candidate server 3, the slave server 2, and the slave server 3, will send master device query requests to the other servers in the device cluster according to the candidate list information to search for the current master server, and then actively establish a communication channel with the master server (i.e., the candidate server 1) to form a network.
When the candidate server 1 does not act as the master server and has elected to be the master server (e.g., the candidate server 3), the candidate server 1 sends a master inquiry request to the rest of the servers in the device cluster to search for the current master server, and then actively establishes a communication channel with the master server (i.e., the candidate server 1) to form a network.
On the other hand, the candidate server 1 needs to respond to the negotiation requests sent by other candidate servers in the negotiation process, so that the other candidate servers can elect the main server. As shown in fig. 5b, the request processing flow of the candidate server 1 in the main device negotiation process is as follows:
501. the candidate servers 1 respectively receive the main device negotiation requests sent by the candidate servers 2, and the requests carry the IP of the candidate servers 2.
502. The candidate server 1 determines whether the device is currently the main server, if not, step 503 is executed, and if so, step 507 is executed.
503. Candidate server 1 determines whether the device is currently a slave server, if not, step 504 is executed, and if so, step 508 is executed.
504. The candidate server 1 determines whether the IP of the own device is smaller than the IP of the candidate server 2, and if so, executes step 505, and if not, executes step 506.
505. The candidate server 1 returns a first indication parameter indicating agreement of the candidate server 2 as the primary server to the candidate server 2.
506. The candidate server 1 returns a first indication parameter indicating that the candidate server 2 is not approved as the primary server to the candidate server 2.
507. The candidate server 1 returns a third indication parameter indicating that the device is the main server to the candidate server 2.
508. The candidate server 1 returns a fourth indication parameter indicating that the device is a slave server to the candidate server 2.
The first indication parameter, the second indication parameter, the third indication parameter, and the fourth indication parameter may be indication parameters with different parameter values, for example, the first indication parameter may be 0, the second indication parameter may be 3, the third indication parameter may be 1, and the fourth indication parameter may be 2.
Similarly, the processing procedure of the negotiation request sent by the candidate server 3 by the candidate server 1 is the same as the processing procedure of the negotiation request sent by the candidate server 2, and is not described herein again.
The above request processing procedure and the procedure of determining whether the own device is the master device may be performed in any order for the candidate server 1, for example, the two procedures may be performed in parallel.
Although the present embodiment is described with respect to the candidate server 1 as a station to describe the processing procedure of the candidate master device in the master device negotiation, it should be understood that the station is the same as or similar to the execution procedure of the candidate server 1 in the rest of the candidate server and the master device negotiation procedure, and reference may be made to the execution procedure of the candidate server 1 described above.
As can be seen from the above, in the embodiment of the present invention, the master device is automatically elected in an inter-device auto-negotiation manner to implement networking between devices, and it is not necessary to perform a large amount of complicated manual configuration on each device, so that networking speed and efficiency between devices can be improved. In addition, the embodiment of the invention realizes the automation of capacity expansion and capacity reduction by automatically searching the master equipment and establishing communication through the slave equipment, so that the scheme supports hot plug capacity expansion and capacity reduction. Because the scheme does not need to restart the service to carry out equipment configuration again during capacity expansion or capacity reduction, the capacity expansion and reduction speed and efficiency are improved, and the influence of the capacity expansion and reduction on the networking equipment is reduced.
In addition, the networking scheme provided by the embodiment of the invention can also reduce the number of communication channels and save communication resources. For example, when n devices are networked in the existing networking manner, n × n (n-1)/2 communication channels are required; the networking scheme provided by the embodiment of the invention can realize the communication between any two machines in the cluster only by n-1 communication channels in the networking of n devices, thereby realizing the minimization of the communication channels and saving the communication resources.
Example III,
In order to better implement the above method, an embodiment of the present invention further provides a networking device between devices, and as shown in fig. 6a, the connection device of the wireless local area network includes: the acquiring unit 601, the transmitting unit 602, the result receiving unit 603, the first determining unit 604, and the communication establishing unit 605 are as follows:
(1) an acquisition unit 601;
an obtaining unit 601, configured to obtain candidate list information, where the candidate list information includes network addresses of candidate master devices in the device cluster.
The candidate list information may be configured in advance and stored in the storage unit of the device, for example, the candidate list information may be configured in advance in the candidate master device. At this time, the acquisition unit 601 may extract candidate list information from the local storage unit.
In this embodiment, the candidate master device may use a plurality of candidate devices providing the hosting service, and in this case, the candidate list information may include a network address of each candidate master device. In practical applications, the network Address may be an IP (Internet Protocol Address) of the candidate host device, and the like.
(2) A transmitting unit 602;
a sending unit 602, configured to send a first master device negotiation request to candidate master devices in the device cluster, except for the device itself, according to the candidate list information.
(3) A result receiving unit 603;
a result receiving unit 603, configured to receive a negotiation result returned by the other candidate master device according to the first master device negotiation request.
Wherein, the negotiation may result in: indication information for indicating agreement with the request sender device as a master device, and indication information for indicating disagreement with the request sender device as a master device.
In practical applications, the value of the specific parameter may be used to indicate that the sender is approved or not approved as the device, that is, the indication information of this embodiment may include an indication parameter for indicating whether the sender device is approved as the master device. For example, when the parameter value of the indication parameter is 0, it means that: agreeing to the request sender device as the master device; when the parameter value of the indicated parameter is 3, it means that: the request sender device is not granted as a master device.
(4) A first determination unit 604;
a first determining unit 604, configured to determine whether the device is a master device according to a negotiation result returned by another candidate master device.
The negotiation result comprises: an indication parameter indicating whether or not the request sender device (i.e., the present device) is granted as a master device; the first determining unit 604 may specifically be configured to: acquiring the number of indication parameters indicating agreement of the equipment as main equipment, and determining the equipment as the main equipment when the number is greater than or equal to a preset threshold value; when the number is smaller than the preset threshold, it is determined that the device is not the master device, for example, it may be determined that the device is the slave device.
The preset threshold may be set based on the number of candidate master devices, and preferably, the preset threshold may be one less than the total number of candidate master devices; that is, when all the other candidate master devices agree that the device is the master device, the device is determined to be the master device. For example, the number of candidate masters is N (N > 1, and is a positive integer), and the preset threshold may be N-1.
For another example, in some cases, a candidate master device is already determined as a master device before networking, and then the negotiation result may further include: the indication information may include an indication parameter for the other candidate master devices as the master device, and in practical applications, different parameter values may be used to indicate whether the other candidate master devices are the master devices. The first determining unit 604 may be specifically configured to:
when the negotiation result comprises an indication parameter for indicating that other candidate main equipment is the main equipment, determining that the equipment is not the main equipment;
when the negotiation result does not comprise an indication parameter for indicating other candidate main equipment as the main equipment, acquiring the number of the indication parameters indicating that the equipment agrees to be the main equipment;
and determining whether the equipment is the main equipment or not according to the number.
For example, the number may be compared with a preset threshold, and when the number is greater than the preset threshold, it is determined that the device is the master device, otherwise, it is determined that the device is not the master device.
Optionally, in some cases, the candidate master device is already determined to be a slave device before networking, and the negotiation result may further include: indication information, such as an indication parameter, for indicating that the requesting receiver device, i.e., the other candidate master devices, is a slave device; in practical application, whether other candidate master devices are slave devices or not can be indicated through indication parameters of different parameter values; at this time, the first determining unit 604 may be specifically configured to:
setting a preset threshold according to the number of indication parameters for indicating other candidate master devices as slave devices and the total number of the candidate master devices;
comparing the number of the indication parameters which indicate that the device agrees to be used as the main device with the preset threshold value;
when the current device is larger than or equal to a preset threshold value, determining that the current device is a main device; otherwise, it is not the master.
(5) A communication establishing unit 605;
a communication establishing unit 605, configured to establish a communication channel with other devices in the device cluster except the device itself to form a network when the first determining unit 604 determines that the device is the master device.
The capacity expansion and the capacity reduction of the equipment network are facilitated; in this embodiment, a communication channel is established with other devices, and the other devices in the device cluster may actively search for the master device and initiate a communication connection, so as to implement automation of capacity expansion and capacity reduction. Wherein, the communication establishing unit 605 is configured to:
receiving a main equipment inquiry request initiated by other equipment in the equipment cluster;
returning response information for indicating that the equipment is the main equipment according to the inquiry request of the main equipment;
receiving a communication establishment request sent by the other equipment according to the response information;
and establishing a communication channel with the other candidate master equipment according to the communication establishment request.
Optionally, referring to fig. 6b, the networking apparatus may further include a second determining unit 606, where the second determining unit 606 is configured to determine whether a master device already exists currently when the first determining unit 604 determines that the device is not the master device, and if so, determine that the device is the slave device.
Optionally, referring to fig. 6c, the networking device may further include:
a request receiving unit 607, configured to receive a second master device negotiation request sent by another candidate master device according to the candidate list information, where the second master device negotiation request carries network addresses of the other candidate master devices;
a result returning unit 608, configured to return a corresponding negotiation result to the other candidate master device according to the network address of the local device and the network addresses of the other candidate master devices.
The result returning unit 608 may include:
the comparison subunit is used for comparing the network address of the local device with the network addresses of other candidate main devices to obtain a comparison result;
and the result returning subunit is used for returning the corresponding negotiation result to the other candidate main equipment according to the comparison result.
Optionally, referring to fig. 6d, the networking device may further include: a judgment unit 609;
the determining unit 609 is configured to determine whether the device is a master device currently after the request receiving unit 607 receives the second device negotiation request and before the result returning unit returns the negotiation result, and if the device is not a master device, determine whether the device is a slave device currently;
the result returning unit 608 is configured to, when the determining unit 609 determines that the local device is not the slave device, return a corresponding negotiation result to the other candidate master device according to the network address of the local device and the network addresses of the other candidate master devices.
Optionally, the communication establishing unit 605 is further configured to, after the determining unit 604 determines that the device is a slave device, send a master device query request to the other candidate master devices according to the candidate list information; receiving response information returned by the other candidate main equipment according to the main equipment inquiry request; and determining the currently negotiated main equipment according to the response information, and establishing a communication channel with the main equipment.
In a specific implementation, the above units may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and the specific implementation of the above units may refer to the foregoing method embodiments, which are not described herein again.
The networking means between the devices may be integrated in a server, for example, a candidate server providing a hosting service.
As can be seen from the above, with the networking device provided in the embodiment of the present invention, the master device can be automatically elected in an auto-negotiation manner to implement networking between devices, and it is not necessary to perform a large number of complicated manual configurations on each device, so that the networking speed and efficiency between devices can be improved. In addition, the networking device provided by the embodiment of the invention can also automatically search the master device through the slave device and establish communication, so that the automation of capacity expansion and capacity reduction is realized, and the scheme supports hot plug capacity expansion and capacity reduction (wherein plug and play means that the online and offline of the slave do not influence the operation of the existing networking device and do not need configuration change). Because the scheme does not need to restart the service to carry out equipment configuration again during capacity expansion or capacity reduction, the capacity expansion and reduction speed and efficiency are improved, and the influence of the capacity expansion and reduction on the networking equipment is reduced.
In addition, the networking scheme provided by the embodiment of the invention can also reduce the number of communication channels and save communication resources. For example, when n devices are networked in the existing networking manner, n × n (n-1)/2 communication channels are required; the networking scheme provided by the embodiment of the invention can realize the communication between any two machines in the cluster only by n-1 communication channels in the networking of n devices, thereby realizing the minimization of the communication channels and saving the communication resources.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, and the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
The above detailed description is provided for a method, an apparatus, and a system for networking between devices according to an embodiment of the present invention, and a specific example is applied in the present disclosure to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for those skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (14)

1. A method for networking between devices, comprising:
acquiring candidate list information, wherein the candidate list information comprises network addresses of candidate master devices in a device cluster, the device cluster comprises the candidate master devices and determined slave devices, and the candidate master devices comprise the device and other candidate master devices;
sending a first main device negotiation request to other candidate main devices except the device in the device cluster according to the candidate list information;
receiving a negotiation result returned by the other candidate main equipment according to the negotiation request of the first main equipment;
determining whether the equipment is the main equipment or not according to a negotiation result returned by the other candidate main equipment, wherein the negotiation result comprises indication information for indicating whether the equipment is agreed to be the main equipment or not, and when the equipment with the largest equipment IP address is selected to be the main equipment, if the IP of the other candidate main equipment is not larger than the IP of the equipment, the indication information for agreeing to be the main equipment is returned; or when other candidate main devices are not elected as the main devices, returning indication information agreeing to the main device as the main device; or when the storage space of other candidate main equipment is insufficient or the network connection is unstable, returning indication information agreeing to the equipment as the main equipment; the indication information comprises an indication parameter used for indicating whether the equipment is agreed to be used as main equipment;
acquiring the number of indication parameters indicating agreement that the local device serves as a master device, and determining that the local device is the master device when the number is greater than or equal to a preset threshold value, wherein the preset threshold value is set according to the number of the indication parameters for indicating other candidate master devices as slave devices and the total number of the candidate master devices;
after determining that the device is a master device, modifying the state identifier of the device so that the modified state identifier indicates that the device is a master device, actively searching the device by the slave device, and actively establishing a communication channel with the device to form a network, wherein the slave device includes other candidate master devices except the device in the device cluster and the determined slave device;
after networking, the slave devices in the device cluster send respective cache data to the master device, and the cache data is forwarded to the other slave devices through the master device so as to synchronize the cache data.
2. The networking method of claim 1, further comprising:
when the equipment is determined not to be the main equipment, determining whether the main equipment exists at present;
and if so, determining that the equipment is the slave equipment.
3. The networking method of claim 1 or 2, further comprising:
receiving a second main device negotiation request sent by other candidate main devices according to the candidate list information, wherein the second main device negotiation request carries network addresses of the other candidate main devices;
and returning corresponding negotiation results to other candidate main equipment according to the network address of the equipment and the network addresses of other candidate main equipment.
4. The networking method according to claim 3, wherein returning a corresponding negotiation result to the other candidate master device according to the network address of the local device and the network addresses of the other candidate master devices comprises:
comparing the network address of the equipment with the network addresses of other candidate main equipment to obtain a comparison result;
and returning corresponding negotiation results to the other candidate main equipment according to the comparison result.
5. The networking method of claim 3, wherein after receiving the second device negotiation request and before returning the negotiation result, the networking method further comprises:
judging whether the equipment is a main equipment at present;
if not, judging whether the equipment is the slave equipment currently;
and if the device is not the slave device, returning a corresponding negotiation result to the other candidate master devices according to the network address of the device and the network addresses of the other candidate master devices.
6. The networking method of claim 1, wherein establishing a communication channel with a device other than the device in the device cluster comprises:
receiving a main equipment inquiry request initiated by other equipment in the equipment cluster;
returning response information for indicating that the equipment is the main equipment according to the inquiry request of the main equipment;
receiving a communication establishment request sent by the other equipment according to the response information;
and establishing a communication channel with the other candidate main equipment according to the communication establishing request.
7. The networking method according to claim 2, wherein after determining that the present device is a slave device, the networking method further comprises:
sending a main device inquiry request to the other candidate main devices according to the candidate list information;
receiving response information returned by the other candidate main equipment according to the main equipment inquiry request;
and determining the currently negotiated main equipment according to the response information, and establishing a communication channel with the main equipment.
8. An apparatus for networking between devices, comprising:
an obtaining unit, configured to obtain candidate list information, where the candidate list information includes network addresses of candidate master devices in a device cluster, the device cluster includes the candidate master devices and determined slave devices, and the candidate master devices include a local device and other candidate master devices;
a sending unit, configured to send a first master device negotiation request to other candidate master devices in the device cluster except for the device according to the candidate list information;
a result receiving unit, configured to receive a negotiation result returned by the other candidate master devices according to the first master device negotiation request;
a first determining unit, configured to determine whether the device is a master device according to a negotiation result returned by the other candidate master devices, where the negotiation result includes indication information indicating whether to approve the device as a master device, and when a device with a largest device IP address is selected as a master device, if the IP of the other candidate master devices is not greater than the IP of the device, return indication information approving the device as a master device; or when other candidate main devices are not elected as the main devices, returning indication information agreeing to the main device as the main device; or when the storage space of other candidate main equipment is insufficient or the network connection is unstable, returning indication information agreeing to the equipment as the main equipment; the indication information comprises an indication parameter used for indicating whether the equipment is agreed to be used as main equipment;
acquiring the number of indication parameters indicating agreement that the local device serves as a master device, and determining that the local device is the master device when the number is greater than or equal to a preset threshold value, wherein the preset threshold value is set according to the number of the indication parameters for indicating other candidate master devices as slave devices and the total number of the candidate master devices;
a communication establishing unit, configured to modify a state identifier of the local device after determining that the local device is a master device, so that the modified state identifier indicates that the local device is the master device, and when the first determining unit determines that the local device is the master device, the slave device actively searches for the local device and actively establishes a communication channel with the local device to form a network, where the slave device includes other candidate master devices except the local device in the device cluster and the determined slave device; after networking, the slave devices in the device cluster send respective cache data to the master device, and the cache data is forwarded to the other slave devices through the master device so as to synchronize the cache data.
9. The networking apparatus of claim 8, further comprising: a second determination unit;
the second determining unit is configured to determine whether a master device already exists currently when the first determining unit determines that the device is not the master device, and if so, determine that the device is the slave device.
10. The networking device of claim 8 or 9, further comprising:
a request receiving unit, configured to receive a second master device negotiation request sent by another candidate master device according to the candidate list information, where the second master device negotiation request carries a network address of the other candidate master device;
and a result returning unit, configured to return a corresponding negotiation result to the other candidate master device according to the network address of the local device and the network addresses of the other candidate master devices.
11. The networking apparatus according to claim 10, wherein the result returning unit includes:
the comparison subunit is used for comparing the network address of the local device with the network addresses of other candidate main devices to obtain a comparison result;
and the result returning subunit is used for returning the corresponding negotiation result to the other candidate main equipment according to the comparison result.
12. The networking apparatus according to claim 10, further comprising a judging unit;
the judging unit is configured to judge whether the device is a master device currently after the request receiving unit receives the second device negotiation request and before the result returning unit returns the negotiation result, and judge whether the device is a slave device currently if the device is not a master device;
and the result returning unit is used for returning corresponding negotiation results to other candidate main equipment according to the network address of the equipment and the network addresses of other candidate main equipment when the judging unit judges that the equipment is not the slave equipment.
13. The networking apparatus of claim 8, wherein the communication establishing unit is configured to:
receiving a main equipment inquiry request initiated by other equipment in the equipment cluster;
returning response information for indicating that the equipment is the main equipment according to the inquiry request of the main equipment;
receiving a communication establishment request sent by the other equipment according to the response information;
and establishing a communication channel with the other candidate main equipment according to the communication establishing request.
14. A networking system between devices, characterized in that it comprises networking means according to any one of claims 8 to 13.
CN201710220955.1A 2017-04-06 2017-04-06 Method, device and system for networking between devices Active CN106953767B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710220955.1A CN106953767B (en) 2017-04-06 2017-04-06 Method, device and system for networking between devices

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710220955.1A CN106953767B (en) 2017-04-06 2017-04-06 Method, device and system for networking between devices

Publications (2)

Publication Number Publication Date
CN106953767A CN106953767A (en) 2017-07-14
CN106953767B true CN106953767B (en) 2021-03-02

Family

ID=59475771

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710220955.1A Active CN106953767B (en) 2017-04-06 2017-04-06 Method, device and system for networking between devices

Country Status (1)

Country Link
CN (1) CN106953767B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107505612A (en) * 2017-09-11 2017-12-22 深圳市航天华拓科技有限公司 Radio ranging system and method
CN108055140B (en) * 2017-12-05 2021-05-04 深圳市东微智能科技股份有限公司 Cross-device communication method, device, storage medium and computer equipment thereof in networking
CN108737181A (en) * 2018-05-22 2018-11-02 四川斐讯信息技术有限公司 A kind of the communications status information change method and change system of intelligent terminal
CN112671904B (en) * 2020-12-23 2023-03-28 青岛海尔科技有限公司 Method and device for transmitting equipment state information, storage medium and electronic device
CN113364838B (en) * 2021-05-26 2022-08-26 中建三局智能技术有限公司 Equipment ad hoc network method and system based on MQTT
CN114466081B (en) * 2021-12-23 2024-04-12 东莞市李群自动化技术有限公司 Method, system, equipment and storage medium for managing and controlling nodes of real-time channel group
CN116436755B (en) * 2023-06-12 2023-08-25 新华三技术有限公司 Network management method and device and electronic equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103532764A (en) * 2013-10-24 2014-01-22 中国科学院信息工程研究所 Multi-machine hot backup method and system
CN105024860A (en) * 2015-07-23 2015-11-04 上海斐讯数据通信技术有限公司 Remote communication control method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007055549A1 (en) * 2005-11-14 2007-05-18 Lg Electronics Inc. Method for selecting a determinator of priority to access a network

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103532764A (en) * 2013-10-24 2014-01-22 中国科学院信息工程研究所 Multi-machine hot backup method and system
CN105024860A (en) * 2015-07-23 2015-11-04 上海斐讯数据通信技术有限公司 Remote communication control method and system

Also Published As

Publication number Publication date
CN106953767A (en) 2017-07-14

Similar Documents

Publication Publication Date Title
CN106953767B (en) Method, device and system for networking between devices
US10057130B2 (en) D2HCP protocol in ad hoc networks: merging of sub-networks and address conflict resolution
US20010048728A1 (en) Apparatus and methods for providing data synchronization by facilitating data synchronization system design
CN103369051B (en) A kind of data server cluster system and method for data synchronization
EP3361387A1 (en) Data transmission method, equipment and system
US8219614B2 (en) Edge peer device, pan gateway device, super peer device, and P2P network-based interconnection method
KR20120018178A (en) Swarm-based synchronization over a network of object stores
CN104243527A (en) Data synchronization method and device and distributed system
WO2018024121A1 (en) Network function (nf) management method and nf management device
US10470225B2 (en) System and method for enhance the user experience of applications for proximity-based peer-to-peer mobile computing
US9288075B2 (en) Method and system for auto-configuration, and network node
CN109495383B (en) Data processing method, device, communication system and network equipment
WO2021017703A1 (en) Communication information exchange method and apparatus, storage medium and computer device
US10454531B2 (en) File transmission/reception device and control method of file transmission/reception device
US20140108484A1 (en) Method and system for optimizing distributed transactions
CN100505662C (en) Method for setting point-to-point data channel
CN112003943A (en) Voice data synchronization method and device
CN102684966B (en) Equipment method of network entry, Apparatus and system
CN112202877A (en) Gateway linkage method, gateway, cloud server and user terminal
CN110213359B (en) Internet of vehicles networking data pushing system and method based on D2D
CN113726581B (en) Method and device for restoring factory configuration of network equipment and network equipment
CN111800516B (en) Internet of things equipment management method and device based on P2P
CN112491951B (en) Request processing method, server and storage medium in peer-to-peer network
CN112689029A (en) Method, device and equipment for acquiring IP address of group user
US10693921B2 (en) System and method for distributed mobile network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant