A gateway hot standby method and target hot standby gateway

By establishing a distributed application coordination service cluster between multiple hot standby gateways in the Internet of Things field, monitoring and coordinating the gateway status in real time, and automatically switching to another normal gateway when one gateway runs abnormally, the problem of resource waste in the existing technology is solved and the system reliability and efficiency is improved.

CN118890263BActive Publication Date: 2025-04-04BEIJING PILOT ZHILIAN INTERNET OF THINGS TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411073915.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-06
Publication Date
2025-04-04
Estimated Expiration
2044-08-06

AI Technical Summary

Technical Problem

In the field of the Internet of Things, when there is an abnormal operation of the Internet of Things gateway, additional IoT gateways need to be prepared to take over, resulting in waste of resources.

Method used

A gateway hot standby method is adopted to coordinate service clusters between multiple hot standby gateways within the same network segment to monitor and coordinate the operating status of the gateway in real time. When one hot standby gateway runs abnormally, another normal hot standby gateway is instructed to take over the network control device it controls.

Benefits of technology

Without pre-preparing an additional IoT gateway, you can automatically switch to another normal gateway when one runs abnormally, thereby reducing resource waste and improving system reliability and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118890263B_ABST
    Figure CN118890263B_ABST
Patent Text Reader

Abstract

The present application provides a hot standby method for a gateway and a target hot standby gateway, wherein the method is applied to any one of at least two hot standby gateways in the same network segment that is operating normally; each hot standby gateway is respectively connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself; the method includes: determining whether there is an abnormal hot standby gateway in the hot standby gateway; when there is an abnormal hot standby gateway in the hot standby gateway, instructing the normal hot standby gateway in the hot standby gateway to establish a connection with the target network control device, so that the indicated hot standby gateway takes over the control of the target network control device; the target network control device is the network control device connected to the abnormal hot standby gateway. Through this method, when one of the IoT gateways has an abnormal operation, there is no need to prepare an additional IoT gateway, thereby reducing resource waste.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a hot standby method for a gateway and a target hot standby gateway. Background Art

[0002] In the field of IoT, each IoT gateway can control multiple controlled devices. When one of the IoT gateways runs abnormally, the prior art usually uses an additional IoT gateway prepared in advance to take over the controlled device controlled by the abnormal IoT gateway. It can be seen that the method in the prior art requires the preparation of an additional IoT gateway, which wastes resources. Summary of the invention

[0003] In view of this, the purpose of the present application is to provide a gateway hot standby method and a target hot standby gateway, so that when one of the IoT gateways has an operational abnormality, there is no need to prepare an additional IoT gateway, thereby reducing resource waste.

[0004] In a first aspect, an embodiment of the present application provides a hot standby method for a gateway, the method being applied to any one of at least two hot standby gateways in the same network segment that is operating normally; each of the hot standby gateways is respectively connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself; the method comprising:

[0005] Determine whether there is an abnormal hot standby gateway among the hot standby gateways;

[0006] When there is an abnormal hot standby gateway among the hot standby gateways, the hot standby gateway that is operating normally among the hot standby gateways is instructed to establish a connection with a target network control device so that the instructed hot standby gateway takes over the control of the target network control device; the target network control device is a network control device connected to the abnormal hot standby gateway.

[0007] In combination with the first aspect, an embodiment of the present application provides a first possible implementation scheme of the first aspect, wherein there are multiple physical spaces, and at least one network control device is arranged in each of the physical spaces; each of the hot standby gateways is responsible for at least one of the physical spaces; each of the hot standby gateways is connected to each of the network control devices in the physical space that the hot standby gateway is responsible for through a switch; the switch is connected to at least one of the hot standby gateways; when there are multiple switches, the switches are connected to each other.

[0008] In combination with the first possible implementation of the first aspect, the embodiment of the present application provides a second possible implementation of the first aspect, wherein, when there are multiple hot standby gateways, a distributed application coordination service is deployed in each of the hot standby gateways, and the distributed application coordination services deployed in all the hot standby gateways in the same network segment constitute a distributed application coordination service cluster; the distributed application coordination service is used to store the operating status of the hot standby gateway deployed by the distributed application coordination service; the operating status includes normal operation and abnormal operation; the distributed application coordination services in the distributed application coordination service cluster share the operating status of the hot standby gateway stored in themselves, so that each of the distributed application coordination services obtains the operating status of each of the hot standby gateways;

[0009] The determining whether there is an abnormal hot standby gateway among the hot standby gateways comprises:

[0010] When the distributed application coordination service deployed by itself has an operating abnormality in the operating status of each hot standby gateway obtained from the distributed application coordination service cluster, it receives a gateway abnormality notification sent by the distributed application coordination service deployed by itself to determine whether there is a hot standby gateway with an operating abnormality among the hot standby gateways.

[0011] In combination with the second possible implementation of the first aspect, the embodiment of the present application provides a third possible implementation of the first aspect, wherein when there is an abnormally operating hot standby gateway among the hot standby gateways, instructing a normally operating hot standby gateway among the hot standby gateways to establish a connection with a target network control device so that the indicated hot standby gateway takes over the control of the target network control device, including:

[0012] When there is an abnormal hot standby gateway among the hot standby gateways, the gateway information of the hot standby gateway whose running status is normal is obtained from the distributed application coordination service deployed by itself;

[0013] According to the first physical spaces that are responsible for all the hot standby gateways that are operating normally and all the hot standby gateways that are operating abnormally, each of the first physical spaces is reallocated to each hot standby gateway that is operating normally, to obtain a respective allocation result for each hot standby gateway that is operating normally; the allocation result includes the first physical space that the hot standby gateway needs to be responsible for;

[0014] The allocation result of each hot standby gateway that is operating normally is uploaded to the distributed application coordination service cluster, so that for each hot standby gateway that is operating normally, the hot standby gateway establishes a connection with the network control device in the first physical space included in the allocation result according to the first physical space included in its own allocation result, and takes over the control of the network control device in the first physical space included in the allocation result.

[0015] In combination with the third possible implementation of the first aspect, the embodiment of the present application provides a fourth possible implementation of the first aspect, wherein, according to the first physical spaces responsible for all hot standby gateways operating normally and all hot standby gateways operating abnormally, each of the first physical spaces is reallocated to a hot standby gateway operating normally, including:

[0016] Re-allocating each of the first physical spaces to a hot standby gateway that is operating normally by any one of the following four allocation methods;

[0017] The first allocation method is: randomly allocating each first physical space to a hot standby gateway that is operating normally;

[0018] The second allocation method is:

[0019] Determine the current load of each hot standby gateway that is operating normally according to the number of network control devices currently connected to each hot standby gateway that is operating normally;

[0020] Based on the current load of each hot standby gateway operating normally, allocating each first physical space to the hot standby gateway operating normally;

[0021] The third allocation method is:

[0022] For each of the first physical spaces, calculate a hash value of the space number of the first physical space; wherein each of the first physical spaces corresponds to its own space number;

[0023] Calculate the ratio of the hash value to the number of hot standby gateways that are operating normally, take the remainder of the ratio, and obtain the remainder corresponding to the first physical space;

[0024] According to the remainder of the first physical space and the first gateway number of each normally operating hot standby gateway, determine from each first gateway number a first gateway number that is the same as the remainder of the first physical space, so as to allocate the first physical space to the normally operating hot standby gateway corresponding to the first gateway number;

[0025] The fourth allocation method is:

[0026] Construct a target ring;

[0027] According to the numbering sequence of the second gateway numbers of all the hot standby gateways and the specified direction, the gateway identifiers of all the hot standby gateways are evenly arranged on the target ring in sequence; wherein the specified direction is a clockwise direction or a counterclockwise direction;

[0028] For every two adjacent gateway identifiers arranged on the target circular ring, on the circular ring segment between the two gateway identifiers, the gateway identifiers of all the hot standby gateways are evenly arranged on the circular ring segment in sequence according to the numbering sequence of all the hot standby gateways and the specified direction, and, on the circular ring segment between the two gateway identifiers, the space identifiers of the physical space responsible for the hot standby gateway corresponding to the first gateway identifier of the two gateway identifiers are evenly arranged on the circular ring segment in sequence; wherein the first gateway identifier is the gateway identifier in the direction indicated by the specified direction of the two gateway identifiers arranged on the target circular ring;

[0029] Deleting the gateway identifiers of all abnormally running hot standby gateways from the target ring;

