Master node election method and substation automation system

By adopting a multi-node architecture and election mechanism in the substation automation system, the problems of low resource utilization and insufficient stability under the main and standby dual-machine architecture are solved, and higher resource utilization and operational stability are achieved.

CN119155153APending Publication Date: 2024-12-17CHINA SOUTHERN POWER GRID COMPANY

Patent Information

Application Number
CN202411216261.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

The main and backup dual-machine architecture in the existing substation automation system results in low system resource utilization and may cause system failure when the main node fails.

Method used

Using a multi-node architecture, the master node is determined through the election mechanism, and multiple slave nodes are used to participate in the system operation to avoid idle resources, and elect a new master node to continue running when the master node fails.

Benefits of technology

It improves system resource utilization and operation stability, avoids global failure caused by failure of main and standby dual-machines, and enhances the high availability and flexibility of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119155153A_ABST
    Figure CN119155153A_ABST
Patent Text Reader

Abstract

The invention discloses a main node election method and a substation automation system, and belongs to the field of power system operation and maintenance. The method comprises the following steps: a first node sends an election message carrying a second duration and an identifier of the first node to other nodes; and after receiving the election message, the second node determines the main node according to the second duration of the first node, the second duration of the second node, the identifier of the first node and the identifier of the second node. The n nodes in the substation automation system comprise one master node and a plurality of slave nodes, the master node is used for communicating with the external system, and the master node is used for indicating the plurality of slave nodes to execute the operation, so that each node in the n nodes can participate in the operation of the substation automation system, resource idleness can be avoided, and the reliability of the substation automation system is improved. And the system resource utilization rate is improved. Moreover, when the master node has a fault, the plurality of slave nodes can elect a new master node for continuous operation, so that the operation stability of the substation automation system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of power system operation and maintenance, and in particular to a master node election method and a substation automation system. Background Art

[0002] Substation automation system has been widely used in substations due to its features of remote control, automatic monitoring and automatic protection, so as to achieve efficient and reliable operation and management of substations.

[0003] At present, the substation automation system is operated in a master-slave dual-machine mode. Specifically, the substation automation system is built on two devices, one device is used as the master device, and the other device is used as the backup device. Under normal circumstances, the master device implements the system functions. When the master device fails, the technicians start the backup device to continue to implement the system functions. However, this method has low system resource utilization. Summary of the invention

[0004] The present application provides a master node election method and a substation automation system, which can improve the utilization rate of system resources. The technical solution is as follows:

[0005] In a first aspect, a master node election method is provided, which is applied to a substation automation system, wherein the substation automation system includes n nodes, where n is an integer greater than or equal to 3, and the method includes:

[0006] The first node sends an election message to each of the other n-1 nodes, the election message carrying the second term of the first node and the identifier of the first node, the first node being the slave node that initiates the election among the n nodes; wherein the second term of the node that does not initiate the election in this round of master node election is the same as the first term, the second term of the node that initiates the election in this round of master node election is the first term plus 1, and the first term of the node is the number of master node election rounds in which the node participates;

[0007] A second node receives the election message sent by the first node, and the second node is any one of the n nodes except the first node; the second node determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node and the identifier of the second node; wherein the n nodes include a master node and multiple slave nodes, the master node is used to communicate with an external system, and the master node is used to instruct the multiple slave nodes to perform operations.

[0008] In the present application, the first node among the n nodes included in the substation automation system sends an election message to each of the other n-1 nodes, and the election message carries the second term of the first node and the identifier of the first node. After the second node among the n nodes receives the election message sent by the first node, it determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node and the identifier of the second node. In the present application, the n nodes include a master node and multiple slave nodes, the master node is used to communicate with an external system, and the master node is used to instruct multiple slave nodes to perform operations, so that each of the n nodes can participate in the operation of the substation automation system, thereby avoiding idle resources and improving system resource utilization. In addition, when the master node fails, multiple slave nodes can elect a new master node to continue to operate, thereby improving the operational stability of the substation automation system.

[0009] Optionally, the second node determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node, including:

[0010] If the second term of the first node is greater than the second term of the second node, the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes; or, if the second term of the first node is the same as the second term of the second node, and the identifier of the first node is greater than the identifier of the second node, the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes;

[0011] The second node receives voting messages sent by other nodes;

[0012] If the second node determines that the number of votes of the first node is greater than or equal to the preset number of votes based on the voting message sent by itself and the voting messages sent by other nodes, the first node is determined to be the master node.

