A method and device for selecting a leader in a lightweight distributed decentralized system

By configuring multiple hardware nodes as scheduling nodes in the distributed computing system and adopting a self-recommended master selection method, the single point of failure problem is solved, and the long-term and stable operation of the system is achieved.

CN115987758BActive Publication Date: 2025-04-11NO 8511 RES INST OF CASIC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211651702.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-22
Publication Date
2025-04-11
Estimated Expiration
2042-12-22

AI Technical Summary

Technical Problem

There is a single point of failure problem in the existing distributed computing system. After the dispatching node goes down, the entire system is paralyzed and cannot operate normally.

Method used

By running the node management module on each hardware node, the configuration file configures the role of the hardware node, and multiple hardware nodes are configured as scheduling nodes at the same time. The scheduling node has three states: leader, follower, and candidate. The self-recommended master selection method is adopted. Whoever signs up first wins first, determines the activity scheduling node.

Benefits of technology

The automatic master selection function is realized, which avoids single point of failure, ensures that the system can still run normally when the dispatching node is down, and the system can run stably for a long time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115987758B_ABST
    Figure CN115987758B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for selecting a master of a lightweight distributed decentralized system. A node management module is run on each hardware node of the distributed system, and the role of the hardware node is configured through a configuration file; multiple hardware nodes are configured as scheduling nodes at the same time, and the scheduling nodes have three states: leader, follower, and candidate; the scheduling node is in the candidate state by default, and the active scheduling node is determined by the master selection method. The principle of selecting the master is the self-recommendation system, and whoever registers first wins first; the leader is used to send a scheduling heartbeat, which is a heartbeat data packet broadcasted periodically to maintain the leader state; the follower is used to receive the scheduling heartbeat; the candidate is used to activate the self-recommendation process, and the candidate has the opportunity to become a leader. The present invention does not rely on any open source components, is autonomous and controllable, and the normal operation of a scheduling node in the system can meet the system operation requirements, so that the system can operate stably for a long time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of distributed computing technology, and in particular to a method and device for selecting a leader in a lightweight distributed decentralized system. Background Art

[0002] The existing general distributed intelligent processing and analysis platform for electromagnetic signals (such as patent CN113157252A) can realize the function of distributed computing in a distributed computing cluster. The distributed intelligent processing and analysis platform consists of a scheduling node, several conventional computing nodes, several advanced computing nodes, several data access nodes, etc. A node management module is deployed on each node to monitor the hardware status, software running status, start and close software modules and other functions; the scheduling node deploys the scheduling module, which is the center of the system and is responsible for scheduling and resource coordination, and the computing node is used to adapt to parallel processing tasks. The UI front-end module receives the user's task instructions and sends them to the back-end service module through the communication protocol. After the node management module successfully monitors and allocates resources, the task-related modules (data access module, preprocessing calculation module, deep learning calculation module) start the task; each module interacts with the data management module to realize data storage and management, and the result feedback is completed through the communication protocol after the task is completed; the back-end service module is responsible for task scheduling, the node management module is responsible for resource recovery, and the UI front-end module is responsible for result display.

[0003] The software framework of the above platform includes an Nginx front-end module, a scheduling module, an agent assistant software module, a data management module, several data access modules, several conventional computing software modules, and several advanced computing software modules; it can run on one computer or on multiple computers according to roles, such as: the data access software module runs on the acquisition server, and there are two types of computing nodes: conventional computing software modules run on conventional computing nodes, and advanced computing software modules run on advanced computing nodes.

[0004] In the scenario of distributed computing and multi-tasking concurrency, multiple clients will send task applications to the scheduling software "simultaneously", and each user may apply for multiple tasks; at the same time, each task will have parallel computing processes, and even distributed on different computing nodes. The essence of this problem is that the scheduling module must be able to accept multiple task applications, and be able to reasonably allocate tasks to corresponding computing resources based on the current computing resource status (including conventional computing software modules and advanced computing software modules), and monitor and manage the operation of resources.

[0005] Although the platform in patent CN113157252A can rely on the node management module on the scheduling node to monitor the status of the scheduling module, and automatically start it up when the scheduling module is abnormally shut down; there is still a single point failure problem, that is, when the scheduling server goes down, the entire system is paralyzed and cannot operate normally. Summary of the invention

