Distributed node election method based on priority and related device

By adopting the priority-based node election method in the DCS hosting computer, the duty nodes are automatically elected and the second-level switching is performed, the state maintenance problem caused by the uncertainty of the number of nodes is solved, and the system's response speed and stability are improved.

CN120491578APending Publication Date: 2025-08-15XIAN THERMAL POWER RES INST CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510627033.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The prior art is difficult to maintain the main and standby state of the application in DCS host computers, especially in the environment of uncertain number of nodes and dynamic changes, and traditional consistency algorithms are difficult to adapt.

Method used

A distributed node election method based on priority is adopted. By setting node priority, the duty node is automatically elected, the main and backup selection is realized, and the second-level switching is performed when the node fails.

Benefits of technology

It realizes the second-level control of node switching, ensuring the system responds quickly in the face of failures or changes, ensuring service continuity and stability, and improving system performance and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120491578A_ABST
    Figure CN120491578A_ABST
Patent Text Reader

Abstract

The invention discloses a priority-based distributed node election method and a related device, and belongs to the technical field of distributed control systems. By setting the priority of the nodes, the on-duty nodes can be automatically elected, and it is guaranteed that the on-duty nodes are available to maintain the application state when the unit runs; and the active-standby selection of the application is realized. In addition, the method has no requirement for the number of nodes, election and switching can be effectively carried out regardless of the number of the nodes, and normal operation of the system is ensured. By optimizing the election process and the switching mechanism, the second-level control of node switching is realized, and the switching time is greatly shortened. The rapid switching capability enables the system to make a response rapidly when facing node faults or changes, and ensures the continuity and stability of services, thereby improving the overall performance of the system and the user experience, and having wider application scenarios and stronger adaptability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of distributed control systems and relates to a priority-based distributed node election method and related devices. Background Art

[0002] As a core component of modern industrial automation, the efficient and stable operation of distributed control systems (DCSs) is crucial for ensuring the safety and efficiency of the entire production process. In a DCS architecture, the host computer, a key link in human-machine interaction and data processing, undertakes multiple tasks, including monitoring, executing control strategies, and recording data. To efficiently manage and coordinate various applications, the host computer typically adopts a distributed deployment model, meaning that multiple applications may be deployed on each host computer node. This deployment approach improves system flexibility and scalability, but also introduces challenges in information synchronization and state consistency.

[0003] In the distributed environment of a DCS host computer, information synchronization and state consistency between each node and its applications are fundamental to ensuring the correct operation of the system. Because applications may run on different physical or logical nodes, they need to share critical data and update status information in real time to quickly respond to operational instructions or system changes. To achieve this, each application requires one or more on-duty nodes responsible for maintaining the application's global state and ensuring data freshness and accuracy. The on-duty node not only processes information update requests from other nodes but also initiates state synchronization operations when necessary to ensure that all nodes have a consistent understanding of the application's state.

[0004] However, the number of DCS host computer nodes and the number of nodes deployed for applications are often uncertain. This dynamic nature complicates system design and maintenance. Traditional distributed consensus algorithms, such as Paxos and Raft, while effective in addressing consistency issues in distributed systems, typically require prior knowledge of the number of participants or a relatively fixed cluster structure. In a DCS environment, the flexibility of node and application deployment limits the direct application of these algorithms, making them difficult to adapt to rapidly changing environmental demands. Therefore, a stable distributed election algorithm is required to maintain the active and standby status of applications during normal operation, ensuring that there are active nodes on duty to maintain application status. Summary of the Invention

[0005] The purpose of the present invention is to provide a priority-based distributed node election method and related devices to solve the technical problem that the existing technology is difficult to stably maintain the active and standby states of applications.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions: In a first aspect, the present invention provides a priority-based distributed node election method, comprising the following steps: When any application of a node is started, a request message is sent to all other nodes configured with the application; When other nodes receive the request message, they determine whether the current application status is on duty. If it is on duty, they send a response message to the node that sent the request message; If the node that sent the request message receives a response message, it synchronizes the database and starts the application based on the application type of the node. If the node that sent the request message does not receive a response message, it determines whether the node is a maintenance node. If so, it sets the node as the duty node and broadcasts the active / standby switchover message to all nodes. If it is not a maintenance node, the application cannot be started. When the on-duty node stops its application, it broadcasts the application stop message to other nodes. After receiving the application stop message, other nodes determine that the current node is the on-duty node. If the application of this node is configured as a backup on-duty node, it broadcasts an election message to other nodes to elect a new on-duty node. After receiving the broadcast election message, other nodes set or switch the duty node.

[0007] Furthermore, it also includes: When the on-duty node fails, the standby on-duty node sets the on-duty node status to faulty and sends an election message to other nodes; After receiving the election message, other nodes set or switch the duty node.