[0013] Optionally, the method further comprises:

[0014] If the second term of the first node is smaller than the second term of the second node, the second node discards the election message.

[0015] Optionally, the method further comprises:

[0016] If the second term of the first node is the same as the second term of the second node, and the identifier of the first node is smaller than the identifier of the second node, the second node discards the election message.

[0017] Optionally, the method further comprises:

[0018] If the first node determines that an election needs to be initiated, the second term of the first node is increased by 1;

[0019] After the first node initiates the election, if the first node determines the master node in this round of master node election, the first term of the first node is increased by 1.

[0020] Optionally, the substation automation system further comprises a master-slave information library, wherein the master-slave information library stores a master-slave type of each of the n nodes, and the master-slave type of the node is used to indicate whether the node is the master node or the slave node;

[0021] After the second node determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node, the method further includes:

[0022] If the second node determines that the other node is the master node, it determines itself as the slave node;

[0023] The second node updates the master-slave type of the second node in the master-slave information base to a slave node type.

[0024] Optionally, the first node sends an election message to each of the other n-1 nodes, including:

[0025] After the first node is started, determining that the first node is the slave node;

[0026] The first node stores the master-slave type of the first node as a slave node type in the master-slave information base;

[0027] If the first node determines that the master node does not exist among the n nodes according to the master-slave type of each of the n nodes in the master-slave information base, the first node sends the election message to each of the other n-1 nodes.

[0028] Optionally, the method further comprises:

[0029] The master node periodically sends a heartbeat message to each of the multiple slave nodes;

[0030] The first node sends an election message to each of the other n-1 nodes, including:

[0031] If the first node does not receive the heartbeat message sent by the master node within a preset time period, it sends the election message to each of the other n-1 nodes.

[0032] Optionally, the method further comprises:

[0033] The master node receives the target request sent by the external system;

[0034] The master node generates one or more target tasks according to the target request;

[0035] The master node distributes the one or more target tasks to the multiple slave nodes for execution.

[0036] Optionally, each of the n nodes includes one or more applications, and each application is deployed in a different container.

[0037] In a second aspect, a substation automation system is provided, the substation automation system comprising n nodes, wherein n is an integer greater than or equal to 3; the n nodes comprise a first node and a second node, the first node being a slave node that initiates an election among the n nodes, and the second node being any node among the n nodes except the first node;

[0038] The first node is used to: send an election message to each of the other n-1 nodes, the election message carrying the second term of the first node and the identifier of the first node; wherein the second term of the node that did not initiate the election in this round of master node election is the same as the first term, the second term of the node that initiated the election in this round of master node election is obtained by adding 1 to the first term, and the first term of the node is the number of master node election rounds in which the node participated;

[0039] The second node is used to: receive the election message sent by the first node, and determine the master node according to the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node;

[0040] The n nodes include a master node and multiple slave nodes, the master node is used to communicate with an external system, and the master node is used to instruct the multiple slave nodes to perform operations.

[0041] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the operations performed by the first node or the second node in the master node election method described in the first aspect.

[0042] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the operation performed by the first node or the second node in the master node election method described in the first aspect is implemented.

[0043] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the operations performed by the first node or the second node in the master node election method described in the first aspect above.

[0044] It can be understood that the beneficial effects of the second, third, fourth and fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0046] Figure 1 is a schematic diagram of a substation automation system provided by an embodiment of the present application;

[0047] Figure 2 is a schematic diagram of a node provided in an embodiment of the present application;

[0048] Figure 3 This is a flowchart of a master node election method provided by an embodiment of the present application;

[0049] Figure 4 This is an architectural diagram of a master node election method provided in an embodiment of the present application;

[0050] Figure 5 is a flowchart of another master node election method provided in an embodiment of the present application;

[0051] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0053] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.

[0054] The phrases such as "one embodiment" or "some embodiments" described in the present application mean that the specific features, structures or characteristics described in the embodiment are included in one or more embodiments of the present application. Therefore, the phrases such as "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments" that appear in the differences in the present application do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. In addition, the terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0055] The substation automation system provided in the embodiment of the present application is described below.

[0056] Figure 1 1 is a schematic diagram of a substation automation system 100 provided in an embodiment of the present application. Figure 1 The substation automation system 100 may include n nodes 101, any two of the n nodes 101 may communicate, and n is an integer greater than or equal to 3. The n nodes 101 may include one master node and multiple slave nodes.