[0006] The purpose of the present invention is to provide a method and device for selecting a master in a lightweight distributed decentralized system to solve the single point failure problem, avoid the downtime of the scheduling node affecting the normal operation of the entire system, and enable the system to operate stably for a long time.

[0007] The technical solution to achieve the purpose of the present invention is: a method for selecting a leader in a lightweight distributed decentralized system, comprising:

[0008] A node management module runs on each hardware node of the distributed system, and the role of the hardware node is configured through the configuration file;

[0009] Configure multiple hardware nodes as scheduling nodes at the same time. Scheduling nodes have three states: leader, follower, and candidate.

[0010] The scheduling node is in the candidate state by default. The active scheduling node is determined by the master election method. The principle of master election is self-recommendation. Whoever registers first wins.

[0011] A master selection device for a lightweight distributed decentralized system includes multiple node management modules, each of which is provided with a configuration file, wherein:

[0012] Each node management module is set on each hardware node of the distributed system one by one, and the configuration file is used to configure the role of the hardware node;

[0013] The configuration file configures multiple hardware nodes as scheduling nodes at the same time. The scheduling nodes have three states: leader, follower, and candidate. The scheduling nodes are provided with a candidate state transition unit, a follower state transition unit, and a leader state transition unit.

[0014] The scheduling node is in the candidate state by default. The active scheduling node is determined by the master election method. The principle of master election is self-recommendation. Whoever registers first wins.

[0015] Compared with the prior art, the present invention has the following significant advantages: (1) relying on the node management module running on the node and the scheduling module on the scheduling node, the automatic master selection function is realized, thereby solving the single point failure problem, avoiding the downtime of the scheduling node affecting the normal operation of the entire system, and enabling the system to operate stably for a long time; (2) it does not rely on any open source components, is autonomous and controllable, and can run on a variety of operating systems; (3) the system operation requirements can be met if one scheduling node in the system is operating normally, and there is no requirement for more than half of the nodes to operate normally. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a system hardware composition diagram in the background technology of the present invention.

[0017] Figure 2 It is a system software architecture diagram in the background technology of the present invention.

[0018] Figure 3 It is a scheduling node state switching diagram of a lightweight distributed decentralized system.

[0019] Figure 4 It is the candidate state transition flow chart.

[0020] Figure 5 It is the follower state transition flowchart.

[0021] Figure 6 It is the leader state transition flowchart. DETAILED DESCRIPTION

[0022] The hardware components of the lightweight distributed multi-task resource management and task scheduler described in the present invention are shown in FIG. Figure 1 As shown in the figure, the distributed computing software framework structure is as follows Figure 2 shown.

[0023] The master selection method of the lightweight distributed decentralized system of the present invention relies on the node management module running on the node and the scheduling module on the scheduling node. The scheduling module is the main running process of the program, and the node management module runs on each node.

[0024] The implementation principle of registration discovery: a node management module runs on each hardware node. The role of the hardware node is configured through the configuration file. Multiple hardware nodes can be configured as scheduling nodes.

[0025] As a scheduling node, there are three states: leader, follower, and candidate:

[0026] The leader is used to send scheduling heartbeats, which are heartbeat packets broadcast periodically to maintain the leader status;

[0027] Follower, used to receive scheduling heartbeats;

[0028] Candidates, used to activate the self-recommendation process, candidates have the opportunity to become leaders.

[0029] The scheduling node is in the candidate state by default. The active scheduling node is determined by the master election method. The principle of master election is self-recommendation. Whoever registers first wins.

[0030] Minimum system resources: refers to the minimum set of nodes required for the system to run; the criteria for meeting the minimum resources are as follows: the minimum set of nodes refers to at least one scheduling node, conventional computing node, advanced computing node, and data access node, and all nodes that meet the minimum system requirements can ping each other, that is, the network is reachable.

[0031] The entire system is divided into three roles: candidate, follower, and leader. Figure 3 shown.

[0032] When the system starts, all scheduling nodes are candidates by default;

[0033] Candidates can switch to follower or leader according to conditions, and can also remain in candidate state;

[0034] Followers can further develop into leaders, or they can degenerate into candidates;