[0030] For each first physical space that is responsible for all abnormally operating hot standby gateways, based on the arrangement distance between the space identifier of the first physical space on the target ring and the gateway identifier of each normally operating hot standby gateway and the specified direction, the first physical space is allocated to the hot standby gateway corresponding to the gateway identifier that is in the specified direction and closest to the arrangement distance between the space identifier of the first physical space.

[0031] In combination with the second possible implementation of the first aspect, the embodiment of the present application provides a fifth possible implementation of the first aspect, wherein the method further includes:

[0032] When the first device state of any one or more first network control devices among the network control devices connected to the target hot standby gateway changes, the first device state information of the first network control device is uploaded to the distributed application coordination service cluster through the distributed application coordination service deployed by itself; wherein the first device state information includes the first device identifier, the changed first device state, and the first state change timestamp;

[0033] Other hot standby gateways are used to obtain the first device status information of the first network control device from the distributed application coordination service cluster when monitoring changes in the first device status information of the first network control device stored in the distributed application coordination service cluster; when the original first device status information of the first network control device is not stored in the other hot standby gateway, store the first device status information of the first network control device in the other hot standby gateway; when the original first device status information of the first network control device is stored in the other hot standby gateway, determine whether the first state change timestamp in the first device status information is later than the state change timestamp in the original first device status information; if so, use the first device status information to update the original first device status information.

[0034] In combination with the second possible implementation of the first aspect, the embodiment of the present application provides a sixth possible implementation of the first aspect, wherein a first control screen is further provided in each of the physical spaces;

[0035] The first control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the first control screen is located is normal; when the operating status of the hot standby gateway is abnormal, based on the gateway address information of each other hot standby gateway stored in itself, it sends detection requests to other hot standby gateways in turn, so as to obtain the second hot standby gateway currently responsible for the physical space where the first control screen is located from the hot standby gateways that are operating normally among the other hot standby gateways, and establish a connection with the second hot standby gateway.

[0036] In combination with the first possible implementation of the first aspect, the embodiment of the present application provides a seventh possible implementation of the first aspect, wherein, when the hot standby gateway includes only two hot standby gateways that back up each other, determining whether there is an abnormally operating hot standby gateway in the hot standby gateway includes:

[0037] The first network request is periodically sent to another hot standby gateway that is in mutual backup with the target hot standby gateway; when the first feedback information of the other hot standby gateway is not received, it is characterized that the other hot standby gateway is an abnormally operating hot standby gateway.

[0038] In combination with the seventh possible implementation of the first aspect, the embodiment of the present application provides an eighth possible implementation of the first aspect, wherein when there is an abnormally operating hot standby gateway among the hot standby gateways, instructing a normally operating hot standby gateway among the hot standby gateways to establish a connection with a target network control device so that the indicated hot standby gateway takes over the control of the target network control device, including:

[0039] When the other hot standby gateway is an abnormally operating hot standby gateway, querying all second physical spaces that the abnormally operating hot standby gateway is responsible for;

[0040] Determining network control devices located in each of the second physical spaces;

[0041] The target hot standby gateway is used to establish a connection with each network control device in the second physical space, so that the target hot standby gateway takes over the control of the network control device in the second physical space.

[0042] In combination with the eighth possible implementation of the first aspect, the embodiment of the present application provides a ninth possible implementation of the first aspect, wherein, after using the target hot standby gateway to establish a connection with each network control device in the second physical space so that the target hot standby gateway takes over the control of the network control device in the second physical space, it also includes:

[0043] Periodically sending a second network request to another hot standby gateway that is in mutual backup with the target hot standby gateway;

[0044] When second feedback information from another hot standby gateway is received, the connection with the network control device in the second physical space is disconnected to release the control right over the network control device in the second physical space.

[0045] In combination with the seventh possible implementation of the first aspect, the embodiment of the present application provides a tenth possible implementation of the first aspect, wherein the method further includes:

[0046] When the second device status information of any one or more second network control devices among the network control devices connected to the target hot standby gateway changes, the second device status information of the second network control device is sent to another hot standby gateway that is mutually backed up with the target hot standby gateway; the second device status information includes the changed second device status and the second status change timestamp;

[0047] Another hot standby gateway is used to store the second device status information when receiving the second device status information, when the second device status information is not stored in the other hot standby gateway; when the original second device status information of the target hot standby gateway is stored in the other hot standby gateway, determine whether the second state change timestamp in the second device status information is later than the state change timestamp in the original second device status information, and if so, use the second device status information to update the original second device status information.

[0048] In combination with the eighth possible implementation of the first aspect, the embodiment of the present application provides an eleventh possible implementation of the first aspect, wherein a second control screen is further provided in each of the physical spaces; and the method further includes:

[0049] When the operating status of another hot standby gateway is abnormal, a connection establishment request sent by the second control screen in the second physical space is received to establish a connection with the second control screen in the second physical space; wherein the second control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the second control screen is located is normal.

[0050] In a second aspect, an embodiment of the present application further provides a target hot standby gateway, wherein the target hot standby gateway is any one of at least two hot standby gateways in the same network segment and operates normally; each of the hot standby gateways is respectively connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself; the target hot standby gateway is used to:

[0051] Determine whether there is an abnormal hot standby gateway among the hot standby gateways;

[0052] When there is an abnormal hot standby gateway among the hot standby gateways, the hot standby gateway that is operating normally among the hot standby gateways is instructed to establish a connection with a target network control device so that the instructed hot standby gateway takes over the control of the target network control device; the target network control device is a network control device connected to the abnormal hot standby gateway.

[0053] The embodiment of the present application provides a hot standby method for a gateway and a target hot standby gateway, wherein the method is applied to any one of at least two hot standby gateways in the same network segment that is operating normally; each hot standby gateway is respectively connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself; the method includes: determining whether there is a hot standby gateway with abnormal operation in the hot standby gateway; when there is a hot standby gateway with abnormal operation in the hot standby gateway, instructing the hot standby gateway with normal operation in the hot standby gateway to establish a connection with the target network control device, so that the indicated hot standby gateway takes over the control of the target network control device; the target network control device is the network control device connected to the hot standby gateway with abnormal operation. In this way, when one of the hot standby gateways operates abnormally, the hot standby gateway with normal operation is directly used to take over the network control device controlled by the hot standby gateway with abnormal operation, without preparing additional gateways, which is conducive to reducing resource waste.

[0054] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0056] Figure 1 A flowchart of a hot standby method for a gateway provided in an embodiment of the present application is shown;

[0057] Figure 2 A schematic diagram of a multi-machine multi-active mode provided in an embodiment of the present application is shown;

[0058] Figure 3 A schematic diagram of a target ring provided in an embodiment of the present application is shown;

[0059] Figure 4 A schematic diagram of another target ring provided in an embodiment of the present application is shown;

[0060] Figure 5 A schematic diagram of a dual-machine mutual backup mode provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0061] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0062] In the Internet field, microservice architecture is usually used. A service can run on multiple server nodes. For example, online conference services can run on multiple server nodes, and different server nodes can provide online conference services for different conference terminals. The container management software Kubernetes is installed in each server node. Kubernetes is used to manage each container in the server node (containers such as application services). When a container in one of the server nodes runs abnormally and cannot work, other server nodes will be used to take over the services provided by the abnormal container in the abnormal server node. At the same time, Kubernetes in the abnormal server node will try to restart the abnormal container. When the container is restarted, the abnormal container in the abnormal server node can continue to provide services. However, in the field of the Internet of Things, due to resource and cost constraints, it is usually impossible to run software such as Kubernetes that consumes a lot of memory and CPU resources on the Internet of Things.

[0063] The existing technology usually adopts a cold standby method, that is, an additional gateway is prepared in advance. When the gateway in use fails, the device controlled by the gateway is switched to the standby gateway so that the standby gateway takes over the device controlled by the abnormal gateway. This method requires the preparation of an additional IoT gateway, which wastes resources.

[0064] In view of the above problems, based on this, an embodiment of the present application provides a gateway hot standby method and a target hot standby gateway, which are described below through embodiments.

[0065] To facilitate understanding of this embodiment, a hot standby method for a gateway disclosed in an embodiment of the present application is first introduced in detail. The method is applied to any one of at least two hot standby gateways in the same network segment that is operating normally; each hot standby gateway is connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself.