[0057] The master node can communicate with an external system via a wired connection or a wireless connection. For example, the external system can be a supervisory control and data acquisition (SCADA) system, a telecontrol communication system, etc., which is not limited in the embodiments of the present application.

[0058] Each of the plurality of slave nodes may communicate with the master node via a wired connection or a wireless connection.

[0059] The substation automation system 100 is used to manage and control substation equipment in a power substation.

[0060] The master node may be a node 101 selected from the n nodes 101. The master node is used to receive a request sent by an external system and assign the task indicated by the request to the multiple slave nodes. Each of the multiple slave nodes is used to receive and execute the task assigned by the master node.

[0061] The multi-node architecture of the substation automation system 100 in the embodiment of the present application can flexibly adapt to the expansion of the scale and increase of functions of the substation automation system 10. By adjusting (i.e., increasing or decreasing) the number of nodes, the expansion and upgrade of the substation automation system 10 can be easily achieved.

[0062] Optionally, any one or more nodes 101 among the n nodes 101 may initiate a master node election process to run for the master node.

[0063] Optionally, the substation automation system 100 may further include a master-slave information library, which stores the master-slave type of each node 101 in the n nodes 101 , and the master-slave type of a node is used to indicate whether the node is a master node or a slave node.

[0064] By way of example, the master-slave information library may exist in one of the n nodes 101 , or the master-slave information library may exist in an independent device other than the n nodes 101 .

[0065] In the embodiment of the present application, the substation automation system 100 can interact with the external system through the master node and receive the request sent by the external system. After receiving the request, the master node can generate one or more tasks according to the request, and then assign the one or more tasks to the multiple slave nodes for execution. After the one or more tasks are executed, the master node returns a response message of the request to the external system, and the response message carries the execution result of the task corresponding to the request.

[0066] In some embodiments, after the substation automation system 100 is just constructed, the n nodes 101 therein may elect a master node by the following master node election method: Afterwards, the elected master node communicates with the external system and instructs multiple slave nodes to perform operations.

[0067] In some embodiments, during the operation of the substation automation system 100, if the master node fails, the multiple slave nodes can elect a new master node through the following master node election method, and the new master node continues to communicate with the external system and instructs the multiple slave nodes to perform operations to maintain the normal operation of the substation automation system 100.

[0068] The node 101 provided in the embodiment of the present application is described below.

[0069] Figure 2 1 is a schematic diagram of a node 101 provided in an embodiment of the present application. Figure 2 , the node 101 may include one or more applications.

[0070] The node 101 may be Figure 1 Any node 101 among the n nodes 101 in .

[0071] Each of the one or more applications is used to implement a specific function. For example, the one or more applications may include an application for performing master node election. For example, the one or more applications may include an application for performing tasks.

[0072] In this case, when the node 101 needs to execute a task, a corresponding application program can be selected from the one or more application programs to execute according to the task to be executed.

[0073] In some embodiments, different applications in the one or more applications may be deployed in different containers (such as Pods, etc.). For example, each application may be deployed in a container using the helm tool in k8s (kubernetes) technology.

[0074] In this case, the number of containers can be adjusted dynamically, so that the dynamic expansion and flexible adjustment of the containers in the node 101 can be realized, and then the virtualization of the hardware resources of the substation automation system 100 can be realized. In addition, since containers with the same function are deployed on different nodes 101, when a node 101 fails, the containers in other nodes 101 can continue to provide services to the external system without causing business interruption, which can improve service reliability.

[0075] Optionally, the Internet Protocol (IP) address and other network configurations of each of the n nodes 101 can be pre-set. For example, the Dynamic Host Configuration Protocol (DHCP) can be used to configure each of the n nodes 101. Of course, other methods can also be used for configuration, which is not limited in the embodiments of the present application.

[0076] In the embodiment of the present application, the n nodes 101 can be configured in the same configuration mode, thereby reducing the complexity and management cost of the substation automation system 100. In addition, DHCP can centrally manage the IP addresses and other network configurations of the n nodes 101, so when there is a need to modify the network configuration of the n nodes 101, the configuration of the n nodes 101 can be modified as a whole without manually modifying them one by one, thus improving the flexibility and applicability of the network configuration of the node 101.

[0077] The master node election method provided in the embodiment of the present application is explained in detail below.

[0078] Figure 3 This is a flowchart of a master node election method provided by an embodiment of the present application. The master node election method can be applied to Figure 1 Substation Automation System 100 in Figure 3 , the method comprises the following steps:

[0079] Step 301: The first node sends an election message to each of the other n-1 nodes, and the election message carries the second term of the first node and the identifier of the first node; wherein the second term of the node that did not initiate an election in this round of master node election is the same as the first term, and the second term of the node that initiated an election in this round of master node election is the first term plus 1.

[0080] The first node is a slave node that initiates an election among n nodes in the substation automation system. n is an integer greater than or equal to 3.

[0081] The election message sent by the first node is used to indicate that the first node wants to run for the master node.

[0082] The first term of a node is the number of master node election rounds in which the node participates.

[0083] The first term and the second term of a node have initial values. The initial values ​​of the first term and the second term can be preset. For example, the initial values ​​of the first term and the second term can be set to 0.

[0084] A node's ID is used to identify the node.

[0085] If a node (such as the first node) needs to run for the master node, that is, if the node determines that an election needs to be initiated, the second term of the node can be increased by 1, and then an election message can be sent to each of the other n-1 nodes to instruct the node to initiate an election.

[0086] In some embodiments, the first node sending the election message to each of the other n-1 nodes may be triggered by the following two methods:

[0087] The first method: after the first node is started, it is determined that the first node is a slave node, and the first node stores the master-slave type of the first node as a slave node type in the master-slave information library; if the first node determines that there is no master node among the n nodes according to the master-slave type of each node in the master-slave information library, it is determined that an election needs to be initiated. In this case, the second term of the first node is increased by 1, and then the election message is sent to each of the other n-1 nodes.

[0088] In some embodiments, after constructing the substation automation system, each of the n nodes can default to being a slave node after the first startup; or, after adding a node to the substation automation system, the newly added node can default to being a slave node after the first startup. Or, after a node fails and is repaired and becomes normal, the node can default to being a slave node after restarting.

[0089] If the first node determines from the master-slave information library that the master-slave type of each of the n nodes is a slave node type, it means that there is no master node in the current n nodes, which will affect the normal interaction between the substation automation system and the external system. In this case, the first node can initiate the master node election process, that is, increase its second term by 1, and then send the election message to each of the other n-1 nodes; if the first node determines from the master-slave information library that there is a node with a master node type among the n nodes, it means that there is already a master node among the current n nodes, so the master node election process is not initiated.

[0090] The second method: If the first node does not receive the heartbeat message sent by the master node within the preset time, it determines that an election needs to be initiated. In this case, the second term of the first node is increased by 1, and then the election message is sent to each of the other n-1 nodes.

[0091] The preset duration can be preset. For example, the preset duration can be set by a technician according to needs.

[0092] The heartbeat message is used to indicate whether the communication between the master node and the slave node is normal.

[0093] For example, the master node may periodically send a heartbeat message to each of the plurality of slave nodes, and the sending period of the heartbeat message may be preset.

[0094] If the first node receives the heartbeat message sent by the master node within the preset time, it means that the current communication between the master node and the first node is normal, and thus the first node does not need to initiate the master node election process; if the first node does not receive the heartbeat message sent by the master node within the preset time, it means that the master node may currently have a fault, which will affect the normal interaction between the substation automation system and the external system. Therefore, in this case, the first node can initiate the master node election process in order to elect a new master node to continue interacting with the external system.

[0095] In some embodiments, multiple slave nodes among the n nodes may also send heartbeat messages to each other. In this case, when a faulty node (master node or slave node) appears among the n nodes, the faulty node can be quickly detected by other nodes, and its work can be taken over by other nodes, thus ensuring high availability and continuous operation of the substation automation system.

[0096] Step 302: The second node receives the election message sent by the first node.

[0097] The second node is any node among the n nodes except the first node.

[0098] Step 303: The second node determines a master node according to the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node.

[0099] The size of a node's second term can reflect the stability of the node's operation to a certain extent. Specifically, the larger the second term of a node, the more master node election rounds the node participates in, that is, the longer the node runs, and the relatively higher the stability of the node's operation; the smaller the second term of a node, the fewer master node election rounds the node participates in, that is, the shorter the node runs, and the relatively lower the stability of the node's operation. The identifier of a node can reflect the order in which the node is introduced into the substation automation system. The larger the identifier of a node, the later the node is introduced; the smaller the identifier of a node, the earlier the node is introduced. In this case, the second node determines the master node based on the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node, that is, the second term of the first node and the second term of the second node, the identifier of the first node and the identifier of the second node are compared to determine whether the first node is suitable as the master node.