[0035] The leader degenerates into a follower or candidate depending on the conditions.

[0036] The specific state transition process of each role is as follows Figure 4 , Figure 5 , Figure 6 shown.

[0037] Combination Figure 4 , the candidate state transition process is as follows:

[0038] (1.1) Activate the self-recommendation timer;

[0039] (1.2) Before the self-recommendation timer expires T1:

[0040] ① If the scheduling heartbeat information sent by other nodes is received in the scheduling heartbeat channel, the information contains the scheduled IP port number and the term number increment. Compare whether the term number is greater than the local one. The local one refers to the term number stored in this node:

[0041] If yes, then turn off the self-recommendation timer, establish a connection with the scheduling node, and convert to a follower;

[0042] If not, determine whether the self-recommendation timer has timed out by T1 time. If not, return to step (1.2). If so, proceed to step (1.3).

[0043] ② If you receive self-recommendation information from other nodes, compare whether the term number is greater than the local one:

[0044] If so, determine whether the scheduling heartbeat of the node is received within the timeout T2. The node refers to the current node described relative to other nodes. If received, turn off the timer, establish a connection with the scheduling node, and convert to a follower. If not received, determine whether the self-recommendation timer has timed out by T1. If not, return to step (1.2). If T1 has timed out, go to step (1.3). T1>T2, and the values ​​of T1 and T2 are adjusted according to system requirements.

[0045] If not, then turn off the self-recommendation timer, send a self-recommendation message, and become a leader;

[0046] ③ If no scheduling heartbeat information is received from other nodes in the scheduling heartbeat channel, and no self-recommendation information is received from other nodes, then go to step (1.3);

[0047] (1.3) After the self-recommendation timer times out T1: turn off the self-recommendation timer, send a self-recommendation message, and become the leader.

[0048] Combination Figure 5 , the follower state transition process is as follows:

[0049] (2.1) The node management module of this node starts the status timer and the monitoring timer;

[0050] (2.2) Determine whether the node management module of this node receives the scheduling heartbeat within the timeout T4:

[0051] If yes, go to step (2.3);

[0052] If not, turn off the state timer and the listening timer, turn into a candidate, and end the conversion process;

[0053] (2.3) The node management module resets the monitoring timer and compares the scheduling term number with the local one:

[0054] If the scheduling term number is larger than the local one, the scheduling module is redirected according to the scheduling heartbeat, a connection is established with the new scheduling module, and step (2.4) is entered;

[0055] If the scheduling term number is smaller than the local one, the state timer and the monitoring timer are turned off, the node becomes a candidate, and the conversion process ends;

[0056] If the scheduling term number is the same as the local one, go to step (2.4);

[0057] (2.4) Determine whether the status timer has timed out:

[0058] If not, re-enter step (2.4);

[0059] If yes, the node management module resets the status timer, obtains the status of the node, and sends the status information of the node to the scheduling module.

[0060] Combination Figure 6 , the leader state transition process is as follows:

[0061] (3.1) When receiving the self-recommendation information of this node, this node becomes the leader, and the scheduling module immediately sends a scheduling heartbeat;

[0062] (3.2) The scheduling module starts the heartbeat timer;

[0063] (3.3) Determine whether the heartbeat timer reaches the timing time T5, T5<T2, and the value of T5 is adjusted according to system requirements:

[0064] If the timing time T5 is reached, determine whether the minimum system resources are met. If so, reset the heartbeat timer, send the scheduling heartbeat, and return to step (3.3) to wait for the next timing time to arrive; if not, turn off the heartbeat timer and become a candidate, and the state transition process ends;

[0065] If the timing time T5 is not reached, then:

[0066] ① Determine whether the heartbeat of other node scheduling is received:

[0067] If the node receives a scheduling heartbeat from another node, and the term number in the scheduling heartbeat is greater than the local term number, the scheduling module of this node turns off the heartbeat timer and becomes a follower, and the state transition process ends;

[0068] Otherwise, re-execute step (3.3);

[0069] ② Determine whether to receive self-recommendation information from other nodes:

[0070] If a node receives a self-recommendation message from another node, and the term number in the self-recommendation message is greater than the local one, the node scheduling module turns off the heartbeat timer and becomes a follower, and the state transition process ends;