[0008] Furthermore, the sign of the duty node failure is that all other nodes do not receive the heartbeat message of the duty node for 5 consecutive cycles.

[0009] Furthermore, after receiving the election message, the other nodes perform the steps of setting or switching the duty node, specifically including: When other nodes receive the election message, they determine the type of their own node; If the node itself is not on duty, the on-duty node is set as the node that sends the election message; If the node itself is the on-duty node, a priority judgment is performed. When the priority of the node sending the election message is greater than or equal to that of the node itself, the node sending the election message is the on-duty node. If the priority of the node itself is high, the request message is resent to perform the on-duty node switching operation.

[0010] Furthermore, if the node that sent the request message receives a response message, the steps of synchronizing the database and starting the application are performed according to the application type of the node, specifically including: If the node that sent the request message receives a response message, it determines the type of its own node application; If it is an off-duty node, it will request the requested on-duty node to synchronize the configuration database and then start the application; If it is a duty node, the priority of the current duty node and the priority of this node are determined. If the priority of this node is lower, a request is made to the current duty node to synchronize the database and then start the application. If the priority of this node is higher, a request is made to the current duty node to synchronize the database and then start the application, and a message is broadcast to all nodes to perform a master-slave switch, switching the duty node to the current node.

[0011] Furthermore, if the node that sent the request message receives a response message, the step of synchronizing the database and starting the application according to the application type of the node further includes: When a response message is received, the timestamp in the message is checked. If the timestamp in the message differs from the local time by more than 1 second, the request is considered invalid and will not be processed.

[0012] Furthermore, after receiving the broadcast election message, the other nodes perform the steps of setting or switching the duty node, specifically including: After receiving the broadcast election message, other nodes determine the type of their own nodes; If the node itself is not on duty, the on-duty node is set as the node that broadcasts the election message; If the node itself is the on-duty node, a priority judgment is performed. When the priority of the node broadcasting the election message is greater than or equal to that of the node itself, the node broadcasting the election message is the on-duty node. If the priority of the node itself is high, the request message is resent to perform the on-duty node switching operation.

[0013] In a second aspect, the present invention provides a priority-based distributed node election system, comprising: A request sending module, configured to send a request message to all other nodes configured with the application when any application of the node is started; The request response module is used to determine whether the current application status is on duty when other nodes receive the request message. If it is on duty, it sends a response message to the node that sent the request message; The application startup module is used to synchronize the database and start the application according to the application type of the node if the node that sent the request message receives a response message. If the node that sent the request message does not receive a response message, it determines whether the node is a maintenance node. If so, it sets the node as the duty node and broadcasts the active / standby switch message to all nodes. If it is not a maintenance node, the application cannot be started. The application stop module is used to broadcast the application stop message to other nodes when the on-duty node stops the application. After receiving the application stop message, other nodes determine that the current node is the on-duty node. If the application of this node is configured as a backup on-duty node, they broadcast an election message to other nodes to elect the on-duty node. The node setting module is used for other nodes to set or switch the on-duty node after receiving the broadcast election message.

[0014] In a third aspect, the present invention provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0015] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0016] Compared with the prior art, the present invention has the following beneficial effects: The present invention discloses a priority-based distributed node election method and related devices. By setting the priority of the node, the on-duty node can be automatically elected to ensure that there is an on-duty node to maintain the application status when the unit is running, and the master-slave selection of the application is realized. In addition, the present invention has no requirements for the number of nodes. Regardless of the number of nodes, it can effectively carry out elections and switches to ensure the normal operation of the system. By optimizing the election process and switching mechanism, the present invention realizes second-level control of node switching, greatly shortening the switching time. This fast switching capability enables the system to respond quickly when facing node failures or changes, ensuring the continuity and stability of the service, thereby improving the overall performance of the system and user experience, and has a wider range of application scenarios and stronger adaptability. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0018] Figure 1 is a flow chart of the method of the present invention; Figure 2 is a schematic diagram of the system of the present invention; Figure 3 It is a schematic diagram of the computer device structure of the present invention. DETAILED DESCRIPTION

[0019] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that, unless there is a conflict, the embodiments and features in the embodiments of the present application can be combined with each other.

[0020] The following detailed description is an exemplary description, which is intended to provide further detailed description of the present invention. Unless otherwise indicated, all technical terms used in the present invention have the same meaning as those generally understood by those skilled in the art. The terms used in the present invention are only for describing specific embodiments, and are not intended to limit the exemplary embodiments according to the present invention.