[0066] In this embodiment, the hot standby gateways in the same network segment are in the same network environment, and the hot standby gateways in the same network segment can communicate with each other. There can be multiple gateways in the same network segment, including at least two hot standby gateways; or, the gateways in the same network segment can all be hot standby gateways. The target hot standby gateway can be any hot standby gateway that is operating normally among all the hot standby gateways in the same network segment. The network control equipment includes audio and video equipment and home Internet of Things equipment. Among them, the audio and video equipment includes any one or more of the following: high-definition player, projector, display screen, camera, video matrix, audio matrix, microphone, and speaker. Home Internet of Things equipment includes any one or more of the following: air conditioner, light, curtain, temperature and humidity sensor, human body sensor, noise sensor.

[0067] Each hot standby gateway can be connected to at least one network control device, for example, the hot standby gateway is connected to a speaker or a light. The hot standby gateway is used to control the network control device connected to the hot standby gateway, for example, the hot standby gateway can control the volume of the speaker or turn on and off the light.

[0068] like Figure 1 As shown, the method includes the following steps S101-S102:

[0069] S101: Determine whether there is an abnormal hot standby gateway among the hot standby gateways;

[0070] S102: When there is an abnormal hot standby gateway among the hot standby gateways, instruct a normally operating hot standby gateway among the hot standby gateways to establish a connection with a target network control device, so that the normally operating hot standby gateway takes over the control of the target network control device; the target network control device is the network control device connected to the abnormal hot standby gateway.

[0071] In step S101, it is determined whether there is at least one abnormal hot standby gateway among all hot standby gateways in the same network segment. As long as there is at least one abnormal hot standby gateway, it means that there is an abnormal hot standby gateway among the hot standby gateways.

[0072] In step S102, when there is an abnormal hot standby gateway among the hot standby gateways, the abnormal hot standby gateway cannot control the target network control device to which it is connected. At this time, the target hot standby gateway instructs the normal hot standby gateways among all the hot standby gateways to establish a connection with the target network control device, so that the normal hot standby gateways among all the hot standby gateways take over the control of the target network control device, thereby controlling the target network control device. The normal hot standby gateway indicated by the target hot standby gateway may be the target hot standby gateway, or may be another normal hot standby gateway other than the target hot standby gateway.

[0073] In a possible implementation, there are multiple physical spaces, each of which is provided with at least one network control device; each hot standby gateway is responsible for at least one physical space; each hot standby gateway is connected to each network control device in the physical space that the hot standby gateway is responsible for through a switch; the switch is connected to at least one hot standby gateway; when there are multiple switches, the switches are connected to each other.

[0074] In this embodiment, the physical space can be a room, such as a conference room, office, classroom, bedroom, living room, etc. Each network control device is only set in one of the physical spaces, and each physical space is only managed by one of the hot standby gateways. When there are multiple switches, the switches are connected to each other, so that all hot standby gateways can be in the same network environment.

[0075] like Figure 3As shown, illustratively, there are 3 hot standby gateways, namely hot standby gateway A, hot standby gateway B, and hot standby gateway C. There are 4 physical spaces, among which, network control devices a1, a2, a3, and a4 are set in physical space 1, network control devices b1 and b2 are set in physical space 2, network control devices b3, b4, and b5 are set in physical space 3, and network control devices c1 and c2 are set in physical space 4. There are two switches, namely switch 1 and switch 2, and switches 1 and 2 are connected.

[0076] In this example, hot standby gateway A is responsible for physical space 1, that is, hot standby gateway A is used to control network control devices a1, a2, a3, and a4. Hot standby gateway B is responsible for physical space 2 and physical space 3, so hot standby gateway B is used to control network control devices b1, b2, b3, b4, and b5. Hot standby gateway C is responsible for physical space 3, so hot standby gateway C is used to control network control devices c1 and c2.

[0077] In the first case, when there are multiple hot standby gateways, a distributed application coordination service (ZooKeeper) is deployed in each hot standby gateway, and the distributed application coordination services deployed in all hot standby gateways in the same network segment constitute a distributed application coordination service cluster; the distributed application coordination service is used to store the operating status of the hot standby gateway deployed by the distributed application coordination service; the operating status includes normal operation and abnormal operation; the distributed application coordination services in the distributed application coordination service cluster share the operating status of the hot standby gateway stored in themselves, so that each distributed application coordination service obtains the operating status of each hot standby gateway.

[0078] In this embodiment, if Figure 3 As shown, taking hot standby gateway A as an example, a distributed application coordination service (ZooKeeper) is deployed in hot standby gateway A, and the distributed application coordination service is used to store the running status of hot standby gateway A, and share the running status of hot standby gateway A with the distributed application coordination service in hot standby gateway B and the distributed application coordination service in hot standby gateway C. Similarly, the distributed application coordination service in hot standby gateway A can also obtain the running status of hot standby gateway B shared by the distributed application coordination service in hot standby gateway B, and the running status of hot standby gateway C shared by the distributed application coordination service in hot standby gateway C.

[0079] In a possible implementation, when executing step S101, the following steps may be followed: when the distributed application coordination service deployed by itself has an operating abnormality in the operating status of each hot standby gateway obtained from the distributed application coordination service cluster, a gateway abnormality notification is received from the distributed application coordination service deployed by itself to determine the hot standby gateway with the operating abnormality among the hot standby gateways.

[0080] In this embodiment, taking the target hot standby gateway as hot standby gateway A as an example, when the distributed application coordination service deployed in the target hot standby gateway A obtains the running status of hot standby gateway B and hot standby gateway C from the distributed application coordination service cluster and there is an operation abnormality, for example, when the running status of hot standby gateway C is an operation abnormality, the distributed application coordination service deployed in the target hot standby gateway A will send a gateway abnormality notification to the target hot standby gateway A, so that the target hot standby gateway A determines that there is a hot standby gateway with an operation abnormality in the hot standby gateways ABC.

[0081] In a possible implementation manner, when executing step S102, the following steps S1021-S1023 may be performed:

[0082] S1021: When there is an abnormal hot standby gateway among the hot standby gateways, gateway information of the hot standby gateways in normal operation is obtained from the distributed application coordination service deployed by itself.

[0083] In this embodiment, if Figure 3 As shown, when the target hot standby gateway A determines that there is an abnormally operating hot standby gateway among the hot standby gateways ABC, the target hot standby gateway A obtains the gateway information of the hot standby gateways whose operating status is normal from the distributed application coordination service deployed by itself, that is, obtains the gateway information of the hot standby gateways A and B.

[0084] S1022: reallocate each first physical space to each hot standby gateway that is operating normally, according to the first physical spaces that are responsible for all hot standby gateways that are operating normally and all hot standby gateways that are operating abnormally, to obtain an allocation result for each hot standby gateway that is operating normally; the allocation result includes the first physical space that the hot standby gateway needs to be responsible for;

[0085] In this embodiment, according to the hot standby gateway A and the hot standby gateway B that are operating normally, and the first physical space 4 that is responsible for the hot standby gateway that is operating abnormally, the first physical space 4 is reallocated to the hot standby gateway A or the hot standby gateway B, and the allocation results of the hot standby gateway A and the hot standby gateway B are obtained. Exemplarily, the allocation result of the hot standby gateway A includes the first physical space 4, and then the allocation result of the hot standby gateway B may be empty.

[0086] S1023: Upload the allocation result of each hot standby gateway that is operating normally to the distributed application coordination service cluster, so that for each hot standby gateway that is operating normally, the hot standby gateway establishes a connection with the network control device in the first physical space included in the allocation result according to the first physical space included in its own allocation result, and takes over the control of the network control device in the first physical space included in the allocation result.

[0087] In this embodiment, the target hot standby gateway A uploads the allocation results of the target hot standby gateway A and the hot standby gateway B to the distributed application coordination service cluster through the distributed application coordination service deployed by itself. The hot standby gateway A obtains the allocation results of the hot standby gateway A from the distributed application coordination service cluster, and the hot standby gateway B obtains the allocation results of the hot standby gateway B from the distributed application coordination service cluster.

[0088] The target hot standby gateway A establishes a connection with the network control devices c1 and c2 in the first physical space 4 through the switch 2 according to the first physical space 4 included in the allocation result, thereby taking over the control rights of the network control devices c1 and c2.

[0089] In a possible implementation manner, when executing step S1022, the following steps may be followed: reallocating each first physical space to a hot standby gateway that is operating normally by using any one of the following four allocation methods;

[0090] The first allocation method is: randomly allocating each first physical space to a hot standby gateway that is operating normally.

[0091] The second allocation method is:

[0092] The current load of each normally operating hot standby gateway is determined based on the number of network control devices currently connected to each normally operating hot standby gateway; wherein, the more network control devices currently connected to the hot standby gateway, the greater the current load of the hot standby gateway; conversely, the fewer network control devices currently connected to the hot standby gateway, the smaller the current load of the hot standby gateway.

[0093] Based on the current load of each hot standby gateway that is operating normally, each first physical space is allocated to the hot standby gateway that is operating normally.

[0094] In this allocation method, the allocation principle is to preferentially allocate the first physical space to the hot standby gateway with a small load, so as to ensure load balancing.

[0095] The third allocation method is:

[0096] For each first physical space, calculate a hash value of the space number of the first physical space; wherein each first physical space corresponds to its own space number;

[0097] Calculate the ratio of the hash value to the number of hot standby gateways that are operating normally, take the remainder of the ratio, and obtain the remainder corresponding to the first physical space;

[0098] According to the remainder of the first physical space and the first gateway number of each normally operating hot standby gateway, a first gateway number that is the same as the remainder of the first physical space is determined from each first gateway number to allocate the first physical space to the normally operating hot standby gateway corresponding to the first gateway number.

[0099] In this allocation method, the first gateway number is numbered from 0. Assume that the first gateway number of the target hot standby gateway A is 2, and the remainder of the first physical space 4 is 2. At this time, the first physical space 2 is allocated to the target hot standby gateway A with the first gateway number 2.

[0100] The fourth allocation method is:

[0101] Construct a target ring;

[0102] According to the numbering sequence of the second gateway numbers of all hot standby gateways and the specified direction, the gateway identifiers of all hot standby gateways are evenly arranged on the target ring in sequence; wherein the specified direction is a clockwise direction or a counterclockwise direction;

[0103] For every two adjacent gateway identifiers arranged on the target circular ring, on the circular ring segment between the two gateway identifiers, the gateway identifiers of all hot standby gateways are evenly arranged on the circular ring segment in sequence according to the numbering sequence of all hot standby gateways and the specified direction, and, on the circular ring segment between the two gateway identifiers, the space identifiers of the physical space responsible for the hot standby gateway corresponding to the first gateway identifier of the two gateway identifiers are evenly arranged on the circular ring segment in sequence; wherein the first gateway identifier is the gateway identifier in the direction indicated by the specified direction of the two gateway identifiers arranged on the target circular ring;

[0104] Delete the gateway IDs of all abnormal hot standby gateways from the target ring;

[0105] For each first physical space that is responsible for all hot standby gateways that are operating abnormally, based on the arrangement distance between the space identifier of the first physical space on the target ring and the gateway identifier of each hot standby gateway that is operating normally and the specified direction, the first physical space is allocated to the hot standby gateway corresponding to the gateway identifier that is in the specified direction and closest to the arrangement distance between the space identifier of the first physical space.

[0106] In this embodiment, if Figure 4As shown, the second gateway numbers of all hot standby gateways A, B, and C can be 1, 2, and 3 in sequence. According to the numbering sequence of the second gateway numbers and the specified direction (for example, clockwise), the gateway identifiers of the hot standby gateways A, B, and C (for example, the gateway identifiers are hot standby gateway A, hot standby gateway B, and hot standby gateway C) are evenly arranged in sequence on the ring segment (for example, Figure 3 Hot standby gateway A, hot standby gateway B, hot standby gateway C in bold).

[0107] like Figure 4 As shown, taking the ring segment between the bold hot standby gateway A and the bold hot standby gateway B on the target ring as an example, according to the numbering order of all hot standby gateways A, B, C and the specified direction (for example, clockwise), the gateway identifiers of all hot standby gateways (hot standby gateway A, hot standby gateway B, hot standby gateway C) are evenly arranged on the ring segment in sequence.

[0108] Also, on the ring segment between the bold hot standby gateway A and the bold hot standby gateway B on the target ring, the space identifiers (physical space 2, physical space 3) of the physical spaces that the hot standby gateway B is responsible for are evenly arranged in sequence on the ring segment.

[0109] like Figure 4 As shown, at this time, an indicating dotted line can be drawn on the target ring to indicate the physical space originally responsible for each hot standby gateway.

[0110] like Figure 5 As shown, when the hot standby gateway C runs abnormally, the gateway identifiers of all hot standby gateways C on the target ring are deleted. Based on the arrangement distance between the space identifier (physical space 4) of the first physical space 4 on the target ring and the gateway identifiers (hot standby gateway A, hot standby gateway B) of each hot standby gateway running normally and the specified direction (clockwise), the first physical space 4 is allocated to the hot standby gateway corresponding to the gateway identifier (hot standby gateway A) that is closest to the arrangement distance of the space identifier (physical space 4) of the first physical space 4 in the specified direction (clockwise). That is, the first physical space 4 is allocated to the hot standby gateway A.

[0111] In a possible implementation, Figure 2 As shown, for example, if the network control device c1 is a lamp, the device state of the network control device c1 may be the brightness of the lamp. If the network control device c2 is a speaker, the device state of the network control device c2 may be the loudness. During the process of the hot standby gateway C controlling the network control devices c1 and c2, the device states of the network control devices c1 and c2 may change. For example, the initial device state of the network control device c1 is the first level brightness. During the process of the hot standby gateway C controlling the network control device c1, the device state of the network control device c1 changes from the first level brightness to the second level brightness.

[0112] At this time, if the hot standby gateway C runs abnormally, after the hot standby gateway A takes over the network control devices c1 and c2, the device states of the network control devices c1 and c2 stored in the hot standby gateway A are still the initial device states. At this time, it is necessary to manually adjust the device state of the network control device c1 stored in the hot standby gateway A to the actual state, that is, to the second-level brightness. In this way, when the hot standby gateway A takes over too many network control devices, it takes a long time to adjust the device states of each network control device, which is cumbersome and inefficient.

[0113] Based on this, when there are multiple hot standby gateways, the method further includes:

[0114] When the first device state of any one or more first network control devices among the network control devices connected to the target hot standby gateway changes, the first device state information of the first network control device is uploaded to the distributed application coordination service cluster through the distributed application coordination service deployed by itself; wherein the first device state information includes the first device identifier, the changed first device state, and the first state change timestamp;

[0115] The other hot standby gateway is used to obtain the first device status information of the first network control device from the distributed application coordination service cluster when monitoring the change of the first device status information of the first network control device stored in the distributed application coordination service cluster; when the original first device status information of the first network control device is not stored in the other hot standby gateway, store the first device status information of the first network control device in the other hot standby gateway; when the original first device status information of the first network control device is stored in the other hot standby gateway, determine whether the first state change timestamp in the first device status information is later than the state change timestamp in the original first device status information, and if so, use the first device status information to update the original first device status information.

[0116] In this embodiment, if Figure 2 As shown, when the first device state of any one or more first network control devices (for example, network control device a1) among the network control devices a1, a2, a3, and a4 connected to the target hot standby gateway A changes, the first device state information (for example, level 2 brightness) of the first network control device a1 is uploaded to the distributed application coordination service cluster through the distributed application coordination service deployed by itself.

[0117] When other hot standby gateways (for example, hot standby gateway B) other than the target hot standby gateway A monitor that the first device status information of the first network control device a1 stored in the distributed application coordination service cluster changes, the hot standby gateway B obtains the first device status information of the first network control device a1 from the distributed application coordination service cluster; when the original first device status information of the first network control device a1 (for example, level 1 brightness) is not stored in the hot standby gateway B, the first device status information of the first network control device a1 (for example, level 2 brightness) is stored in the hot standby gateway B; when the original first device status information of the first network control device (for example, level 2 brightness) is stored in the hot standby gateway B, the hot standby gateway B determines whether the first state change timestamp in the first device status information is later than the state change timestamp in the original first device status information; if so, the first device status information is used to update the original first device status information.

[0118] Through the above method, when the device status of any network control device (including a1 to a4, b1 to b5, and c1 to c2) changes, each hot standby gateway (including hot standby gateways A, B, and C) can update the device status of each network control device stored in itself in real time without manual adjustment.

[0119] In a possible implementation, a first control screen is also provided in each physical space;

[0120] The first control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the first control screen is located is normal; when the operating status of the hot standby gateway is abnormal, based on the gateway address information of each other hot standby gateway stored in itself, it sends detection requests to other hot standby gateways in turn, so as to obtain the second hot standby gateway currently responsible for the physical space where the first control screen is located from the hot standby gateways that are operating normally among the other hot standby gateways, and establish a connection with the second hot standby gateway.