[0071] Otherwise, repeat step (3.3).

[0072] The present invention also provides a master selection device for a lightweight distributed decentralized system, comprising a plurality of node management modules, each of which is provided with a configuration file, wherein:

[0073] Each node management module is set on each hardware node of the distributed system one by one, and the configuration file is used to configure the role of the hardware node;

[0074] The configuration file configures multiple hardware nodes as scheduling nodes at the same time. The scheduling nodes have three states: leader, follower, and candidate. The scheduling nodes are provided with a candidate state transition unit, a follower state transition unit, and a leader state transition unit.

[0075] The scheduling node is in the candidate state by default. The active scheduling node is determined by the master election method. The principle of master election is self-recommendation. Whoever registers first wins.

[0076] In a specific implementation, the candidate state transition unit, the follower state transition unit, and the leader state transition unit are specifically as follows:

[0077] First, the candidate state conversion unit includes:

[0078] A timer activation subunit, used for activating a self-recommendation timer;

[0079] Subunit before the self-recommendation timer times out T1 time: used to perform the following processing before the self-recommendation timer times out T1 time:

[0080] ① If the scheduling heartbeat information sent by other nodes is received in the scheduling heartbeat channel, the information contains the scheduled IP port number and the term number increment. Compare whether the term number is greater than the local one. The local one refers to the term number stored in this node:

[0081] If yes, then turn off the self-recommendation timer, establish a connection with the scheduling node, and convert to a follower;

[0082] If not, determine whether the self-recommendation timer has timed out by T1 time, if not, return to the sub-unit before the self-recommendation timer timed out by T1 time, if it has timed out by T1 time, enter the sub-unit after the self-recommendation timer timed out by T1 time;

[0083] ② If you receive self-recommendation information from other nodes, compare whether the term number is greater than the local one:

[0084] If so, determine whether the scheduling heartbeat of the node is received within the timeout T2. The node refers to the current node described relative to other nodes. If received, turn off the timer, establish a connection with the scheduling node, and convert to a follower. If not received, determine whether the self-recommendation timer has timed out by T1. If not, return to the sub-unit before the self-recommendation timer timeout T1. If it has timed out by T1, enter the sub-unit after the self-recommendation timer timeout T1. T1>T2, and the values ​​of T1 and T2 are adjusted according to system requirements.

[0085] If not, then turn off the self-recommendation timer, send a self-recommendation message, and become a leader;

[0086] ③ If the scheduling heartbeat information sent by other nodes is not received in the scheduling heartbeat channel, and no self-recommendation information from other nodes is received, the sub-unit after the self-recommendation timer times out T1 time is entered;

[0087] The subunit after the self-recommendation timer times out for T1 time is used to perform the following processing after the self-recommendation timer times out for T1 time:

[0088] Turn off the self-recommendation timer, send a self-recommendation message, and become a leader.

[0089] Second, the follower state conversion unit includes:

[0090] The state timer and monitoring timer subunit are used to start the state timer and the monitoring timer;

[0091] The first judgment subunit is used to judge whether the node management module of the node receives the scheduling heartbeat within the timeout T4:

[0092] If yes, then enter the comparison subunit;

[0093] If not, turn off the state timer and the listening timer, turn into a candidate, and end the conversion process;

[0094] The comparison subunit is used to reset the monitoring timer and compare the scheduling term number with the local one:

[0095] If the scheduling term number is larger than the local one, the scheduling module is redirected according to the scheduling heartbeat, a connection is established with the new scheduling module, and the second judgment subunit is entered;

[0096] If the scheduling term number is smaller than the local one, the state timer and the monitoring timer are turned off, the node becomes a candidate, and the conversion process ends;

[0097] If the scheduling term number is the same as the local one, then enter the second judgment subunit;

[0098] The second judgment subunit is used to judge whether the status timer has timed out:

[0099] If not, re-enter the second judgment subunit;

[0100] If yes, the node management module resets the status timer, obtains the status of the node, and sends the status information of the node to the scheduling module.

[0101] Third, the leader state transition unit includes:

[0102] The scheduling heartbeat subunit, when receiving the self-recommendation information of this node, the node becomes the leader, and the scheduling module immediately sends a scheduling heartbeat;