[0100] It should be noted that if the second node also initiates an election in this round of master node election process, then the second term of the second node is the first term of the second node plus 1; if the second node does not initiate an election in this round of master node election process, then the second term of the second node is the same as the first term of the second node.

[0101] In the embodiment of the present application, the n nodes include a master node and multiple slave nodes, the master node is used to communicate with the external system, and the master node is used to instruct multiple slave nodes to perform operations. In this case, each of the n nodes can participate in the operation of the substation automation system, thereby avoiding idle resources and improving system resource utilization. In addition, when the master node of the n nodes fails, multiple slave nodes can elect a new master node to continue to operate, thereby avoiding the situation in which two nodes in the master-standby dual-machine architecture in the related art fail and cause global failure. In this way, the operational stability of the substation automation system can be improved.

[0102] In some embodiments, the operation of step 303 may include the following steps (1) to (3):

[0103] Step (1): If the second term of the first node is greater than the second term of the second node, the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes; or, if the second term of the first node is the same as the second term of the second node, and the identifier of the first node is greater than the identifier of the second node, the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes.

[0104] The voting message sent by the second node and carrying the identifier of the first node is used to instruct the second node to vote for the first node, that is, the second node supports the first node as the master node.

[0105] When each of the n nodes is started for the first time, there is no master node among the n nodes. In this case, the first term and second term of the node that did not initiate the election among the n nodes are both initial values, and the second term of the node that initiated the election is obtained by adding 1 to the initial value.

[0106] In this case, if the second term of the first node is greater than the second term of the second node, it means that the second node has not yet initiated the master node election process, and the first node wants to be elected as the master node, so the second node can send a voting message carrying the identifier of the first node to each of the other n-1 nodes; if the second term of the first node is equal to the second term of the second node, it means that the second node has also initiated the master node election process, and now both the first node and the second node want to be elected as the master node. In this case, if the identifier of the first node is greater than the identifier of the second node, it means that the first node was introduced later than the second node, and the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes.

[0107] In the case that there is a master node among the n nodes but the master node is lost, if the second term of the first node is greater than the second term of the second node, it means that the first node runs more stably than the second node, so the second node agrees to elect the first node as the master node, that is, the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes.

[0108] If the second term of the first node is equal to the second term of the second node, it means that the operation stability of the first node and the second node is roughly the same. In this case, the identifier of the second node can be compared with the identifier of the first node to determine whether to vote for the first node based on the size of the identifier of the first node; if the identifier of the first node is greater than the identifier of the second node, it means that the first node was introduced later than the second node, so the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes; if the identifier of the first node is less than the identifier of the second node, it means that the first node was introduced earlier than the second node, so the second node does not elect the first node as the master node.

[0109] In some embodiments, if the second term of the first node is less than the second term of the second node, it means that the operating stability of the first node is lower than that of the second node, so the second node does not elect the first node as the master node. At this time, the second node can discard the election message sent by the first node.

[0110] In some embodiments, when the second term of the second node is the same as the second term of the first node and the identifier of the second node is greater than the identifier of the first node, the second node may discard the election message sent by the first device.

[0111] Step (2): The second node receives voting messages sent by other nodes.

[0112] It should be noted that, regardless of whether the second node sends a voting message to other nodes, the second node can receive voting messages sent by other nodes. The other nodes are other nodes among the n nodes except the second node. The node identifier carried in the voting message sent by the other node may be the identifier of the first node, or may be the identifier of other nodes initiating the election except the first node.

[0113] It should be noted that in one round of master node election, there may be one or more slave nodes initiating elections.

[0114] For example, Figure 4 As shown, it is assumed that the election application in node 1 sends election messages to node 2 and node 3 respectively. After node 2 and node 3 receive the election message, the election application in node 2 compares the second term of node 2 and the identifier of node 2 with the second term of node 1 and the identifier of node 1 respectively. If node 2 needs to vote for node 1, node 2 retains the vote for node 1 and sends voting messages for node 1 to node 1 and node 3 respectively; the election application in node 3 compares the second term of node 3 and the identifier of node 3 with the second term of node 1 and the identifier of node 1 respectively. If node 3 needs to vote for node 1, node 3 retains the vote for node 1 and sends voting messages for node 1 to node 1 and node 2 respectively; node 1 receives voting messages for node 1 sent by nodes 2 and 3, node 2 receives voting messages for node 1 sent by node 3, and node 3 receives voting messages for node 1 sent by node 2. In this way, nodes 1, 2, and 3 can all know the total number of votes for node 1.