[0121] In this embodiment, for the first control screen in any physical space, such as the first control screen in physical space 4, the first control screen is used to periodically send http network requests to the hot standby gateway C corresponding to the physical space 4, and judge whether the operation status of the hot standby gateway C is normal or abnormal according to the information fed back by the hot standby gateway C. When the operation status of the hot standby gateway C is abnormal, the first control screen in the physical space 4 sends detection requests to other hot standby gateways (including hot standby gateways A and B) in sequence based on the gateway address information of each other hot standby gateway (including hot standby gateways A and B) stored in itself, so as to obtain the second hot standby gateway (such as hot standby gateway A) currently responsible for the physical space 4 from the hot standby gateways (such as hot standby gateway A) that are operating normally among the other hot standby gateways (including hot standby gateways A and B), and establish a connection with the second hot standby gateway A.

[0122] In this embodiment, the second hot standby gateway may be the target hot standby gateway, or may be another hot standby gateway that operates normally except the target hot standby gateway.

[0123] In the second case, if Figure 5 As shown, when the hot standby gateways only include two hot standby gateways that back up each other, when executing step S101, the following steps may be specifically performed:

[0124] A first network request is periodically sent to another hot standby gateway that is in mutual backup with the target hot standby gateway; when no first feedback information of the other hot standby gateway is received, it is characterized that the other hot standby gateway is an abnormally operating hot standby gateway.

[0125] In this embodiment, if Figure 5 As shown, hot standby gateway D and hot standby gateway E are mutual standby gateways, and the target hot standby gateway can be hot standby gateway D or hot standby gateway E. Hot standby gateway D periodically sends a first network request to hot standby gateway E, wherein the first network request can be an http network request. When hot standby gateway D does not receive the first feedback information fed back by hot standby gateway E, it indicates that hot standby gateway E is an abnormal hot standby gateway. On the contrary, when hot standby gateway D receives the first feedback information fed back by hot standby gateway E, it indicates that hot standby gateway E is a normal hot standby gateway.

[0126] Similarly, the hot standby gateway E will also periodically send the first network request to the hot standby gateway D. When the hot standby gateway E does not receive the first feedback information fed back by the hot standby gateway D, it indicates that the hot standby gateway D is an abnormal hot standby gateway. If the hot standby gateway E receives the first feedback information fed back by the hot standby gateway D, it indicates that the hot standby gateway D is a normal hot standby gateway.

[0127] In a possible implementation manner, when executing step S102, the following steps S1024-S1026 may be specifically performed:

[0128] S1024: When the other hot standby gateway is an abnormally operating hot standby gateway, query all second physical spaces that the abnormally operating hot standby gateway is responsible for;

[0129] S1025: Determine the network control devices located in each second physical space;

[0130] S1026: Use the target hot standby gateway to establish a connection with each network control device in the second physical space, so that the target hot standby gateway takes over the control of the network control device in the second physical space.

[0131] Exemplarily, taking hot standby gateway D as the target hot standby gateway as an example, when hot standby gateway E is the hot standby gateway with abnormal operation, all second physical spaces responsible for hot standby gateway E are queried, such as Figure 5As shown, it is assumed that the second physical space that the hot standby gateway E is responsible for is physical space 6 and physical space 7. The network control devices in the second physical space 6 and the second physical space 7 are determined to be network control devices e1, e2, e3, e4, and e5 respectively. The target hot standby gateway D is connected to the network control devices e1 and e2 in the second physical space 6 and the network control devices e3, e4, and e5 in the second physical space, so that the target hot standby gateway D takes over the control of the network control devices e1 and e2 in the second physical space 6 and the network control devices e3, e4, and e5 in the second physical space.

[0132] In a possible implementation manner, after executing step S1026, the following steps may also be performed:

[0133] S1031: Periodically sending a second network request to another hot standby gateway that has mutual backup with the target hot standby gateway;

[0134] S1032: When receiving second feedback information from another hot standby gateway, disconnect the connection with the network control device in the second physical space to release the control right over the network control device in the second physical space.

[0135] Following the above embodiment, Figure 5 As shown, after the target hot standby gateway D takes over the control of the network control devices e1, e2 and the network control devices e3, e4, and e5 in the second physical space 6, the target hot standby gateway D periodically sends a second network request to the hot standby gateway E, and the second network request can be an http network request. When the operation of the hot standby gateway E returns to normal, the hot standby gateway E will feedback the second feedback information to the target hot standby gateway D. After receiving the second feedback information sent by the hot standby gateway E indicating that the operation status of the hot standby gateway E has returned to normal, the target hot standby gateway D disconnects the connection with the network control devices e1, e2 and the network control devices e3, e4, and e5 in the second physical space 6, so that the target hot standby gateway D releases the control of the network control devices e1, e2 and the network control devices e3, e4, and e5 in the second physical space 6. The hot standby gateway E then establishes a connection with the network control devices e1, e2 and the network control devices e3, e4, and e5 in the second physical space 6 to regain control.

[0136] In a possible implementation, considering the mutual backup hot standby gateway D and hot standby gateway E, the hot standby gateway D only stores the initial device states of the network control devices e1, e2, e3, e4, and e5. When the hot standby gateway D takes over the network control devices e1, e2, e3, e4, and e5, it is necessary to manually adjust the initial device states of the network control devices e1, e2, e3, e4, and e5 stored in the hot standby gateway D to the actual device states. Conversely, the hot standby gateway E also stores the initial device states of the network control devices d1, d2, d3, and d4. When the hot standby gateway E takes over the control of the network control devices d1, d2, d3, and d4, it is also necessary to manually adjust the initial device states of the network control devices d1, d2, d3, and d4 stored in the hot standby gateway E to the actual device states. In this way, when there are many network control devices, it takes a long time to adjust the device states of each network control device, and the process is cumbersome and inefficient. Based on this, the method also includes the following steps:

[0137] When the second device status information of any one or more second network control devices in the network control devices connected to the target hot standby gateway changes, the second device status information of the second network control device is sent to another hot standby gateway that is mutually backed up with the target hot standby gateway; the second device status information includes the changed second device status and the second status change timestamp;

[0138] Another hot standby gateway is used to store the second device status information when receiving the second device status information, when the second device status information is not stored in the other hot standby gateway; when the original second device status information of the target hot standby gateway is stored in the other hot standby gateway, determine whether the second status change timestamp in the second device status information is later than the status change timestamp in the original second device status information, and if so, use the second device status information to update the original second device status information.

[0139] For example, Figure 2 As shown, the target hot standby gateway may be the hot standby gateway D or the hot standby gateway E. When the target hot standby gateway is the hot standby gateway D, if the second device status information of the network control device d1 connected to the target hot standby gateway D changes, for example, when the second device status information of the network control device d1 changes from the first level loudness to the second level loudness, the second device status information (for example, the second level loudness) of the second network control device is sent to the hot standby gateway E.

[0140] When the hot standby gateway E receives the second device status information (e.g., level 2 loudness), if the hot standby gateway E does not store the second device status information, the second device status information is stored. When the hot standby gateway E stores the original second device status information (e.g., level 1 loudness) of the target hot standby gateway D, it is determined whether the second state change timestamp in the second device status information (e.g., level 2 loudness) is later than the state change timestamp in the original second device status information (e.g., level 1 loudness). If the second state change timestamp in the second device status information (e.g., level 2 loudness) is later than the state change timestamp in the original second device status information (e.g., level 1 loudness), the second device status information (e.g., level 2 loudness) is used to update the original second device status information. In this way, the hot standby gateway E stores the latest second device status information of each network control device (d1, d2, d3, d4) controlled by the hot standby gateway D. When an abnormality occurs in the hot standby gateway D, after the hot standby gateway E takes over the network control devices d1, d2, d3, d4, the hot standby gateway E can directly control the network control devices d1, d2, d3, d4 according to the latest second device status information of each network control device d1, d2, d3, d4 stored in itself.

[0141] Through the above method, the two hot standby gateways that back up each other can timely update the device status of each network control device controlled by the other hot standby gateway stored in themselves, which is beneficial for directly controlling the network control device controlled by the other party according to the latest second device information when taking over the network control device controlled by the other party.

[0142] In a possible implementation, a second control screen is further provided in each physical space; after executing step S1026, the method further includes:

[0143] When the operating status of another hot standby gateway is abnormal, a connection establishment request sent by the second control screen in the second physical space is received to establish a connection with the second control screen in the second physical space; wherein the second control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the second control screen is located is normal.