[0103] The heartbeat timer starter unit schedules the module to start the heartbeat timer quickly;

[0104] The third judgment subunit is used to judge whether the heartbeat timer reaches the timing time T5, T5<T2, and the value of T5 is adjusted according to system requirements:

[0105] If the timing time T5 is reached, it is determined whether the minimum system resources are met. If so, the heartbeat timer is reset, and the scheduling heartbeat is sent, and the process returns to the third judgment subunit of step to wait for the next timing time to arrive; if not, the heartbeat timer is turned off, and the state transition process ends;

[0106] If the timing time T5 is not reached, then:

[0107] ① Determine whether the heartbeat of other node scheduling is received:

[0108] If the node receives a scheduling heartbeat from another node, and the term number in the scheduling heartbeat is greater than the local term number, the scheduling module of this node turns off the heartbeat timer and becomes a follower, and the state transition process ends;

[0109] Otherwise, re-execute the third judgment subunit;

[0110] ② Determine whether to receive self-recommendation information from other nodes:

[0111] If a node receives a self-recommendation message from another node, and the term number in the self-recommendation message is greater than the local one, the node scheduling module turns off the heartbeat timer and becomes a follower, and the state transition process ends;

[0112] Otherwise, the third judgment subunit is executed again.

[0113] In a specific embodiment, the present invention is divided into two stages: initial operation and operation process, specifically:

[0114] 1. First run phase (no scheduling module is elected)

[0115] Each node management module with candidate qualifications has a random time self-recommendation timer.

[0116] After the first startup, the self-recommendation timer is activated. If the heartbeat information sent by the scheduling is received in the scheduling heartbeat channel before the timing timeout T1 (including the scheduling IP port number, term number self-increment, etc.), the timer is turned off, a connection is established with the scheduling node, and it is converted to a follower; if the self-recommendation information sent by other candidates is received before the timing timeout T1, the self-recommendation timer is turned off, the latest term number is used as the basis, the scheduling heartbeat channel is monitored, the scheduling heartbeat information sent by the node that sends the self-recommendation information is monitored, and a connection is established with it, and it is converted to a follower; if the scheduling heartbeat is not received after the time threshold T2, the timer is activated. If the timing time is up and the scheduling heartbeat and self-recommendation information sent by other candidates are not received, the leader self-recommendation information is sent once through the discovery multicast channel, and it is converted to a leader at this time, and the scheduling heartbeat is sent to all node management modules. When there is a scheduling heartbeat, all nodes establish a connection with it.

[0117] As a scheduling node, if the minimum system resources are not met, the scheduling heartbeat should be stopped. If the node management module of this node does not receive the scheduling heartbeat after the timeout T4, it will wait for a new scheduling node, become a candidate, activate the self-recommendation timer, and send the self-recommendation information again when the timing time is up.

[0118] To avoid extreme situations, information islands, and small clusters, if the leader sends a scheduling heartbeat and receives a scheduling heartbeat from other nodes, the term number of the scheduling heartbeat sent by other nodes is compared with the local current term number. If the local term number is smaller, the self-recommendation timer is turned off, the scheduling heartbeat is stopped, and the scheduling heartbeat is waited for from other scheduling modules to become a follower; if the local term number is larger, the scheduling heartbeat information is continued to be sent. If the leader sends a scheduling heartbeat and receives a self-recommendation message from other nodes, the term number of the scheduling heartbeat sent by other nodes is compared with the local current term number. If the local term number is smaller, the self-recommendation timer is turned off, and the scheduling heartbeat is waited for from other scheduling modules; if the local term number is larger, the self-recommendation message is sent again to update the local term number.

[0119] 2. During operation (scheduling node downtime)