[0115] Step (3): If the second node determines that the number of votes of the first node is greater than or equal to the preset number of votes based on the voting message sent by itself and the voting messages sent by other nodes, the first node is determined to be the master node.

[0116] The preset number of votes is the number of votes indicating that a node can be elected as a master node. The preset number of votes can be preset. For example, the preset number of votes can be greater than half of the total number of nodes, such as half of the total number of nodes plus 1.

[0117] If the number of votes of the first node is less than the preset number of votes, it means that most nodes do not support the first node to be elected as the master node, so the second node will not determine the first node as the master node; if the number of votes of the first node is greater than or equal to the preset number of votes, it means that most nodes support the first node to be elected as the master node, so the second node can determine the first node as the master node.

[0118] In some cases, if the first node determines that an election needs to be initiated, the second term of the first node may be increased by 1 before sending the election message in step 301 .

[0119] As an example, after the first node sends an election message to each of the other n-1 nodes, that is, after the first node initiates the election, if the first node receives a heartbeat message sent by the original master node when the current round of master node election has not yet ended and the master node has not yet been determined, it is determined that the current round of master node election is interrupted, the second term of the first node is set to be the same as the first term, and the election messages and voting messages received from other nodes are discarded.

[0120] If the first node receives a heartbeat message sent by the original master node when the current round of master node election has not yet ended and the master node has not yet been determined, it means that the communication between the master node and the first node has returned to normal. Therefore, the first node can interrupt the current round of master node election and continue to communicate with the master node.

[0121] As another example, after the first node initiates the election, if the first node determines the master node in this round of master node election, it can be determined that this round of master node election is over, and the first term of the first node is increased by 1.

[0122] Optionally, if the second node does not initiate an election in this round of master node election, then if the second node determines the master node in this round of master node election, it can be determined that the current round of master node election is over, the first term of the second node is increased by 1, and the second term of the second node is set to be the same as the first term of the second node. If the second node initiates an election in this round of master node election, then if the second node determines the master node in this round of master node election, it can be determined that the current round of master node election is over, and the first term of the second node is increased by 1.

[0123] Optionally, if the first node determines itself to be the master node, the master-slave type of the first node in the master-slave information library is updated to be the master node type.

[0124] Optionally, if the second node determines that the other node is a master node, it determines itself as a slave node; the second node updates the master-slave type of the second node in the master-slave information database to a slave node type.

[0125] In some embodiments, the master node may receive a target request sent by an external system, the master node generates one or more target tasks according to the target request, and the master node assigns the one or more target tasks to multiple slave nodes for execution.

[0126] For example, the master node can generate one or more target tasks according to its own load, the load of each slave node in the multiple slave nodes, and the target request. For example, the master node can generate and distribute target tasks through the task generator and task scheduler in k8s technology.

[0127] In this case, since the target task is generated with reference to the load of each node and is distributed to the multiple slave nodes, load balancing of the master node and the multiple slave nodes can be achieved, thereby improving the operational stability of the substation automation system.

[0128] Optionally, after the master node receives the target request sent by the external system, the application in the master node for processing the target request can read the master-slave type of each of the n nodes in the master-slave information library, and then generate a target task based on it and assign the target task to multiple slave nodes.

[0129] For example, Figure 4 As shown, assuming that node 3 is the master node, after node 3 receives the target request sent by the external system, application 2 in node 3 can process the target request, and application 2 can obtain the master-slave type of node 1 and node 2 from the master-slave information library through the election application in node 3, and then assign one or more target tasks corresponding to the target request to node 1 and node 2.

[0130] Optionally, after at least one of the multiple slave nodes receives and executes the target task assigned by the master node, the execution result of the target task can be returned to the master node. After the master node receives the execution result of the one or more target tasks, a response message of the target request can be returned to the external system, and the response message can carry the execution result of the one or more target tasks corresponding to the target request.

[0131] For ease of understanding, the following Figure 5 The above master node election method is exemplified.

[0132] Figure 5 is a flow chart of a master node election method provided by an embodiment of the present application. Figure 5 The method includes the following steps 501 to 512.

[0133] Step 501: A second node receives an election message sent by a first node, where the election message carries the second term of office of the first node and an identifier of the first node.