[0144] For example, Figure 5 As shown, the second control screen in physical space 5 will periodically send a third network request to hot standby gateway D, such as an http request, to detect whether the operating status of hot standby gateway D is normal. The second control screens in physical spaces 6 and 7 will also periodically send a third network request to hot standby gateway E to detect whether the operating status of hot standby gateway E is normal.

[0145] When the second control screen in the physical space 5 detects that the operating status of the hot standby gateway D is abnormal, the target hot standby gateway is the hot standby gateway E. The second control screen in the physical space 5 will send a connection establishment request to the hot standby gateway E. The hot standby gateway E receives the connection establishment request sent by the second control screen in the second physical space (ie, physical space 5). The hot standby gateway E establishes a connection with the second control screen in the second physical space 5. In this way, the user can use the second control screen in the second physical space 5 to control various network control devices in the second physical space 5 through the hot standby gateway E.

[0146] Similarly, when the second control screen in physical space 6 and 7 detects that the operating status of hot standby gateway E is abnormal, the target hot standby gateway is hot standby gateway D. The second control screen in physical space 6 and 7 will send a connection establishment request to hot standby gateway D. Hot standby gateway D receives the connection establishment request sent by the second control screen in the second physical space (ie, physical space 6 and 7). Hot standby gateway D establishes a connection with the second control screen in the second physical space 6 and 7. In this way, the user can use the second control screen in the second physical space 6 to control the various network control devices in the second physical space 6 through the hot standby gateway D, and the user can use the second control screen in the second physical space 7 to control the various network control devices in the second physical space 7 through the hot standby gateway D.

[0147] Based on the same technical concept, the present application also provides a target hot standby gateway, wherein the target hot standby gateway is any one of at least two hot standby gateways in the same network segment that is operating normally; each of the hot standby gateways is respectively connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself; the target hot standby gateway is used to:

[0148] Determine whether there is an abnormal hot standby gateway among the hot standby gateways;

[0149] When there is an abnormal hot standby gateway among the hot standby gateways, the hot standby gateway that is operating normally among the hot standby gateways is instructed to establish a connection with a target network control device so that the instructed hot standby gateway takes over the control of the target network control device; the target network control device is a network control device connected to the abnormal hot standby gateway.

[0150] Optionally, there are multiple physical spaces, and at least one of the network control devices is arranged in each of the physical spaces; each of the hot standby gateways is responsible for at least one of the physical spaces; each of the hot standby gateways is connected to each of the network control devices in the physical space that the hot standby gateway is responsible for via a switch; the switch is connected to at least one of the hot standby gateways; when there are multiple switches, the switches are connected to each other.

[0151] Optionally, when there are multiple hot standby gateways, a distributed application coordination service is deployed in each of the hot standby gateways, and the distributed application coordination services deployed in all the hot standby gateways in the same network segment constitute a distributed application coordination service cluster; the distributed application coordination service is used to store the operating status of the hot standby gateway deployed by the distributed application coordination service; the operating status includes normal operation and abnormal operation; the distributed application coordination services in the distributed application coordination service cluster share the operating status of the hot standby gateway stored in themselves, so that each distributed application coordination service obtains the operating status of each hot standby gateway;

[0152] When the target hot standby gateway is used to determine whether there is an abnormal hot standby gateway among the hot standby gateways, the target hot standby gateway is specifically used to:

[0153] When the distributed application coordination service deployed by itself has an operating abnormality in the operating status of each hot standby gateway obtained from the distributed application coordination service cluster, it receives a gateway abnormality notification sent by the distributed application coordination service deployed by itself to determine whether there is a hot standby gateway with an operating abnormality among the hot standby gateways.

[0154] Optionally, when the target hot standby gateway is used to instruct a hot standby gateway operating normally among the hot standby gateways to establish a connection with a target network control device when there is a hot standby gateway operating abnormally among the hot standby gateways, so that the indicated hot standby gateway takes over the control of the target network control device, the target hot standby gateway is specifically used to:

[0155] When there is an abnormal hot standby gateway among the hot standby gateways, the gateway information of the hot standby gateway whose running status is normal is obtained from the distributed application coordination service deployed by itself;

[0156] According to the first physical spaces that are responsible for all the hot standby gateways that are operating normally and all the hot standby gateways that are operating abnormally, each of the first physical spaces is reallocated to each hot standby gateway that is operating normally, to obtain a respective allocation result for each hot standby gateway that is operating normally; the allocation result includes the first physical space that the hot standby gateway needs to be responsible for;

[0157] The allocation result of each hot standby gateway that is operating normally is uploaded to the distributed application coordination service cluster, so that for each hot standby gateway that is operating normally, the hot standby gateway establishes a connection with the network control device in the first physical space included in the allocation result according to the first physical space included in its own allocation result, and takes over the control of the network control device in the first physical space included in the allocation result.

[0158] Optionally, when the target hot standby gateway is used to reallocate each of the first physical spaces to each hot standby gateway that is operating normally, according to the first physical spaces that are responsible for all the hot standby gateways that are operating normally and all the hot standby gateways that are operating abnormally, the target hot standby gateway is specifically used to:

[0159] Re-allocating each of the first physical spaces to a hot standby gateway that is operating normally by any one of the following four allocation methods;

[0160] The first allocation method is: randomly allocating each first physical space to a hot standby gateway that is operating normally;

[0161] The second allocation method is:

[0162] Determine the current load of each hot standby gateway that is operating normally according to the number of network control devices currently connected to each hot standby gateway that is operating normally;

[0163] Based on the current load of each hot standby gateway operating normally, allocating each first physical space to the hot standby gateway operating normally;

[0164] The third allocation method is:

[0165] For each of the first physical spaces, calculate a hash value of the space number of the first physical space; wherein each of the first physical spaces corresponds to its own space number;

[0166] Calculate the ratio of the hash value to the number of hot standby gateways that are operating normally, take the remainder of the ratio, and obtain the remainder corresponding to the first physical space;

[0167] According to the remainder of the first physical space and the first gateway number of each normally operating hot standby gateway, determine from each first gateway number a first gateway number that is the same as the remainder of the first physical space, so as to allocate the first physical space to the normally operating hot standby gateway corresponding to the first gateway number;

[0168] The fourth allocation method is:

[0169] Construct a target ring;

[0170] According to the numbering sequence of the second gateway numbers of all the hot standby gateways and the specified direction, the gateway identifiers of all the hot standby gateways are evenly arranged on the target ring in sequence; wherein the specified direction is a clockwise direction or a counterclockwise direction;

[0171] For every two adjacent gateway identifiers arranged on the target circular ring, on the circular ring segment between the two gateway identifiers, the gateway identifiers of all the hot standby gateways are evenly arranged on the circular ring segment in sequence according to the numbering sequence of all the hot standby gateways and the specified direction, and, on the circular ring segment between the two gateway identifiers, the space identifiers of the physical space responsible for the hot standby gateway corresponding to the first gateway identifier of the two gateway identifiers are evenly arranged on the circular ring segment in sequence; wherein the first gateway identifier is the gateway identifier in the direction indicated by the specified direction of the two gateway identifiers arranged on the target circular ring;

[0172] Deleting the gateway identifiers of all abnormally running hot standby gateways from the target ring;

[0173] For each first physical space that is responsible for all abnormally operating hot standby gateways, based on the arrangement distance between the space identifier of the first physical space on the target ring and the gateway identifier of each normally operating hot standby gateway and the specified direction, the first physical space is allocated to the hot standby gateway corresponding to the gateway identifier that is in the specified direction and closest to the arrangement distance between the space identifier of the first physical space.

[0174] Optionally, the target hot standby gateway is further used for:

[0175] When the first device state of any one or more first network control devices among the network control devices connected to the target hot standby gateway changes, the first device state information of the first network control device is uploaded to the distributed application coordination service cluster through the distributed application coordination service deployed by itself; wherein the first device state information includes the first device identifier, the changed first device state, and the first state change timestamp;

[0176] Other hot standby gateways are used to obtain the first device status information of the first network control device from the distributed application coordination service cluster when monitoring changes in the first device status information of the first network control device stored in the distributed application coordination service cluster; when the original first device status information of the first network control device is not stored in the other hot standby gateway, store the first device status information of the first network control device in the other hot standby gateway; when the original first device status information of the first network control device is stored in the other hot standby gateway, determine whether the first state change timestamp in the first device status information is later than the state change timestamp in the original first device status information; if so, use the first device status information to update the original first device status information.

[0177] Optionally, a first control screen is also provided in each of the physical spaces;