[0120] During operation, the follower detects that it has timed out and has not received the scheduling heartbeat. If this node is a scheduling node, and the node management module of this node has not received the scheduling heartbeat within T4, it will be converted to a candidate; if before the timing timeout T1, the heartbeat information sent by the scheduling is received in the scheduling heartbeat channel (including the scheduling IP port number, term number self-increment, etc.), the timer will be turned off, a connection will be established with the scheduling node, and it will be converted to a follower; if before the timing timeout T1, a self-recommendation message is received from other candidates, the term number is compared, and if the term number is greater than the local, the self-recommendation timer will be turned off, the scheduling heartbeat message of the node that sent the self-recommendation message will be monitored, and a connection will be established with it, and it will be converted to a follower; if the scheduling heartbeat is not received within the time threshold T2, the timer will be activated. If the timing time is up and the scheduling heartbeat and self-recommendation messages sent by other candidates are not received, the leader self-recommendation message will be sent once through the discovery multicast channel, and it will be converted to a leader at this time, and the scheduling heartbeat will be sent to all node management modules. When there is a scheduling heartbeat, all nodes will establish a connection with it.

[0121] As a scheduling node, if the minimum system resources are not met, the scheduling heartbeat should be stopped. If the node management module of this node does not receive the scheduling heartbeat after the timeout T4, it will wait for a new scheduling node, become a candidate, activate the self-recommendation timer, and send the self-recommendation information again when the timing time is up.

[0122] To avoid extreme situations, information islands, and small clusters, if the leader sends a scheduling heartbeat and receives a scheduling heartbeat from other nodes, the term number of the scheduling heartbeat sent by other nodes is compared with the local current term number. If the local term number is smaller, the self-recommendation timer is turned off, the scheduling heartbeat is stopped, and the scheduling heartbeat is waited for from other scheduling modules to become a follower; if the local term number is larger, the scheduling heartbeat information is continued to be sent. If the leader sends a scheduling heartbeat and receives a self-recommendation message from other nodes, the term number of the scheduling heartbeat sent by other nodes is compared with the local current term number. If the local term number is smaller, the self-recommendation timer is turned off, and the scheduling heartbeat is waited for from other scheduling modules; if the local term number is larger, the self-recommendation message is sent again to update the local term number.

[0123] In summary, the present invention relies on the node management module running on the node and the scheduling module on the scheduling node to realize the automatic master selection function, thereby solving the single point failure problem, avoiding the downtime of the scheduling node affecting the normal operation of the entire system, and enabling the system to operate stably for a long time. In addition, the present invention does not rely on any open source components, is autonomous and controllable, and can run on a variety of operating systems; the normal operation of one scheduling node in the system can meet the system operation requirements, and there is no requirement for more than half of the nodes to operate normally, and the system has good stability.

Claims

1. A method for selecting a leader in a lightweight distributed decentralized system, characterized in that: include: A node management module runs on each hardware node of the distributed system, and the role of the hardware node is configured through the configuration file; Configure multiple hardware nodes as scheduling nodes at the same time. Scheduling nodes have three states: leader, follower, and candidate. The scheduling node is in the candidate state by default. The active scheduling node is determined by the master election method. The principle of master election is self-recommendation. Whoever registers first wins. The candidate can switch to a follower or a leader according to the conditions, or can maintain the candidate state. The candidate state transition process is as follows: (1.1) Activate the self-recommendation timer; (1.2) Before the self-recommendation timer expires T1: ① If the scheduling heartbeat information sent by other nodes is received in the scheduling heartbeat channel, the information contains the scheduled IP port number and the term number increment. Compare whether the term number is greater than the local one. The local one refers to the term number stored in this node: If yes, then turn off the self-recommendation timer, establish a connection with the scheduling node, and convert to a follower; If not, determine whether the self-recommendation timer has exceeded T1 time. If not, return to step (1.2). If so, proceed to step (1.3). ② If you receive self-recommendation information from other nodes, compare whether the term number is greater than the local one: If so, determine whether the scheduling heartbeat of the node is received within the timeout T2. The node refers to the current node described relative to other nodes. If received, turn off the timer, establish a connection with the scheduling node, and convert to a follower. If not received, determine whether the self-recommendation timer has timed out by T1. If not, return to step (1.2). If T1 has timed out, go to step (1.3). T1>T2, and the values ​​of T1 and T2 are adjusted according to system requirements. If not, then turn off the self-recommendation timer, send a self-recommendation message, and become a leader; ③ If no scheduling heartbeat information is received from other nodes in the scheduling heartbeat channel, and no self-recommendation information is received from other nodes, then go to step (1.3); (1.3) After the self-recommendation timer times out T1: turn off the self-recommendation timer, send a self-recommendation message, and become the leader.