[0134] Step 502: The second node determines whether the second term of the first node is greater than the second term of the second node.

[0135] If the second term of the first node is greater than the second term of the second node, step 503 is executed; if the second term of the first node is not greater than the second term of the second node, step 504 is executed.

[0136] Step 503: The second node sends a voting message for the first node to other nodes, and saves the vote for the first node.

[0137] Step 504: The second node determines whether the second term of the first node is equal to the second term of the second node.

[0138] If the second term of the first node is equal to the second term of the second node, step 505 is executed; if the second term of the first node is less than the second term of the second node, step 507 is executed.

[0139] Step 505: The second node determines whether the identifier of the first node is greater than the identifier of the second node.

[0140] If the identifier of the first node is greater than the identifier of the second node, step 506 is executed; if the identifier of the first node is less than the identifier of the second node, step 507 is executed.

[0141] Step 506: The second node sends a voting message for the first node to other nodes, and saves the vote for the first node.

[0142] Step 507: The second node discards the election message sent by the first node.

[0143] Step 508: The second node receives voting messages sent by other nodes.

[0144] The voting message sent by other nodes may be a vote for any node, such as a vote for the first node or the second node or other nodes except the first node and the second node.

[0145] Step 509: The second node determines whether the number of votes of the third node is greater than or equal to a preset number of votes.

[0146] The third node may be any node, such as the first node or the second node or any node other than the first node and the second node.

[0147] If the number of votes of the third node is greater than or equal to the preset number of votes, step 510 is executed; if the number of votes of the third node is less than the preset number of votes, the process returns to step 501 to continue receiving election messages sent by other nodes.

[0148] Step 510: The second node determines whether the third node is the second node.

[0149] If the third node is the second node, execute step 511 ; if the third node is not the second node, execute step 512 .

[0150] Step 511: The second node updates the master-slave type of the second node in the master-slave information database to the master node type.

[0151] Step 512: The second node updates the master-slave type of the second node in the master-slave information database to a slave node type.

[0152] In an embodiment of the present application, the first node of the n nodes included in the substation automation system sends an election message to each of the other n-1 nodes, and the election message carries the second term of the first node and the identifier of the first node. After the second node of the n nodes receives the election message sent by the first node, it determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node and the identifier of the second node. In an embodiment of the present application, the n nodes include a master node and multiple slave nodes, the master node is used to communicate with an external system, and the master node is used to instruct multiple slave nodes to perform operations, so that each of the n nodes can participate in the operation of the substation automation system, thereby avoiding idle resources and improving system resource utilization. In addition, when the master node fails, multiple slave nodes can elect a new master node to continue to operate, thereby improving the operational stability of the substation automation system.

[0153] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 6 As shown, the computer device 6 includes: a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and executable on the processor 60. When the processor 60 executes the computer program 62, the steps executed by any node in the master node election method in the above embodiment are implemented.

[0154] The computer device 6 may be a general-purpose computer device or a dedicated computer device. In a specific implementation, the computer device 6 may be a desktop computer, a portable computer, a network server, a PDA, a mobile phone, a tablet computer, a wireless terminal device, a communication device or an embedded device. The embodiment of the present application does not limit the type of the computer device 6. Those skilled in the art will understand that Figure 6 It is only an example of the computer device 6 and does not constitute a limitation on the computer device 6. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, such as input and output devices, network access devices, etc.

[0155] The processor 60 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0156] In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 may also be an external storage device of the computer device 6, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the computer device 6. The memory 61 is used to store an operating system, an application program, a boot loader, data, and other programs. The memory 61 may also be used to temporarily store data that has been output or is to be output.

[0157] An embodiment of the present application also provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, and when the processor executes the computer program, the steps in any of the above-mentioned method embodiments are implemented.

[0158] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0159] An embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the steps in the above-mentioned method embodiments.

[0160] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above method embodiments, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above method embodiments can be implemented. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk and optical data storage device. The computer-readable storage medium mentioned in the present application can be a non-volatile storage medium, in other words, it can be a non-transient storage medium.

[0161] It should be understood that all or part of the steps to implement the above embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-mentioned computer readable storage medium.

[0162] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0163] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0164] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as 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 interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0165] 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.

[0166] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant regulations and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.