[0178] The first control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the first control screen is located is normal; when the operating status of the hot standby gateway is abnormal, based on the gateway address information of each other hot standby gateway stored in itself, it sends detection requests to other hot standby gateways in turn, so as to obtain the second hot standby gateway currently responsible for the physical space where the first control screen is located from the hot standby gateways that are operating normally among the other hot standby gateways, and establish a connection with the second hot standby gateway.

[0179] Optionally, when the hot standby gateways include only two hot standby gateways that back up each other, the target hot standby gateway, when used to determine whether there is an abnormally operating hot standby gateway among the hot standby gateways, is specifically used to:

[0180] The first network request is periodically sent to another hot standby gateway that is in mutual backup with the target hot standby gateway; when the first feedback information of the other hot standby gateway is not received, it is characterized that the other hot standby gateway is an abnormally operating hot standby gateway.

[0181] Optionally, when the target hot standby gateway is used to instruct a hot standby gateway operating normally among the hot standby gateways to establish a connection with a target network control device when there is a hot standby gateway operating abnormally among the hot standby gateways, so that the indicated hot standby gateway takes over the control of the target network control device, the target hot standby gateway is specifically used to:

[0182] When the other hot standby gateway is an abnormally operating hot standby gateway, querying all second physical spaces that the abnormally operating hot standby gateway is responsible for;

[0183] Determining network control devices located in each of the second physical spaces;

[0184] The target hot standby gateway is used to establish a connection with each network control device in the second physical space, so that the target hot standby gateway takes over the control of the network control device in the second physical space.

[0185] Optionally, after the target hot standby gateway is used to establish a connection with each network control device in the second physical space using the target hot standby gateway so that the target hot standby gateway takes over the control of the network control device in the second physical space, the target hot standby gateway is further used to:

[0186] Periodically sending a second network request to another hot standby gateway that is in mutual backup with the target hot standby gateway;

[0187] When second feedback information from another hot standby gateway is received, the connection with the network control device in the second physical space is disconnected to release the control right over the network control device in the second physical space.

[0188] Optionally, the target hot standby gateway is further used for:

[0189] When the second device status information of any one or more second network control devices among the network control devices connected to the target hot standby gateway changes, the second device status information of the second network control device is sent to another hot standby gateway that is mutually backed up with the target hot standby gateway; the second device status information includes the changed second device status and the second status change timestamp;

[0190] Another hot standby gateway is used to store the second device status information when receiving the second device status information, when the second device status information is not stored in the other hot standby gateway; when the original second device status information of the target hot standby gateway is stored in the other hot standby gateway, determine whether the second state change timestamp in the second device status information is later than the state change timestamp in the original second device status information, and if so, use the second device status information to update the original second device status information.

[0191] Optionally, a second control screen is further provided in each of the physical spaces; and the target hot standby gateway is further used for:

[0192] When the operating status of another hot standby gateway is abnormal, a connection establishment request sent by the second control screen in the second physical space is received to establish a connection with the second control screen in the second physical space; wherein the second control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the second control screen is located is normal.

[0193] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the target hot standby gateway described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0194] In the several embodiments provided in the present application, it should be understood that the disclosed target hot standby gateway and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0195] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0196] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0197] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0198] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A hot standby method for a gateway, characterized in that: The method is applied to any one of at least two hot standby gateways in the same network segment that is operating normally; each of the hot standby gateways is respectively connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself; the method includes: Determine whether there is an abnormal hot standby gateway among the hot standby gateways; When there is an abnormal hot standby gateway among the hot standby gateways, instructing the hot standby gateway that is operating normally among the hot standby gateways to establish a connection with a target network control device, so that the indicated hot standby gateway takes over the control right of the target network control device; the target network control device is a network control device connected to the abnormal hot standby gateway; There are multiple physical spaces, each of which is provided with at least one network control device; each hot standby gateway is responsible for at least one physical space; each hot standby gateway is connected to each network control device in the physical space that the hot standby gateway is responsible for through a switch; the switch is connected to at least one hot standby gateway; when there are multiple switches, the switches are connected to each other; When there are multiple hot standby gateways, a distributed application coordination service is deployed in each of the hot standby gateways, and the distributed application coordination services deployed in all the hot standby gateways in the same network segment constitute a distributed application coordination service cluster; the distributed application coordination service is used to store the operating status of the hot standby gateway deployed by the distributed application coordination service; the operating status includes normal operation and abnormal operation; the distributed application coordination services in the distributed application coordination service cluster share the operating status of the hot standby gateway stored in themselves, so that each distributed application coordination service obtains the operating status of each hot standby gateway; When there is an abnormal hot standby gateway among the hot standby gateways, instructing a hot standby gateway that is operating normally among the hot standby gateways to establish a connection with a target network control device so that the indicated hot standby gateway takes over the control right of the target network control device, including: When there is an abnormal hot standby gateway among the hot standby gateways, the gateway information of the hot standby gateway whose running status is normal is obtained from the distributed application coordination service deployed by itself; According to the first physical spaces that are responsible for all the hot standby gateways that are operating normally and all the hot standby gateways that are operating abnormally, each of the first physical spaces is reallocated to each hot standby gateway that is operating normally, to obtain a respective allocation result for each hot standby gateway that is operating normally; the allocation result includes the first physical space that the hot standby gateway needs to be responsible for; The allocation result of each normally operating hot standby gateway is uploaded to the distributed application coordination service cluster, so that for each normally operating hot standby gateway, the hot standby gateway establishes a connection with the network control device in the first physical space included in the allocation result according to the first physical space included in its own allocation result, and takes over the control of the network control device in the first physical space included in the allocation result; The reallocating each of the first physical spaces to the hot standby gateways that are operating normally according to the first physical spaces that are responsible for all the hot standby gateways that are operating normally and all the hot standby gateways that are operating abnormally includes: Re-allocating each of the first physical spaces to a hot standby gateway that is operating normally by any one of the following two allocation methods; One way to allocate is: For each of the first physical spaces, calculate a hash value of the space number of the first physical space; wherein each of the first physical spaces corresponds to its own space number; Calculate the ratio of the hash value to the number of hot standby gateways that are operating normally, take the remainder of the ratio, and obtain the remainder corresponding to the first physical space; According to the remainder of the first physical space and the first gateway number of each normally operating hot standby gateway, determine from each first gateway number a first gateway number that is the same as the remainder of the first physical space, so as to allocate the first physical space to the normally operating hot standby gateway corresponding to the first gateway number; Another way to allocate is: Construct a target ring; According to the numbering sequence of the second gateway numbers of all the hot standby gateways and the specified direction, the gateway identifiers of all the hot standby gateways are evenly arranged on the target ring in sequence; wherein the specified direction is a clockwise direction or a counterclockwise direction; For every two adjacent gateway identifiers arranged on the target circular ring, on the circular ring segment between the two gateway identifiers, the gateway identifiers of all the hot standby gateways are evenly arranged on the circular ring segment in sequence according to the numbering sequence of all the hot standby gateways and the specified direction, and, on the circular ring segment between the two gateway identifiers, the space identifiers of the physical space responsible for the hot standby gateway corresponding to the first gateway identifier of the two gateway identifiers are evenly arranged on the circular ring segment in sequence; wherein the first gateway identifier is the gateway identifier in the direction indicated by the specified direction of the two gateway identifiers arranged on the target circular ring; Deleting the gateway identifiers of all abnormally running hot standby gateways from the target ring; For each first physical space that is responsible for all abnormally operating hot standby gateways, based on the arrangement distance between the space identifier of the first physical space on the target ring and the gateway identifier of each normally operating hot standby gateway and the specified direction, the first physical space is allocated to the hot standby gateway corresponding to the gateway identifier that is in the specified direction and closest to the arrangement distance between the space identifier of the first physical space.

2. The method according to claim 1, characterized in that: The determining whether there is an abnormal hot standby gateway among the hot standby gateways comprises: When the distributed application coordination service deployed by itself has an operating abnormality in the operating status of each hot standby gateway obtained from the distributed application coordination service cluster, it receives a gateway abnormality notification sent by the distributed application coordination service deployed by itself to determine whether there is a hot standby gateway with an operating abnormality among the hot standby gateways.