[0021] See also Figure 1 The present invention discloses a priority-based distributed node election method. All applications on the host computer maintain a node application table, which contains the configuration of each application on each node, including whether the application is configured, whether it is a candidate on-duty node, and the application priority. The heartbeat cycle interval between nodes is configurable, which can control the speed of node application switching. The specific method steps are as follows: Start the application: 1) When any application of a node is started, a broadcast request message is sent to all other host nodes configured with the application, requesting the current on-duty node information. The specific code is as follows:

[0022] 2) When other nodes receive the request message, they determine whether the current application status is on duty. If it is on duty, they send a response message to the node. The specific code is as follows:

[0023] 3) The node that sent the request message receives the response message and determines the type of application of the node and whether it is configured as a standby duty node.

[0024] If it is an off-duty node, it will request the requested on-duty node to synchronize the configuration database and then start the application; If it is a duty node, the priority of the current duty node and the priority of this node are determined. If the priority of this node is lower, a request is made to the current duty node to synchronize the database and then start the application. If the priority of this node is higher, a request is made to the current duty node to synchronize the database and then start the application, and a message is broadcast to all nodes to perform a master-slave switch, switching the duty node to the current node.

[0025] When a response message is received, the timestamp in the message needs to be verified. Industrial control systems have a strong requirement for the consistency of the host computer time. If the timestamp in the message differs from the local time by more than 1 second, it is considered an invalid request and will not be processed.

[0026] 4) If the node that sent the request message does not receive a response message, it means that there is currently no on-duty node for the application. The node is determined to be a maintenance node. If so, the node is set as the on-duty node and the active / standby switch message is broadcast to all nodes. If it is not a maintenance node, the application cannot be started. The specific code is as follows:

[0027] Stop the application: 1) When the on-duty node stops the application, it broadcasts the application stop message to other nodes; 2) After receiving the application stop message, other nodes determine that the current node is the duty node. If the application configuration of this node is a backup duty node, it broadcasts an election message to other nodes to elect a duty node.

[0028] 3) After receiving the broadcast election message, other nodes determine the type of their own nodes; If the node itself is not on duty, the on-duty node is set as the node that broadcasts the election message; If the node itself is the on-duty node, a priority judgment is performed. When the priority of the node broadcasting the election message is greater than or equal to that of the node itself, the node broadcasting the election message is the on-duty node. If the priority of the node itself is high, the request message is resent to perform the on-duty node switching operation.

[0029] On-duty node failure: The on-duty node needs to maintain periodic heartbeat information with all nodes during operation. When the on-duty node fails, the other nodes perform the following processing.

[0030] 1) If the standby node fails to receive a heartbeat message from the on-duty node for five consecutive cycles, it will set the on-duty node status to faulty and send an election message to other nodes. The specific code is as follows:

[0031] 2) After other nodes receive the election message; If the node itself is an off-duty node, the on-duty node is set as the node that sends the election message.

[0032] If the node itself is the on-duty node, a priority judgment is performed. When the priority of the node sending the election message is greater than or equal to that of the node itself, the node sending the election message is the on-duty node. If the priority of the node itself is high, the request message is resent to perform the on-duty node switching operation.

[0033] See also Figure 2 The embodiment of the present invention discloses a priority-based distributed node election system, which includes a request sending module, a request response module, an application starting module, an application stopping module and a node setting module.

[0034] Among them, the request sending module is used to send a request message to all other nodes configured with the application when any application of the node is started; the request response module is used to determine whether the status of the current application is on duty after other nodes receive the request message. If it is on duty, a response message is sent to the node that sent the request message; the application startup module is used to synchronize the database and start the application according to the application type of the node if the node that sent the request message receives a response message; if the node that sent the request message does not receive a response message, it is used to determine whether the node is a maintenance node. If so, the node is set as a duty node and the master-slave switching message is broadcast to all nodes. If it is not a maintenance node, the application cannot be started; the application stop module is used to broadcast an application stop message to other nodes after the on-duty node stops the application; after other nodes receive the application stop message and determine that the current node is a duty node, if the application of this node is configured as an alternative duty node, an election message is broadcast to other nodes to elect a duty node; the node setting module is used to set or switch the duty node after other nodes receive the broadcast election message.

[0035] In one embodiment of the present invention, a computer device is provided. Figure 3 The computer device includes a processor and a memory, wherein the memory is used to store a computer program, wherein the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or may be 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. It is the computing core and control core of the terminal, and is suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions in a computer storage medium to implement a corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used for the operation of a priority-based distributed node election method.

[0036] The present invention also provides a storage medium, specifically a computer-readable storage medium (Memory). The computer-readable storage medium is a memory device in a computer device, used to store programs and data. It is understood that the computer-readable storage medium herein may include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the terminal's operating system. Furthermore, the storage space also stores one or more instructions suitable for being loaded and executed by a processor. These instructions may be one or more computer programs (including program code). It should be noted that the computer-readable storage medium herein may be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage device. The processor may load and execute the one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the priority-based distributed node election method in the above-mentioned embodiment.