[0167] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A master node election method, characterized in that: Applied to a substation automation system, the substation automation system includes n nodes, where n is an integer greater than or equal to 3, and the method includes: The first node sends an election message to each of the other n-1 nodes, the election message carrying the second term of the first node and the identifier of the first node, the first node being the slave node that initiates the election among the n nodes; wherein the second term of the node that does not initiate the election in this round of master node election is the same as the first term, the second term of the node that initiates the election in this round of master node election is the first term plus 1, and the first term of the node is the number of master node election rounds in which the node participates; A second node receives the election message sent by the first node, and the second node is any one of the n nodes except the first node; the second node determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node and the identifier of the second node; wherein the n nodes include a master node and multiple slave nodes, the master node is used to communicate with an external system, and the master node is used to instruct the multiple slave nodes to perform operations.

2. The method according to claim 1, characterized in that The second node determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node, including: If the second term of the first node is greater than the second term of the second node, the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes; or, if the second term of the first node is the same as the second term of the second node, and the identifier of the first node is greater than the identifier of the second node, the second node sends a voting message carrying the identifier of the first node to each of the other n-1 nodes; The second node receives voting messages sent by other nodes; If the second node determines that the number of votes of the first node is greater than or equal to the preset number of votes based on the voting message sent by itself and the voting messages sent by other nodes, the first node is determined to be the master node.

3. The method according to claim 2, characterized in that The method further comprises: If the second term of the first node is smaller than the second term of the second node, the second node discards the election message.

4. The method according to claim 2, characterized in that The method further comprises: If the second term of the first node is the same as the second term of the second node, and the identifier of the first node is smaller than the identifier of the second node, the second node discards the election message.

5. The method according to claim 1, characterized in that The method further comprises: If the first node determines that an election needs to be initiated, the second term of the first node is increased by 1; After the first node initiates the election, if the first node determines the master node in this round of master node election, the first term of the first node is increased by 1.

6. The method according to claim 1, characterized in that The substation automation system further comprises a master-slave information library, wherein the master-slave type of each of the n nodes is stored in the master-slave information library, and the master-slave type of the node is used to indicate whether the node is the master node or the slave node; After the second node determines the master node according to the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node, the method further includes: If the second node determines that the other node is the master node, it determines itself as the slave node; The second node updates the master-slave type of the second node in the master-slave information base to a slave node type.

7. The method according to claim 6, characterized in that The first node sends an election message to each of the other n-1 nodes, including: After the first node is started, determining that the first node is the slave node; The first node stores the master-slave type of the first node as a slave node type in the master-slave information base; If the first node determines that the master node does not exist among the n nodes according to the master-slave type of each of the n nodes in the master-slave information base, the first node sends the election message to each of the other n-1 nodes.

8. The method according to claim 1, characterized in that The method further comprises: The master node periodically sends a heartbeat message to each of the multiple slave nodes; The first node sends an election message to each of the other n-1 nodes, including: If the first node does not receive the heartbeat message sent by the master node within a preset time period, it sends the election message to each of the other n-1 nodes.

9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: The master node receives the target request sent by the external system; The master node generates one or more target tasks according to the target request; The master node distributes the one or more target tasks to the multiple slave nodes for execution.

10. A substation automation system, characterized in that: The substation automation system includes n nodes, where n is an integer greater than or equal to 3; the n nodes include a first node and a second node, the first node is a slave node that initiates an election among the n nodes, and the second node is any node among the n nodes except the first node; The first node is used to: send an election message to each of the other n-1 nodes, the election message carrying the second term of the first node and the identifier of the first node; wherein the second term of the node that did not initiate the election in this round of master node election is the same as the first term, the second term of the node that initiated the election in this round of master node election is obtained by adding 1 to the first term, and the first term of the node is the number of master node election rounds in which the node participated; The second node is used to: receive the election message sent by the first node, and determine the master node according to the second term of the first node, the second term of the second node, the identifier of the first node, and the identifier of the second node; The n nodes include a master node and multiple slave nodes, the master node is used to communicate with an external system, and the master node is used to instruct the multiple slave nodes to perform operations.

Citation Information

Patent Citations

  • Election method and device for a main node in a cluster, equipment and a storage medium

    CN113965578A

  • Node competitive voting method and device based on consensus system

    CN114448769A

  • Multi-node network master node selection method and device, equipment and storage medium

    CN118200123A

  • Cluster election method and device, equipment and medium

    CN118200328A

  • Node election voting method and apparatus based on consensus system

    WO2023186085A1

Cited By

  • Method for managing main and standby states of node and node server

    CN120110888A