3. The method according to claim 1, characterized in that: The method further comprises: When the first device state of any one or more first network control devices among the network control devices connected to the target hot standby gateway changes, the first device state information of the first network control device is uploaded to the distributed application coordination service cluster through the distributed application coordination service deployed by itself; wherein the first device state information includes the first device identifier, the changed first device state, and the first state change timestamp; Other hot standby gateways are used to obtain the first device status information of the first network control device from the distributed application coordination service cluster when monitoring changes in the first device status information of the first network control device stored in the distributed application coordination service cluster; when the original first device status information of the first network control device is not stored in the other hot standby gateway, store the first device status information of the first network control device in the other hot standby gateway; when the original first device status information of the first network control device is stored in the other hot standby gateway, determine whether the first state change timestamp in the first device status information is later than the state change timestamp in the original first device status information; if so, use the first device status information to update the original first device status information.

4. The method according to claim 1, characterized in that: A first control screen is also provided in each of the physical spaces; The first control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the first control screen is located is normal; when the operating status of the hot standby gateway is abnormal, based on the gateway address information of each other hot standby gateway stored in itself, it sends detection requests to other hot standby gateways in turn, so as to obtain the second hot standby gateway currently responsible for the physical space where the first control screen is located from the hot standby gateways that are operating normally among the other hot standby gateways, and establish a connection with the second hot standby gateway.

5. The method according to claim 1, characterized in that: When the hot standby gateways include only two hot standby gateways that standby each other, determining whether there is an abnormal hot standby gateway among the hot standby gateways includes: The first network request is periodically sent to another hot standby gateway that is in mutual backup with the target hot standby gateway; when the first feedback information of the other hot standby gateway is not received, it is characterized that the other hot standby gateway is an abnormally operating hot standby gateway.

6. The method according to claim 5, characterized in that: When there is an abnormal hot standby gateway among the hot standby gateways, instructing a hot standby gateway that is operating normally among the hot standby gateways to establish a connection with a target network control device so that the indicated hot standby gateway takes over the control right of the target network control device, including: When the other hot standby gateway is an abnormally operating hot standby gateway, querying all second physical spaces that the abnormally operating hot standby gateway is responsible for; Determining network control devices located in each of the second physical spaces; The target hot standby gateway is used to establish a connection with each network control device in the second physical space, so that the target hot standby gateway takes over the control of the network control device in the second physical space.

7. The method according to claim 6, characterized in that: After using the target hot standby gateway to establish a connection with each network control device in the second physical space so that the target hot standby gateway takes over the control of the network control device in the second physical space, the method further includes: Periodically sending a second network request to another hot standby gateway that is in mutual backup with the target hot standby gateway; When second feedback information from another hot standby gateway is received, the connection with the network control device in the second physical space is disconnected to release the control right over the network control device in the second physical space.

8. The method according to claim 5, characterized in that: The method further comprises: When the second device status information of any one or more second network control devices among the network control devices connected to the target hot standby gateway changes, the second device status information of the second network control device is sent to another hot standby gateway that is mutually backed up with the target hot standby gateway; the second device status information includes the changed second device status and the second status change timestamp; Another hot standby gateway is used to store the second device status information when receiving the second device status information, when the second device status information is not stored in the other hot standby gateway; when the original second device status information of the target hot standby gateway is stored in the other hot standby gateway, determine whether the second state change timestamp in the second device status information is later than the state change timestamp in the original second device status information, and if so, use the second device status information to update the original second device status information.

9. The method according to claim 6, characterized in that: A second control screen is also provided in each of the physical spaces; the method further comprises: When the operating status of another hot standby gateway is abnormal, a connection establishment request sent by the second control screen in the second physical space is received to establish a connection with the second control screen in the second physical space; wherein the second control screen is used to periodically detect whether the operating status of the hot standby gateway corresponding to the physical space where the second control screen is located is normal.

10. A target hot standby gateway, characterized in that: The target hot standby gateway is any one of at least two hot standby gateways in the same network segment that is operating normally; each of the hot standby gateways is connected to at least one network control device, and the hot standby gateway is used to control the network control device connected to itself; the target hot standby gateway is used to: Determine whether there is an abnormal hot standby gateway among the hot standby gateways; When there is an abnormal hot standby gateway among the hot standby gateways, instructing the hot standby gateway that is operating normally among the hot standby gateways to establish a connection with a target network control device, so that the indicated hot standby gateway takes over the control right of the target network control device; the target network control device is a network control device connected to the abnormal hot standby gateway; There are multiple physical spaces, each of which is provided with at least one network control device; each of the hot standby gateways is responsible for at least one of the physical spaces; each of the hot standby gateways is connected to each of the network control devices in the physical space that the hot standby gateway is responsible for via a switch; The switch is connected to at least one of the hot standby gateways; when there are multiple switches, the switches are connected to each other; When there are multiple hot standby gateways, a distributed application coordination service is deployed in each of the hot standby gateways, and the distributed application coordination services deployed in all the hot standby gateways in the same network segment constitute a distributed application coordination service cluster; the distributed application coordination service is used to store the operating status of the hot standby gateway deployed by the distributed application coordination service; the operating status includes normal operation and abnormal operation; the distributed application coordination services in the distributed application coordination service cluster share the operating status of the hot standby gateway stored in themselves, so that each distributed application coordination service obtains the operating status of each hot standby gateway; The target hot standby gateway is used to instruct a hot standby gateway that is operating normally among the hot standby gateways to establish a connection with a target network control device when there is a hot standby gateway that is operating abnormally among the hot standby gateways, so that the indicated hot standby gateway takes over the control right of the target network control device, specifically for: When there is an abnormal hot standby gateway among the hot standby gateways, the gateway information of the hot standby gateway whose running status is normal is obtained from the distributed application coordination service deployed by itself; According to the first physical spaces that are responsible for all the hot standby gateways that are operating normally and all the hot standby gateways that are operating abnormally, each of the first physical spaces is reallocated to each hot standby gateway that is operating normally, so as to obtain a respective allocation result for each hot standby gateway that is operating normally; The allocation result includes the first physical space that the hot standby gateway needs to be responsible for; The allocation result of each normally operating hot standby gateway is uploaded to the distributed application coordination service cluster, so that for each normally operating hot standby gateway, the hot standby gateway establishes a connection with the network control device in the first physical space included in the allocation result according to the first physical space included in its own allocation result, and takes over the control of the network control device in the first physical space included in the allocation result; When the target hot standby gateway is used to reallocate each of the first physical spaces to each of the hot standby gateways that are operating normally, according to the first physical spaces that are responsible for all the hot standby gateways that are operating normally and all the hot standby gateways that are operating abnormally, the target hot standby gateway is specifically used to: Re-allocating each of the first physical spaces to a hot standby gateway that is operating normally by any one of the following two allocation methods; One way to allocate is: For each of the first physical spaces, calculate a hash value of the space number of the first physical space; wherein each of the first physical spaces corresponds to its own space number; Calculate the ratio of the hash value to the number of hot standby gateways that are operating normally, take the remainder of the ratio, and obtain the remainder corresponding to the first physical space; According to the remainder of the first physical space and the first gateway number of each normally operating hot standby gateway, determine from each first gateway number a first gateway number that is the same as the remainder of the first physical space, so as to allocate the first physical space to the normally operating hot standby gateway corresponding to the first gateway number; Another way to allocate is: Construct a target ring; According to the numbering sequence of the second gateway numbers of all the hot standby gateways and the specified direction, the gateway identifiers of all the hot standby gateways are evenly arranged on the target ring in sequence; wherein the specified direction is a clockwise direction or a counterclockwise direction; For every two adjacent gateway identifiers arranged on the target circular ring, on the circular ring segment between the two gateway identifiers, in accordance with the numbering sequence of all the hot standby gateways and the specified direction, the gateway identifiers of all the hot standby gateways are evenly arranged on the circular ring segment in sequence, and, on the circular ring segment between the two gateway identifiers, the space identifiers of the physical space responsible for the hot standby gateway corresponding to the first gateway identifier of the two gateway identifiers are evenly arranged on the circular ring segment in sequence; wherein the first gateway identifier is the gateway identifier in the direction indicated by the specified direction of the two gateway identifiers arranged on the target circular ring; Deleting the gateway identifiers of all abnormally running hot standby gateways from the target ring; For each first physical space that is responsible for all abnormally operating hot standby gateways, based on the arrangement distance between the space identifier of the first physical space on the target ring and the gateway identifier of each normally operating hot standby gateway and the specified direction, the first physical space is allocated to the hot standby gateway corresponding to the gateway identifier that is in the specified direction and closest to the arrangement distance between the space identifier of the first physical space.

Citation Information

Patent Citations

  • Gateway recovery method and device, equipment

    CN107360034A