2. The method for selecting a leader in a lightweight distributed decentralized system according to claim 1, characterized in that: The leaders, followers, and candidates are as follows: The leader is used to send scheduling heartbeats, which are heartbeat packets broadcast periodically to maintain the leader status; Follower, used to receive scheduling heartbeats; Candidates, used to activate the self-recommendation process, candidates have the opportunity to become leaders.

3. The method for selecting a leader in a lightweight distributed decentralized system according to claim 1, characterized in that: A follower can further become a leader or degenerate into a candidate. The follower state transition process is as follows: (2.1) The node management module of this node starts the status timer and the monitoring timer; (2.2) Determine whether the node management module of this node receives the scheduling heartbeat within the timeout T4: If yes, go to step (2.3); If not, turn off the state timer and the listening timer, turn into a candidate, and end the conversion process; (2.3) The node management module resets the monitoring timer and compares the scheduling term number with the local one: If the scheduling term number is larger than the local one, the scheduling module is redirected according to the scheduling heartbeat, a connection is established with the new scheduling module, and step (2.4) is entered; If the scheduling term number is smaller than the local one, the state timer and the monitoring timer are turned off, the node becomes a candidate, and the conversion process ends; If the scheduling term number is the same as the local one, go to step (2.4); (2.4) Determine whether the status timer has timed out: If not, re-enter step (2.4); If yes, the node management module resets the status timer, obtains the status of the node, and sends the status information of the node to the scheduling module.

4. The method for selecting a leader in a lightweight distributed decentralized system according to claim 1, characterized in that: The leader degenerates into a follower or candidate according to the conditions. The leader state transition process is as follows: (3.1) When receiving the self-recommendation information of this node, this node becomes the leader, and the scheduling module immediately sends a scheduling heartbeat; (3.2) The scheduling module starts the heartbeat timer; (3.3) Determine whether the heartbeat timer reaches the timing time T5, T5<T2, and the value of T5 is adjusted according to system requirements: If the timing time T5 is reached, determine whether the minimum system resources are met. If so, reset the heartbeat timer, send the scheduling heartbeat, and return to step (3.3) to wait for the next timing time to arrive; if not, turn off the heartbeat timer and become a candidate, and the state transition process ends; If the timing time T5 is not reached, then: ① Determine whether the heartbeat of other node scheduling is received: If the node receives a scheduling heartbeat from another node, and the term number in the scheduling heartbeat is greater than the local term number, the scheduling module of this node turns off the heartbeat timer and becomes a follower, and the state transition process ends; Otherwise, re-execute step (3.3); ② Determine whether to receive self-recommendation information from other nodes: If a node receives a self-recommendation message from another node, and the term number in the self-recommendation message is greater than the local one, the node scheduling module turns off the heartbeat timer and becomes a follower, and the state transition process ends; Otherwise, repeat step (3.3).

5. The method for selecting a leader in a lightweight distributed decentralized system according to claim 4, characterized in that: The minimum system resources refer to the minimum set of nodes required for the system to run. The criteria for meeting the minimum resources are: The minimum set of various types of nodes refers to at least one scheduling node, conventional computing node, advanced computing node, and data access node, and all nodes that meet the minimum system requirements can ping each other, that is, the network is reachable.