[0037] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0038] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0039] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1The function specified in one or more boxes.

[0040] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0041] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered by the scope of protection of the claims of the present invention.

Claims

1. A priority-based distributed node election method, characterized in that: The following steps are involved: When any application of a node is started, a request message is sent to all other nodes configured with the application; When other nodes receive the request message, they determine whether the current application status is on duty. If it is on duty, they send a response message to the node that sent the request message; If the node that sent the request message receives a response message, it synchronizes the database and starts the application based on the application type of the node. If the node that sent the request message does not receive a response message, it determines whether the node is a maintenance node. If so, it sets the node as the duty node and broadcasts the active / standby switchover message to all nodes. If it is not a maintenance node, the application cannot be started. When the on-duty node stops its application, it broadcasts the application stop message to other nodes. After receiving the application stop message, other nodes determine that the current node is the on-duty node. If the application of this node is configured as a backup on-duty node, it broadcasts an election message to other nodes to elect a new on-duty node. After receiving the broadcast election message, other nodes set or switch the duty node.

2. A priority-based distributed node election method according to claim 1, characterized in that: Also includes: When the on-duty node fails, the standby on-duty node sets the on-duty node status to faulty and sends an election message to other nodes; After receiving the election message, other nodes set or switch the duty node.

3. A priority-based distributed node election method according to claim 2, characterized in that: The sign of the on-duty node failure is that all other nodes do not receive the heartbeat message of the on-duty node for 5 consecutive cycles.

4. A priority-based distributed node election method according to claim 2, characterized in that: After receiving the election message, the other nodes perform steps of setting or switching the duty node, specifically including: When other nodes receive the election message, they determine the type of their own node; If the node itself is not on duty, the on-duty node is set as the node that sends the election message; If the node itself is the on-duty node, a priority judgment is performed. When the priority of the node sending the election message is greater than or equal to that of the node itself, the node sending the election message is the on-duty node. If the priority of the node itself is high, the request message is resent to perform the on-duty node switching operation.

5. A priority-based distributed node election method according to claim 1, characterized in that: If the node that sent the request message receives a response message, the steps of synchronizing the database and starting the application are performed according to the application type of the node, specifically including: If the node that sent the request message receives a response message, it determines the type of its own node application; If it is an off-duty node, it will request the requested on-duty node to synchronize the configuration database and then start the application; If it is a duty node, the priority of the current duty node and the priority of this node are determined. If the priority of this node is lower, a request is made to the current duty node to synchronize the database and then start the application. If the priority of this node is higher, a request is made to the current duty node to synchronize the database and then start the application, and a message is broadcast to all nodes to perform a master-slave switch, switching the duty node to the current node.

6. A priority-based distributed node election method according to claim 5, characterized in that: If the node that sent the request message receives a response message, the step of synchronizing the database and starting the application according to the application type of the node further includes: When a response message is received, the timestamp in the message is checked. If the timestamp in the message differs from the local time by more than 1 second, the request is considered invalid and will not be processed.

7. A priority-based distributed node election method according to claim 1, characterized in that: After receiving the broadcast election message, the other nodes perform steps of setting or switching the duty node, specifically including: After receiving the broadcast election message, other nodes determine the type of their own nodes; If the node itself is not on duty, the on-duty node is set as the node that broadcasts the election message; If the node itself is the on-duty node, a priority judgment is performed. When the priority of the node broadcasting the election message is greater than or equal to that of the node itself, the node broadcasting the election message is the on-duty node. If the priority of the node itself is high, the request message is resent to perform the on-duty node switching operation.

8. A priority-based distributed node election system, characterized in that: include: A request sending module, configured to send a request message to all other nodes configured with the application when any application of the node is started; The request response module is used to determine whether the current application status is on duty when other nodes receive the request message. If it is on duty, it sends a response message to the node that sent the request message; The application startup module is used to synchronize the database and start the application according to the application type of the node if the node that sent the request message receives a response message. If the node that sent the request message does not receive a response message, it determines whether the node is a maintenance node. If so, it sets the node as the duty node and broadcasts the active / standby switch message to all nodes. If it is not a maintenance node, the application cannot be started. The application stop module is used to broadcast the application stop message to other nodes when the on-duty node stops the application. After receiving the application stop message, other nodes determine that the current node is the on-duty node. If the application of this node is configured as a backup on-duty node, they broadcast an election message to other nodes to elect the on-duty node. The node setting module is used for other nodes to set or switch the on-duty node after receiving the broadcast election message.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.