A method and apparatus for electing a distributed master node
Patent Information
- Application Number
- CN202211456073.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-21
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-11-21
AI Technical Summary
目前的主控节点选举方法是基于随机产生的整数猜拳值进行选举的方法,很明显,目前的方法具有选举结果不可控的问题,从而很容易影响到分布式系统整体的工作能力
[0020]判断所述竞选节点集合中竞选节点数量是否为一;
Smart Images

Figure CN116155529B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of distributed computing, and more specifically, to a method and apparatus for electing a distributed master node. Background Technology
[0002] With the rapid development of network technology, network traffic has experienced explosive growth, drawing widespread attention to network security. Single-machine firewalls and load balancers, when deployed in real-world network environments, are prone to performance bottlenecks. Therefore, the development of distributed security gateway systems has become a priority. However, distributed systems require a master node to provide an interface for user interaction and manage other nodes to enable collaborative operation. Current master node election methods rely on randomly generated integer rock-paper-scissors values. Clearly, this method suffers from uncontrollable election results, easily impacting the overall performance of the distributed system. Summary of the Invention
[0003] The purpose of this application is to provide a distributed master node election method and apparatus that can elect the optimal master node, thereby ensuring the overall working effect of the distributed system.
[0004] The first aspect of this application provides a distributed master node election method, including:
[0005] Check if a master node exists in the TIPC's shared name table;
[0006] When the master control service does not exist in the shared name table, multiple candidate nodes are identified in the shared name table;
[0007] Extract the node election information of the multiple candidate nodes;
[0008] Based on the node election information, a master node is selected from the multiple candidate nodes.
[0009] In the above implementation process, this method can first check whether a master node exists in the shared name table of TIPC. Therefore, this method can establish a reliable communication channel between nodes based on TIPC and monitor and elect distributed nodes based on the shared name table of these channels. Then, if no master node exists in the shared name table, multiple candidate nodes are identified. This means that the method can only begin the election service when it is determined that there is currently no master node. The first step of this election service is to identify all candidate nodes in the TIPC shared name table. Furthermore, this method can eliminate non-candidate nodes in this step, thereby further improving the efficiency of the master node election. Next, the method extracts the node election information of multiple candidate nodes and selects a master node from among them based on this information. Thus, this method can perform a horizontal comparison based on the node election information of all candidate nodes to select the most suitable candidate node as the master node, and then use this candidate node as the master node to complete the master node election service.
[0010] Furthermore, after the step of selecting a master node from the plurality of candidate nodes based on the node election information, the method further includes:
[0011] The other nodes are notified that the master node has been successfully elected.
[0012] In the above implementation process, after the step of selecting a master node from multiple candidate nodes based on node election information, this method notifies other nodes that the master node has been successfully elected. Therefore, this method can notify all other nodes of the successful election after the election service ends, enabling all nodes to provide corresponding services based on the master node. Furthermore, this method facilitates querying by nodes that join the distributed system later.
[0013] Furthermore, after the step of selecting a master node from the plurality of candidate nodes based on the node election information, the method further includes:
[0014] Detect whether the master control node has malfunctioned or unexpectedly exited;
[0015] When the master node fails or exits unexpectedly, the step of identifying multiple candidate nodes in the shared name table is triggered.
[0016] In the above implementation, after the step of selecting a master node from multiple candidate nodes based on node election information, this method can detect in real time whether the master node has failed or unexpectedly exited; and when the master node fails or unexpectedly exits, it triggers the step of identifying multiple candidate nodes in the shared name table. Therefore, this method can detect the master node in real time, so that in the event of a master node failure or voluntary exit, a node exit event is generated based on the TIPC shared name table, allowing other nodes to receive this event and thus triggering a restart of the election process.
[0017] Furthermore, the step of selecting a master node from the plurality of candidate nodes based on the node election information includes:
[0018] Obtain the election priority and node ID value included in the node election information;
[0019] Select the set of candidate nodes with the smallest election priority from among the plurality of candidate nodes;
[0020] Determine whether the number of candidate nodes in the candidate node set is one;
[0021] When the number of candidate nodes is one, the candidate node in the candidate node set is determined as the master node.
[0022] In the above implementation process, when selecting a master node from multiple candidate nodes based on node election information, this method prioritizes obtaining the election priority and node ID value included in the node election information. It is evident that node election information includes at least election priority and node ID value, which can distinguish candidate nodes based on specific rules, thus ensuring a reasonable and reliable election process. Then, this method selects the set of candidate nodes with the smallest election priority from multiple candidate nodes. The election priority can be considered as the recommendation degree of the master node; the lower the election priority, the higher the recommendation degree of the candidate node. Therefore, this method can easily and effectively obtain the most recommended set of candidate nodes (the set contains at least one node). Finally, this method further determines whether the number of candidate nodes in the set is one; and if the number of candidate nodes is one, the candidate node in the set is determined as the master node. Thus, this method can determine the master node when it obtains a unique, most recommended candidate node, thereby completing the selection of the master node.
[0023] Furthermore, the method also includes:
[0024] When the number of candidate nodes is not one, the candidate node with the smallest node ID value in the candidate node set is selected as the master node.
[0025] In the above implementation, when the number of candidate nodes is not uniform, this method selects the candidate node with the smallest node ID value from the candidate node set and determines it as the master node. Therefore, this method can quickly select the master node from multiple recommended candidate nodes based on certain settings, thus making the master node election process more efficient.
[0026] A second aspect of this application provides a distributed master node election device, the distributed master node election device comprising:
[0027] The detection unit is used to detect whether a master node exists in the shared name table of TIPC;
[0028] The identification unit is used to identify multiple candidate nodes in the shared name table when the master control service does not exist in the shared name table;
[0029] An extraction unit is used to extract node election information from the multiple candidate nodes;
[0030] An election unit is used to select a master node from among the multiple candidate nodes based on the node election information.
[0031] Furthermore, the distributed master node election device also includes:
[0032] The notification unit is used to notify other nodes that the master node has been successfully elected after the master node has been selected from the plurality of candidate nodes based on the node election information.
[0033] Furthermore, the detection unit is also used to detect whether the master node has malfunctioned or unexpectedly exited after the master node is selected from the plurality of candidate nodes based on the node election information.
[0034] The identification unit is also used to trigger the step of identifying multiple candidate nodes in the shared name table when the master node fails or exits unexpectedly.
[0035] Furthermore, the election unit includes:
[0036] The acquisition subunit is used to acquire the election priority and node ID value included in the node election information;
[0037] An election subunit is used to select the set of candidate nodes with the smallest election priority from among the plurality of candidate nodes;
[0038] The judgment subunit is used to determine whether the number of candidate nodes in the candidate node set is one.
[0039] A sub-unit is defined to determine the candidate node in the candidate node set as the master node when the number of candidate nodes is one.
[0040] Furthermore, the determining subunit is also used to select the candidate node with the smallest node ID value from the candidate node set and determine it as the master node when the number of candidate nodes is not one.
[0041] A third aspect of this application provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor runs the computer program to cause the electronic device to perform the distributed master node election method described in any one of the first aspects of this application.
[0042] The fourth aspect of this application provides a computer-readable storage medium storing computer program instructions, which, when read and executed by a processor, perform the distributed master node election method described in any one of the first aspects of this application. Attached Figure Description
[0043] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 A flowchart illustrating a distributed master node election method provided in an embodiment of this application;
[0045] Figure 2 A flowchart illustrating a distributed master node election method provided in an embodiment of this application;
[0046] Figure 3 A schematic diagram of a distributed master node election device provided in this application embodiment;
[0047] Figure 4 A schematic diagram of a distributed master node election device provided in this application embodiment;
[0048] Figure 5 This is a schematic diagram illustrating an example of an election process provided in this application. Detailed Implementation
[0049] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0050] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0051] Example 1
[0052] Please refer to Figure 1 , Figure 1 This embodiment provides a flowchart illustrating a distributed master node election method. The distributed master node election method includes:
[0053] S101. Check if a master node exists in the shared name table of TIPC. If it does, end this process; otherwise, proceed to steps S102 to S104.
[0054] S102. Identify multiple candidate nodes in the shared name table.
[0055] S103. Extract node election information from multiple candidate nodes.
[0056] S104. Based on node election information, select a master node from multiple candidate nodes.
[0057] In this embodiment, the method can solve the following technical problems:
[0058] (1) To achieve rapid election of master nodes in a distributed system;
[0059] (2) Non-master nodes can subscribe to master node services and receive master node exit notifications in a timely manner;
[0060] (3) After the master node fails, other nodes should promptly initiate a re-election.
[0061] In this embodiment, the method can utilize the shared name table of TIPC in a distributed system to achieve master election and status monitoring.
[0062] For example, this method can be applied to the election of a master node in a distributed system. It only requires creating the corresponding services at different stages and querying the corresponding services in the shared name table on the local node to elect a master node. Since the election logic is the same for each node and the services queried are the same, the elected master node is also the same. That is, each node will elect the same master node, and there is no need to broadcast the election results after the election.
[0063] For another example, this method can be applied to the status monitoring of master nodes in distributed systems. No heartbeat messages are needed between nodes; non-master nodes only need to subscribe to the master service on their local shared name table to receive event notifications from the shared name table immediately when the master node exits, allowing for timely re-election of the master.
[0064] In this embodiment, the subject executing the method can be a computing device such as a computer or server, and no limitation is made in this embodiment.
[0065] In this embodiment, the subject executing the method can also be a smart device such as a smartphone or tablet, and no limitation is made in this embodiment.
[0066] As can be seen, the distributed master node election method described in this embodiment can conduct master node election without information exchange at the application layer of the distributed system, and the election results do not need to be broadcast, resulting in higher accuracy and faster convergence speed. At the same time, it also enables each node to monitor the status of the master node without exchanging heartbeat messages. Specifically, after each node subscribes to the master service, when the master node exits, each node will immediately receive a notification event without waiting for the heartbeat timeout, thus improving timeliness.
[0067] Example 2
[0068] Please refer to Figure 2 , Figure 2 This embodiment provides a flowchart illustrating a distributed master node election method. The distributed master node election method includes:
[0069] S201. Check if a master node exists in the shared name table of TIPC. If it does, end this process; otherwise, proceed to steps S202 to S206.
[0070] S202. Identify multiple candidate nodes in the shared name table.
[0071] S203. Extract node election information from multiple candidate nodes.
[0072] S204. Obtain the election priority and node ID value included in the node election information.
[0073] In this embodiment, in a distributed system where TIPC is running on each node, each node can intervene in the election results by setting the TIPC address instance number when creating the socket (service). The instance number is a 32-bit integer called the node_id, which consists of the following two parts: priority and node ID.
[0074] S205. Select the set of candidate nodes with the smallest election priority among multiple candidate nodes.
[0075] In this embodiment, the maximum configurable election priority is 0, and the minimum election priority is 255. If a node's priority is 0, it can be understood that the system designates that node as the master. If the priority is 255, it can be understood that the node is not recommended to be the master.
[0076] S206. Determine whether the number of candidate nodes in the candidate node set is one. If yes, execute steps S207 and S209 to S210; otherwise, execute steps S208 to S210.
[0077] S207. Determine the candidate nodes in the candidate node set as the master node.
[0078] S208. Select the candidate node with the smallest node ID value from the candidate node set and determine it as the master node.
[0079] In this embodiment, the master election algorithm of the distributed system considers both node ID and priority. The algorithm first checks the priority and selects the node with the highest priority as the master. If the priorities are the same, the algorithm considers the node ID and selects the node with the smaller ID as the master.
[0080] S209. Notify other nodes that the master node has been successfully elected.
[0081] S210. Check if the master control node has failed or exited unexpectedly. If yes, proceed to steps S202 to S206; otherwise, end this process.
[0082] In this embodiment, the key technical points involved in the method are as follows:
[0083] (1) Assign weights to the nodes;
[0084] (2) Create different services in stages and achieve distributed master election by querying the shared name table of TIPC;
[0085] (3) Non-master nodes subscribe to master services. When the master node exits, the shared name table promptly and proactively notifies other nodes instead of waiting for timeout.
[0086] Please see Figure 5 , Figure 5A schematic diagram illustrating an election process is provided. This method creates a socket with the service name "I WANT TO BE ACSU" (election service) on all nodes with master control capabilities in the system. Each node queries its local TIPC shared name table to detect the node information corresponding to all nodes running this service in the distributed system, and elects the node with the smallest node_id as the master. After the master election is completed, each node shuts down the election service and exits the election process. The elected master node creates a socket named "I AM ACSU" (master control service). However, because the master in the distributed system may need to lead information synchronization and configuration synchronization among nodes, master preemption is not used for the stability of the distributed system. That is, if a master already exists, and the master is not faulty or actively switched to a non-master, even if a node with a higher priority than the current master appears, the current master remains unchanged, and no re-election is performed. In addition, if other nodes have subscribed to the shared name table master service, the shared name table will generate a node exit event in the event of a failure or exit of the master node. After receiving the event and determining that the master node has exited, other nodes will restart the master election process.
[0087] It is evident that this method can be based on Figure 5 For example:
[0088] (1) Check if the master control service exists in the shared name table;
[0089] (2) Create campaign services;
[0090] (3) Search all campaign services;
[0091] (4) The node with the smallest node_id is the master node;
[0092] (5) After electing the master controller, create the master controller service.
[0093] Specifically, the steps of step (1) are as follows: After the distributed system node enters the master election process, it first checks whether there is a socket with the service name "I AM ACSU" on the shared name table, that is, the master service. If it exists, it means that the current system has elected a master. After recording the node_id of the master, it exits the election process.
[0094] The specific steps of step (2) are as follows: If there is no master control service on the shared name table, the node creates a socket with the service name "I WANT TO BE ACSU" on the shared name table, which is the election service.
[0095] The specific steps of step (3) are as follows: This node queries all the election services in the current system through the shared name table, and the table entries found will include the node_id.
[0096] Step (4) involves the following steps: Compare the node_id of this node with the node_ids of other candidate services. If the node_id of this node is not the smallest, wait for the master service to appear in the name table, record the master node_id, and exit the election process. If the node_id of this node is the smallest, check whether the current system has generated a master during the election process of this node. That is, query whether the shared name table currently has a master service. If not, elect this node as the master. If so, record the master node_id and exit the election process.
[0097] The specific steps of step (5) are as follows: elect the master node, create the master service in the shared name table, and notify the nodes that have subscribed to this service, which also facilitates the query of nodes that join the distributed system later.
[0098] In this embodiment, the subject executing the method can be a computing device such as a computer or server, and no limitation is made in this embodiment.
[0099] In this embodiment, the subject executing the method can also be a smart device such as a smartphone or tablet, and no limitation is made in this embodiment.
[0100] As can be seen, the distributed master node election method described in this embodiment can conduct master node election without information exchange at the application layer of the distributed system, and the election results do not need to be broadcast, resulting in higher accuracy and faster convergence speed. At the same time, it also enables each node to monitor the status of the master node without exchanging heartbeat messages. Specifically, after each node subscribes to the master service, when the master node exits, each node will immediately receive a notification event without waiting for the heartbeat timeout, thus improving timeliness.
[0101] Example 3
[0102] Please refer to Figure 3 , Figure 3 This is a schematic diagram of a distributed master node election device provided in this embodiment. Figure 3 As shown, the distributed master node election device includes:
[0103] The detection unit 310 is used to detect whether a master node exists in the shared name table of TIPC;
[0104] The identification unit 320 is used to identify multiple candidate nodes in the shared name table when the master service does not exist in the shared name table.
[0105] Extraction unit 330 is used to extract node election information from multiple candidate nodes;
[0106] Election unit 340 is used to select a master node from multiple candidate nodes based on node election information.
[0107] In this embodiment, the explanation of the distributed master node election device can be referred to the description in Embodiment 1 or Embodiment 2, and will not be repeated here.
[0108] As can be seen, the distributed master node election device described in this embodiment can conduct master election without information interaction at the application layer of the distributed system, and the election results do not need to be broadcast, resulting in higher accuracy and faster convergence speed. At the same time, it also enables each node to monitor the status of the master node without exchanging heartbeat messages. Specifically, after each node subscribes to the master service, when the master node exits, each node will immediately receive a notification event without waiting for the heartbeat timeout, thus improving timeliness.
[0109] Example 4
[0110] Please refer to Figure 4 , Figure 4 This is a schematic diagram of a distributed master node election device provided in this embodiment. Figure 4 As shown, the distributed master node election device includes:
[0111] The detection unit 310 is used to detect whether a master node exists in the shared name table of TIPC;
[0112] The identification unit 320 is used to identify multiple candidate nodes in the shared name table when the master service does not exist in the shared name table.
[0113] Extraction unit 330 is used to extract node election information from multiple candidate nodes;
[0114] Election unit 340 is used to select a master node from multiple candidate nodes based on node election information.
[0115] As an optional implementation, the distributed master node election device further includes:
[0116] The notification unit 350 is used to notify other nodes that the master node has been successfully elected after the master node has been selected from multiple candidate nodes based on node election information.
[0117] As an optional implementation, the detection unit 310 is also used to detect whether the master node has failed or unexpectedly exited after the master node is selected from multiple candidate nodes based on node election information.
[0118] The identification unit 320 is also used to trigger the execution of the step of identifying multiple candidate nodes in the shared name table when the master node fails or exits unexpectedly.
[0119] As an optional implementation, the election unit 340 includes:
[0120] Acquire subunit 341, used to obtain the election priority and node ID value included in the node election information;
[0121] Election subunit 342 is used to select the smallest set of candidate nodes with the lowest election priority from among multiple candidate nodes;
[0122] Judgment subunit 343 is used to determine whether the number of candidate nodes in the candidate node set is one;
[0123] Subunit 344 is defined to determine the main control node from the set of candidate nodes when the number of candidate nodes is one.
[0124] As an optional implementation, the determined subunit 344 is also used to select the candidate node with the smallest node ID value from the candidate node set and determine it as the master node when the number of candidate nodes is not one.
[0125] In this embodiment, the explanation of the distributed master node election device can be referred to the description in Embodiment 1 or Embodiment 2, and will not be repeated here.
[0126] As can be seen, the distributed master node election device described in this embodiment can conduct master election without information interaction at the application layer of the distributed system, and the election results do not need to be broadcast, resulting in higher accuracy and faster convergence speed. At the same time, it also enables each node to monitor the status of the master node without exchanging heartbeat messages. Specifically, after each node subscribes to the master service, when the master node exits, each node will immediately receive a notification event without waiting for the heartbeat timeout, thus improving timeliness.
[0127] This application provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor runs the computer program to enable the electronic device to execute the distributed master node election method in embodiment 1 or embodiment 2 of this application.
[0128] This application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, the distributed master node election method in embodiment 1 or embodiment 2 of this application is performed.
[0129] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0130] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0131] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0132] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0133] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0134] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A distributed master node election method, characterized in that, include: Check if a master node exists in the TIPC's shared name table; When the master node is not present in the shared name table, multiple candidate nodes are identified in the shared name table; Extract the node election information of the multiple candidate nodes; Based on the node election information, a master node is selected from the plurality of candidate nodes; The process involves identifying multiple candidate nodes in the shared name table, including: Query the shared name table of the local TIPC to find all nodes that have created election services, and you will get multiple election nodes.
2. The distributed master node election method according to claim 1, characterized in that, After the step of selecting a master node from the plurality of candidate nodes based on the node election information, the method further includes: The other nodes are notified that the master node has been successfully elected.
3. The distributed master node election method according to claim 1, characterized in that, After the step of selecting a master node from the plurality of candidate nodes based on the node election information, the method further includes: Detect whether the master control node has malfunctioned or unexpectedly exited; When the master node fails or exits unexpectedly, the step of identifying multiple candidate nodes in the shared name table is triggered.
4. The distributed master node election method according to claim 1, characterized in that, The step of selecting a master node from the plurality of candidate nodes based on the node election information includes: Obtain the election priority and node ID value included in the node election information; Select the set of candidate nodes with the smallest election priority from among the plurality of candidate nodes; Determine whether the number of candidate nodes in the candidate node set is one; When the number of candidate nodes is one, the candidate node in the candidate node set is determined as the master node.
5. The distributed master node election method according to claim 4, characterized in that, The method further includes: When the number of candidate nodes is not one, the candidate node with the smallest node ID value in the candidate node set is selected as the master node.
6. A distributed master node election device, characterized in that, The distributed master node election device includes: The detection unit is used to detect whether a master node exists in the shared name table of TIPC; The identification unit is used to identify multiple candidate nodes in the shared name table when the master node does not exist in the shared name table; An extraction unit is used to extract node election information from the multiple candidate nodes; An election unit is used to select a master node from the plurality of candidate nodes based on the node election information; Specifically, the identification unit is used to query all nodes that have created election services in the shared name table of the local TIPC to obtain multiple election nodes.
7. The distributed master node election device according to claim 6, characterized in that, The election unit includes: The acquisition subunit is used to acquire the election priority and node ID value included in the node election information; An election subunit is used to select the set of candidate nodes with the smallest election priority from among the plurality of candidate nodes; The judgment subunit is used to determine whether the number of candidate nodes in the candidate node set is one. A sub-unit is defined to determine the candidate node in the candidate node set as the master node when the number of candidate nodes is one.
8. The distributed master node election device according to claim 7, characterized in that, The determining subunit is further configured to, when the number of candidate nodes is not one, select the candidate node with the smallest node ID value from the candidate node set and determine it as the master node.
9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory being used to store a computer program, and the processor running the computer program to cause the electronic device to perform the distributed master node election method according to any one of claims 1 to 5.
10. A readable storage medium, characterized in that, The readable storage medium stores computer program instructions, which, when read and executed by a processor, perform the distributed master node election method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Improved PBFT consensus method and device, intelligent terminal and storage medium
CN112866399A
Scheme and system for realizing distributed cluster node selection
CN113641692A