6. A master selection device for a lightweight distributed decentralized system, characterized in that: It includes multiple node management modules, each of which has a configuration file, including: Each node management module is set on each hardware node of the distributed system one by one, and the configuration file is used to configure the role of the hardware node; The configuration file configures multiple hardware nodes as scheduling nodes at the same time. The scheduling nodes have three states: leader, follower, and candidate. The scheduling nodes are provided with a candidate state transition unit, a follower state transition unit, and a leader state transition unit. The scheduling node is in the candidate state by default. The active scheduling node is determined by the master election method. The principle of master election is self-recommendation. Whoever registers first wins. The candidate state transition unit includes: A timer activation subunit, used for activating a self-recommendation timer; Subunit before the self-recommendation timer times out T1 time: used to perform the following processing before the self-recommendation timer times out T1 time: ① If the scheduling heartbeat information sent by other nodes is received in the scheduling heartbeat channel, the information contains the scheduled IP port number and the term number increment. Compare whether the term number is greater than the local one. The local one refers to the term number stored in this node: If yes, then turn off the self-recommendation timer, establish a connection with the scheduling node, and convert to a follower; If not, determine whether the self-recommendation timer has timed out by T1 time, if not, return to the sub-unit before the self-recommendation timer timed out by T1 time, if it has timed out by T1 time, enter the sub-unit after the self-recommendation timer timed out by T1 time; ② If you receive self-recommendation information from other nodes, compare whether the term number is greater than the local one: If so, determine whether the scheduling heartbeat of the node is received within the timeout T2. The node refers to the current node described relative to other nodes. If received, turn off the timer, establish a connection with the scheduling node, and convert to a follower. If not received, determine whether the self-recommendation timer has timed out by T1. If not, return to the sub-unit before the self-recommendation timer timeout T1. If it has timed out by T1, enter the sub-unit after the self-recommendation timer timeout T1. T1>T2, and the values ​​of T1 and T2 are adjusted according to system requirements. If not, then turn off the self-recommendation timer, send a self-recommendation message, and become a leader; ③ If the scheduling heartbeat information sent by other nodes is not received in the scheduling heartbeat channel, and no self-recommendation information from other nodes is received, the sub-unit after the self-recommendation timer times out T1 time is entered; The subunit after the self-recommendation timer times out for T1 time is used to perform the following processing after the self-recommendation timer times out for T1 time: Turn off the self-recommendation timer, send a self-recommendation message, and become a leader.

7. The master selection device of the lightweight distributed decentralized system according to claim 6, characterized in that: The follower state transition unit includes: The state timer and monitoring timer subunits are used to start the state timer and the monitoring timer; The first judgment subunit is used to judge whether the node management module of the node receives the scheduling heartbeat within the timeout T4: If yes, then enter the comparison subunit; If not, turn off the state timer and the listening timer, turn into a candidate, and end the conversion process; The comparison subunit is used to reset the monitoring timer and compare the scheduling term number with the local one: If the scheduling term number is larger than the local one, the scheduling module is redirected according to the scheduling heartbeat, a connection is established with the new scheduling module, and the second judgment subunit is entered; If the scheduling term number is smaller than the local one, the state timer and the monitoring timer are turned off, the node becomes a candidate, and the conversion process ends; If the scheduling term number is the same as the local one, then enter the second judgment subunit; The second judgment subunit is used to judge whether the status timer has timed out: If not, re-enter the second judgment subunit; If yes, the node management module resets the status timer, obtains the status of the node, and sends the status information of the node to the scheduling module.

8. The master selection device of the lightweight distributed decentralized system according to claim 6, characterized in that: The leader state transition unit includes: The scheduling heartbeat subunit, when receiving the self-recommendation information of this node, the node becomes the leader, and the scheduling module immediately sends a scheduling heartbeat; The heartbeat timer starter unit schedules the module to start the heartbeat timer quickly; The third judgment subunit is used to judge whether the heartbeat timer reaches the timing time T5, T5<T2, and the value of T5 is adjusted according to system requirements: If the timing time T5 is reached, it is determined whether the minimum system resources are met. If so, the heartbeat timer is reset, and the scheduling heartbeat is sent, and the process returns to the third judgment subunit of step to wait for the next timing time to arrive; if not, the heartbeat timer is turned off, and the state transition process ends; If the timing time T5 is not reached, then: ① Determine whether the heartbeat of other node scheduling is received: If the node receives a scheduling heartbeat from another node, and the term number in the scheduling heartbeat is greater than the local term number, the scheduling module of this node turns off the heartbeat timer and becomes a follower, and the state transition process ends; Otherwise, re-execute the third judgment subunit; ② Determine whether to receive self-recommendation information from other nodes: If a node receives a self-recommendation message from another node, and the term number in the self-recommendation message is greater than the local one, the node scheduling module turns off the heartbeat timer and becomes a follower, and the state transition process ends; Otherwise, the third judgment subunit is executed again.

Citation Information

Patent Citations

  • General distributed intelligent processing analysis platform and method for electromagnetic signals

    CN113157252A

  • Raft-based distributed task scheduling system

    CN113342483A