Method and device for implementing a dual-site arbitration system based on a distributed key-value store

By introducing the observer role into the etcd cluster, the arbitrator node only participates in voting for the leader without storing or replicating data, which solves the problems of complex leader election process and resource waste in dual-datacenter deployment and achieves efficient resource utilization.

CN119728378BActive Publication Date: 2025-11-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411752569.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-11-11
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

In an etcd cluster deployed in two data centers, the existing leader election arbitration process is cumbersome and wastes bandwidth and computing and storage resources.

Method used

By adding an observer role to etcd, the arbitrator node can participate in the leader election process without storing or replicating data, thus optimizing the leader election process and saving resources.

Benefits of technology

The leader election process has been optimized, saving bandwidth and computing and storage resources, and enabling efficient participation of arbitration nodes and rational use of resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728378B_ABST
    Figure CN119728378B_ABST
Patent Text Reader

Abstract

This invention provides a method and apparatus for implementing a dual-datacenter arbitration system based on a distributed key-value repository. The method includes: in response to the startup of the dual-datacenter arbitration system, obtaining configuration parameters, determining the role information of the arbitration nodes, broadcasting the role information of the arbitration nodes to a first node and a second node, receiving the role information of the first node and the second node, selecting a leader node from the first node and the second node based on the role information of the first node and the second node, obtaining a message permission list for the arbitration nodes based on the role information of the arbitration nodes, and filtering operation instruction messages sent by the leader node through the message permission list. This achieves the goal of optimizing the leader election process by adding a target role, allowing the arbitration nodes to only participate in voting for the leader without being elected as the leader, and eliminating the need for data storage and replication. It also saves bandwidth and computing and storage resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network technology, and in particular to a method and apparatus for implementing a dual-datacenter arbitration system based on a distributed key-value repository. Background Technology

[0002] In cloud computing data center construction, there is a need for dual-datacenter deployments. This necessitates leader election arbitration for services in the IaaS (Infrastructure as a Service) layer's virtual network control plane. Typically, in dual-datacenter deployments requiring arbitration, a third suitable site outside the two datacenters is added as an arbitrator node, forming a 3-node etcd (Extended Distributed Key Value) cluster for leader election. These three etcd instances, during operation, uniformly handle data replication and updates; all three nodes are equal and require identical configurations, such as memory, CPU (Central Processing Unit), disk space, and bandwidth. In other words, the etcd instance deployed on the arbitrator node stores all the data and participates in data replication and updates just like the etcd instances in the other two datacenters. However, the arbitrator node does not need to be the leader node, nor does it need to store or replicate data. The current leader election arbitration process is cumbersome and wastes bandwidth and computing / storage resources. Summary of the Invention

[0003] In view of the above problems, a method and apparatus for implementing a dual-datacenter arbitration system based on a distributed key-value store are proposed to overcome or at least partially solve the above problems, including:

[0004] A method for implementing a dual-datacenter arbitration system based on a distributed key-value repository, the dual-datacenter arbitration system comprising an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different datacenters, the method comprising:

[0005] In response to the startup of the dual-datacenter arbitration system, configuration parameters are obtained, and the role information of the arbitration node is determined.

[0006] The role information of the arbitration node is broadcast to the first node and the second node, and the role information of the first node and the second node is received.

[0007] A leader node is selected from the first node and the second node based on the role information of the first node and the role information of the second node.

[0008] Based on the role information of the arbitration node, a message permission list for the arbitration node is obtained, and the operation instruction messages of the leader node are filtered through the message permission list; wherein, the operation instruction messages include data copying operations and data update operations.

[0009] Optionally,

[0010] The role information includes the node URL and the node role;

[0011] The node role includes one of observer, leader, candidate, or follower, and the leader node's node role is the leader.

[0012] Optionally, obtaining configuration parameters and determining the role information of the arbitration node includes:

[0013] Get command-line arguments or configuration files;

[0014] The node role of the arbitration node is determined as the observer by executing the command-line parameters or reading the configuration file.

[0015] Optionally, after obtaining the configuration parameters and determining the role information of the arbitration node, the method further includes:

[0016] Initialize a global read-only role variable and set the value of the global read-only role variable to the enumeration value corresponding to the observer.

[0017] Optionally, it also includes:

[0018] Messages or operations related to the arbitration node are handled through a pre-defined observer state handling function.

[0019] Optionally, selecting a leader node from the first node and the second node based on the role information of the first node and the role information of the second node includes:

[0020] Receive voting request messages sent by the first node and the second node;

[0021] Send an agree vote message or a reject vote message to the first node and the second node;

[0022] The leader node is determined based on the sending of the agreed vote message or the rejected vote message.

[0023] Optionally, determining the leader node based on the sending of the agree vote message or the reject vote message includes:

[0024] If the first node receives the "agree" vote message, the second node receives the "reject" vote message and determines that the first node is the leader node and the second node's node role is the follower.

[0025] If the first node receives the rejection vote message, the second node receives the approval vote message and determines that the second node is the leader node, and the first node's node role is the follower.

[0026] An implementation device for a dual-datacenter arbitration system based on a distributed key-value repository, the dual-datacenter arbitration system comprising an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different datacenters, the device comprising:

[0027] The role information determination module is used to obtain configuration parameters and determine the role information of the arbitration node in response to the startup of the dual-data center arbitration system;

[0028] The role information sending and receiving module is used to send the role information of the arbitration node to the first node and the second node via broadcast, and to receive the role information of the first node and the role information of the second node.

[0029] The election module is used to select a leader node from the first node and the second node based on the role information of the first node and the role information of the second node;

[0030] The message filtering module is used to obtain the message permission list of the arbitration node based on the role information of the arbitration node, and filter the operation instruction messages of the leader node through the message permission list; wherein, the operation instruction messages include data copying operations and data update operations.

[0031] An electronic device includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When executed by the processor, the computer program implements the dual-datacenter arbitration system implementation method based on a distributed key-value store as described above.

[0032] A readable storage medium storing a computer program, which, when executed by a processor, implements the dual-datacenter arbitration system implementation method based on a distributed key-value store as described above.

[0033] The embodiments of the present invention have the following advantages:

[0034] In an embodiment of the present invention, in response to the startup of the dual-datacenter arbitration system, configuration parameters are obtained, the role information of the arbitration node is determined, and the role information of the arbitration node is broadcast to the first node and the second node. The role information of the first node and the role information of the second node are received. Based on the role information of the first node and the role information of the second node, a leader node is selected from the first node and the second node. According to the role information of the arbitration node, a message permission list of the arbitration node is obtained, and the operation instruction messages of the leader node are filtered through the message permission list. The operation instruction messages include data copying operations and data update operations. This realizes the newly added target role, allowing the arbitration node to only participate in voting for the leader but not to be elected as the leader, and it does not need to store and copy data, thus optimizing the leader election process and saving bandwidth and computing and storage resources. Attached Figure Description

[0035] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 This is a flowchart illustrating the steps of a dual-datacenter arbitration system implementation method based on a distributed key-value store, provided in some embodiments of the present invention.

[0037] Figure 2 This is a schematic diagram of a dual-datacenter arbitration system architecture provided in some embodiments of the present invention;

[0038] Figure 3 This is a flowchart illustrating the election process in a dual-datacenter arbitration system according to some embodiments of the present invention;

[0039] Figure 4 This is a schematic diagram of the architecture of a dual-datacenter arbitration system after election, provided by some embodiments of the present invention;

[0040] Figure 5 This is a structural block diagram of a dual-datacenter arbitration system implementation device based on a distributed key-value repository, provided in some embodiments of the present invention. Detailed Implementation

[0041] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0042] Etcd is an open-source, strongly consistent, distributed key-value store used to store and manage critical information needed to keep distributed systems running.

[0043] Etcd is built on the Raft (Replicated And Fault-Tolerant, a distributed consensus algorithm) consensus algorithm, ensuring data storage consistency across all nodes in the cluster—the goal of fault-tolerant distributed systems. Raft achieves this consistency through an elected leader node, which manages the replication of the other nodes in the cluster (called follower nodes). The leader node accepts requests from clients and forwards them to the follower nodes. Once the leader node determines that a majority of follower nodes have stored each new request as a log entry, it applies the entry to its local state machine and returns the result of this execution (a "write" operation) to the client. If a follower node crashes or network packets are lost, the leader node will retry until all follower nodes have consistently stored all log entries. If a follower node fails to receive a message from the leader node within a specified time interval, a new leader node is elected. This follower node declares itself as a candidate, and other follower nodes vote for it or any other node based on its availability. Once a new leader node is elected, it begins managing replication, and this process repeats itself. This process enables all etcd nodes to maintain highly available and consistent copies of data storage.

[0044] In one embodiment of the present invention, by modifying etcd, a new observer role is added. This allows the etcd server instance of the arbitration node to only participate in the leader election vote but not to be elected as the leader. It also eliminates the need for storing and replicating data, thus optimizing the leader election process and saving bandwidth and computing / storage resources. In this invention, the observer role can refer to an etcd server instance started with the observer role.

[0045] Reference Figure 1The diagram illustrates a flowchart of a method for implementing a dual-datacenter arbitration system based on a distributed key-value store, according to some embodiments of the present invention. The dual-datacenter arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different datacenters. Specifically, the method may include the following steps:

[0046] Step 101: In response to the startup of the dual-data center arbitration system, obtain configuration parameters and determine the role information of the arbitration node.

[0047] like Figure 2 The diagram illustrates the architecture of a dual-datacenter arbitration system according to the present invention. Here, az (Availability Zone) represents the availability zone where a datacenter is located, and each datacenter corresponds to a specific node. az1 and az2 can be considered the first node in datacenter 1 and the second node in datacenter 2, respectively. It should be noted that the arbitration node, the first node, and the second node can all be etcd server instances.

[0048] Specifically, this invention adds an observer role by modifying the etcd implementation method. When the dual-datacenter arbitration system starts, the etcd server instance of the arbitration node can obtain the corresponding configuration parameters to determine its own role information.

[0049] In some embodiments of the present invention, the role information includes node URL and node role;

[0050] The node role includes one of observer, leader, candidate, or follower, and the leader node's node role is the leader.

[0051] The role information can include the URL of the corresponding node and the node role. The node role can be one of the following: observer, leader, candidate, or follower. For example, the leader node is the first or second node with the role of leader.

[0052] In some embodiments of the present invention, obtaining configuration parameters and determining the role information of the arbitration node includes:

[0053] Sub-step 11: Obtain command-line arguments or configuration files.

[0054] When the dual-datacenter arbitration system starts up, command-line parameters or configuration files can be obtained.

[0055] Sub-step 12: By executing the command-line parameters or reading the configuration file, the node role of the arbitration node is determined as the observer.

[0056] After obtaining the command-line parameters or configuration file, the node role of the arbitration node can be determined by executing the command-line parameters or reading the configuration file.

[0057] Specifically, the node role of the etcd server instance of the arbitrator node can be determined as observer by passing the "--role observer" startup parameter (i.e., command-line parameter) or by reading the newly added "role:observer" item in the configuration file.

[0058] In some embodiments of the present invention, after obtaining the configuration parameters and determining the role information of the arbitration node, the method further includes:

[0059] Initialize a global read-only role variable and set the value of the global read-only role variable to the enumeration value corresponding to the observer.

[0060] Specifically, after determining the node role of the etcd server instance of the arbitration node, a global read-only role variable can be defined during the initialization of the etcd server instance of the arbitration node in the following way:

[0061] const role int = OBSERVER (OBSERVER is an enumeration value)

[0062] By defining an enumeration type `role` and setting the value of the global read-only role variable `role` to an enumeration value like `OBSERVER`, the node role of the etcd server instance of the arbitration node can be clearly defined through this global read-only role variable, ensuring that the node's role information is clear and consistent during system operation.

[0063] It's important to note that in programming, enumerations are typically used to define a fixed set of values ​​that can only take one of the predefined values ​​in the program. For example, when defining the day of the week, you can use the enumeration type `week`, whose values ​​include Monday, Tuesday, Wednesday, etc. This way, the variable can only take these predefined values, avoiding the use of magic numbers or string constants, making the code clearer and easier to maintain.

[0064] Step 102: The role information of the arbitration node is broadcast to the first node and the second node, and the role information of the first node and the second node are received.

[0065] After the etcd server instance of the arbitrator node determines its node role, it can broadcast the node role and node URL (i.e., role information) of the etcd server instance of the arbitrator node to the corresponding etcd server instances of the first and second nodes.

[0066] Meanwhile, the etcd server instances corresponding to the first and second nodes also broadcast the node URLs and roles (i.e. role information) of the etcd server instances corresponding to the first and second nodes to the etcd server instances of the arbitration node. The etcd server instances of the arbitration node can receive the role information of the etcd server instances of the first and second nodes.

[0067] Specifically, each node's etcd server instance can broadcast its own role information by calling the BroadcastRole() method. It can also start the ReceiveRoleNotification() method to receive role information sent by other nodes' etcd server instances. Each node's etcd instance can also record the mapping relationship between the node URLs and roles of other nodes' etcd server instances.

[0068] Step 103: Select a leader node from the first node and the second node using the role information of the first node and the role information of the second node.

[0069] During the election process in the dual-datacenter arbitration system, the etcd server instance of the arbitration node can obtain the node URLs of the first and second etcd server instances from their role information, and then send voting messages using these URLs.

[0070] In some embodiments of the present invention, selecting a leader node from the first node and the second node using the role information of the first node and the role information of the second node includes:

[0071] Sub-step 21: Receive voting request messages sent by the first node and the second node.

[0072] After the election process begins in the dual-datacenter arbitration system, the etcd server instance of the arbitration node can receive voting request messages from both the etcd server instances of the first and second nodes. It should be noted that at this time, the node roles of both the first and second etcd server instances are candidate nodes.

[0073] Sub-step 22: Send an agree vote message or a reject vote message to the first node and the second node.

[0074] After receiving voting request messages from the etcd server instances of the first node and the second node, the etcd server instance of the arbitration node can send voting messages to the etcd server instances of the first node and the second node respectively.

[0075] The voting message can be either a "yes" or "no" message.

[0076] Sub-step 23: Determine the leader node based on the sending status of the agreed vote message or the rejected vote message.

[0077] After the etcd server instance of the arbitration node sends an agree vote message or a reject vote message, the leader node can be determined based on the sending of the agree vote message or the reject vote message.

[0078] In some embodiments of the present invention, determining the leader node based on the sending of the consent vote message or the rejection vote message includes:

[0079] When the first node etcd server instance receives the "agree" voting message, the second node receives the "reject" voting message and determines that the first node is the leader node and the second node's node role is the follower.

[0080] If the first node receives the rejection vote message, the second node receives the approval vote message and determines that the second node is the leader node, and the first node's node role is the follower.

[0081] Specifically, when the first node's etcd server instance receives an "agree" vote message, the second node's etcd server instance will receive a "reject" vote message. This means the arbitrator node cast its vote for the first node. At this point, the first node can be determined as the leader node, and the second node's role is that of a follower, or simply a follower node. Simultaneously, the first node's etcd server instance can be changed from candidate to leader, and the second node's etcd server instance can be changed from candidate to follower.

[0082] If the first node's etcd server instance receives a rejection vote message, the second node's etcd server instance will receive an approval vote message. This means the arbitrator node has voted for the second node. At this point, the second node can be determined as the leader node, and the first node's role is that of a follower. Simultaneously, the second node's etcd server instance can be changed from candidate to leader, and the first node's etcd server instance can be changed from candidate to follower.

[0083] It's important to note that both the first and second nodes can participate in the voting. However, generally, they can only vote for themselves. Therefore, the arbitrator node's vote of approval determines the node that will become the leader. The arbitrator node's etcd server instance has the role of observer. Observer nodes only participate in the voting election and will not vote for themselves to become the leader. They will only vote for non-observer roles deployed within the two availability zones (i.e., the corresponding first or second node in the data center corresponding to the availability zone). In other words, the leader node can only appear among the first or second nodes in the two data centers.

[0084] In some embodiments of the present invention, it further includes:

[0085] Messages or operations related to the arbitration node are handled through a pre-defined observer state handling function.

[0086] An observer state handling function can be predefined to handle messages or operations related to the etcd server instance of the arbitration node.

[0087] Specifically, the arbitrator node corresponding to the observer role has special behaviors and responsibilities, so an independent state can be defined for it. In Raft, a new state named StateObserver can be added to identify the observer role. That is, a new state can be introduced into the Raft state machine to handle the logic of the observer role. A becomeObserver() handler function can be added to switch the state of the etcd server instance of the arbitrator node to StateObserver and perform the corresponding initialization operations.

[0088] In Raft, a global processing function called stepObserver() can be added in parallel, similar to stepCandidate (candidate state handling function), stepFollower (follower state handling function), and stepLeader (leader state handling function). This is a pre-defined observer state handling function used to process all observer-related messages and actions, that is, messages or operations related to the etcd server instance of the arbitrator node.

[0089] This ensures that the observer node, i.e., the arbitrator node's etcd server example, can correctly process messages from the leader node and does not participate in the leader election, but only votes.

[0090] Step 104: Based on the role information of the arbitration node, obtain the message permission list of the arbitration node, and filter the operation instruction messages of the leader node through the message permission list; wherein, the operation instruction messages include data copying operations and data update operations.

[0091] After the leader node is determined, the message allowable list of the arbitrator node can be obtained based on the node role of the etcd server instance of the arbitrator node. This list does not include data replication operations and data update operations. In other words, data replication operations and data update operations of the leader node will not be allowed to be sent to the arbitrator node. Thus, the message allowable list filters out data replication operations and data update operations of the leader node.

[0092] In practical applications, for each node's etcd server instance, the observer role can be added at the Transport layer, and the role attribute can be added to the peer (nodes in a dual-datacenter arbitration system) to distinguish between observer and non-observer roles.

[0093] If the role of the etcd server instance itself is equal to that of an observer, it means that the node role is leader, follower, or candidate. For peers with the role of observer, special handling is required when sending messages. Only messages such as MsgHup (election trigger message), MsgVote (vote request message), MsgVoteResp (response to vote request message), MsgHeartbeat (heartbeat message), MsgHeartbeatResp (heartbeat response message), MsgPreVote (pre-election message), and MsgPreVoteResp (response to pre-vote request message) (which is the message allowed list of the arbitrator node) can be sent to the peer with the node role of observer. In other words, messages such as Append (log replication message) and Snapshot (acceleration message) (i.e., data replication and data update operations of the leader node) are filtered out.

[0094] Meanwhile, the arbitration node will not actively initiate data synchronization requests, so data synchronization will only occur between the etcd server instances of the first and second nodes, that is, between the etcd server instances of the leader and follower roles.

[0095] In an embodiment of the present invention, in response to the startup of the dual-datacenter arbitration system, configuration parameters are obtained, the role information of the arbitration node is determined, and the role information of the arbitration node is broadcast to the first node and the second node. The role information of the first node and the role information of the second node are received. Based on the role information of the first node and the role information of the second node, a leader node is selected from the first node and the second node. According to the role information of the arbitration node, a message permission list of the arbitration node is obtained, and the operation instruction messages of the leader node are filtered through the message permission list. The operation instruction messages include data copying operations and data update operations. This realizes the newly added target role, allowing the arbitration node to only participate in voting for the leader but not to be elected as the leader, and it does not need to store and copy data, thus optimizing the leader election process and saving bandwidth and computing and storage resources.

[0096] Reference Figure 3 The diagram illustrates a flowchart of the election process in a dual-datacenter arbitration system according to some embodiments of the present invention, which may specifically include the following steps:

[0097] 1. The arbitration node confirms its role information and initializes it;

[0098] 2. The arbitration node sends its role to AZ1 (the data center corresponding to Zone 1, i.e., the first node) and AZ2 (the data center corresponding to Zone 2, i.e., the second node), and receives the returned ack (Acknowledgment) message, i.e., the confirmation message.

[0099] 3. The arbitration node receives the voting request messages from the first and second nodes;

[0100] 4. The arbitration node sends an agreement vote message to the first node and a rejection request message to the second node, thereby determining the first node's role as the leader and the second node's role as the follower.

[0101] 5. Change the role of the first node to leader, making it a leader node, and change the role of the second node to follower, making it a follower node;

[0102] 6. The leader node (first node) sends a data update message to the follower node (second node) and receives an ACK message returned by the follower node.

[0103] like Figure 4 The diagram illustrates the architecture of the dual-datacenter arbitration system after the election of the leader node.

[0104] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0105] Reference Figure 5 The diagram illustrates a structural schematic of a dual-datacenter arbitration system implementation device based on a distributed key-value repository, according to some embodiments of the present invention. The dual-datacenter arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different datacenters. Specifically, it may include the following modules:

[0106] The role information determination module 501 is used to obtain configuration parameters and determine the role information of the arbitration node in response to the startup of the dual-data center arbitration system.

[0107] The role information sending and receiving module 502 is used to send the role information of the arbitration node to the first node and the second node via broadcast, and to receive the role information of the first node and the role information of the second node.

[0108] Election module 503 is used to select a leader node from the first node and the second node based on the role information of the first node and the role information of the second node;

[0109] The message filtering module 504 is used to obtain the message permission list of the arbitration node based on the role information of the arbitration node, and filter the operation instruction messages of the leader node through the message permission list; wherein, the operation instruction messages include data copying operations and data update operations.

[0110] In one embodiment of the present invention,

[0111] The role information includes the node URL and the node role;

[0112] The node role includes one of observer, leader, candidate, or follower, and the leader node's node role is the leader.

[0113] In one embodiment of the present invention, the role information determination module 501 includes:

[0114] The configuration parameter retrieval submodule is used to retrieve command-line arguments or configuration files;

[0115] The role information determination submodule is used to determine the node role of the arbitration node as the observer by executing the command line parameters or reading the configuration file.

[0116] In one embodiment of the present invention, after obtaining the configuration parameters and determining the role information of the arbitration node, the method further includes:

[0117] The initialization module is used to initialize a global read-only role variable and set the value of the global read-only role variable to the enumeration value corresponding to the observer.

[0118] In one embodiment of the present invention, it further includes:

[0119] The message or operation processing module is used to process messages or operations related to the arbitration node through pre-defined observer state processing functions.

[0120] In one embodiment of the present invention, the election module 503 includes:

[0121] The voting request message receiving submodule is used to receive voting request messages sent by the first node and the second node;

[0122] The voting message sending submodule is used to send a vote-agreement message or a vote-rejection message to the first node and the second node;

[0123] The leader node determination submodule is used to determine the leader node based on the sending of the consent vote message or the rejection vote message.

[0124] In one embodiment of the present invention, the leader node determination submodule includes:

[0125] If the first node receives the "agree" vote message, the second node receives the "reject" vote message and determines that the first node is the leader node and the second node's node role is the follower.

[0126] If the first node receives the rejection vote message, the second node receives the approval vote message and determines that the second node is the leader node, and the first node's node role is the follower.

[0127] In an embodiment of the present invention, in response to the startup of the dual-datacenter arbitration system, configuration parameters are obtained, the role information of the arbitration node is determined, and the role information of the arbitration node is broadcast to the first node and the second node. The role information of the first node and the role information of the second node are received. Based on the role information of the first node and the role information of the second node, a leader node is selected from the first node and the second node. According to the role information of the arbitration node, a message permission list of the arbitration node is obtained, and the operation instruction messages of the leader node are filtered through the message permission list. The operation instruction messages include data copying operations and data update operations. This realizes the newly added target role, allowing the arbitration node to only participate in voting for the leader but not to be elected as the leader, and it does not need to store and copy data, thus optimizing the leader election process and saving bandwidth and computing and storage resources.

[0128] Some embodiments of the present invention also provide an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the method described above.

[0129] Some embodiments of the present invention also provide a computer-readable storage medium on which a computer program is stored, and which, when executed by a processor, implements the method described above.

[0130] Some embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the method described above.

[0131] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

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

[0133] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0134] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0135] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations 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, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0136] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0137] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0138] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.

[0139] Finally, 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 terminal device 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 terminal device. 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 terminal device that includes the aforementioned element.

[0140] The above provides a detailed description of the implementation method and apparatus for a dual-datacenter arbitration system based on a distributed key-value repository. Specific examples have been used to illustrate the principles and implementation methods of this invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.

Claims

1. A method for implementing a dual-datacenter arbitration system based on a distributed key-value repository, characterized in that, The dual-datacenter arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different datacenters. The method includes: In response to the startup of the dual-datacenter arbitration system, configuration parameters are obtained, and the role information of the arbitration node is determined. The role information of the arbitration node is broadcast to the first node and the second node, and the role information of the first node and the second node is received. A leader node is selected from the first node and the second node based on the role information of the first node and the role information of the second node. Based on the role information of the arbitration node, a message permission list for the arbitration node is obtained, and the operation instruction messages of the leader node are filtered through the message permission list; wherein, the operation instruction messages include data copying operations and data update operations.

2. The method according to claim 1, characterized in that, The role information includes the node URL and the node role; The node role includes one of observer, leader, candidate, or follower, and the leader node's node role is the leader.

3. The method according to claim 2, characterized in that, The process of obtaining configuration parameters and determining the role information of the arbitration node includes: Get command-line arguments or configuration files; The node role of the arbitration node is determined as the observer by executing the command-line parameters or reading the configuration file.

4. The method according to any one of claims 2-3, characterized in that, After obtaining the configuration parameters and determining the role information of the arbitration node, the process further includes: Initialize a global read-only role variable and set the value of the global read-only role variable to the enumeration value corresponding to the observer.

5. The method according to claim 3, characterized in that, Also includes: Messages or operations related to the arbitration node are handled through a pre-defined observer state handling function.

6. The method according to claim 2, characterized in that, The step of selecting a leader node from the first node and the second node using the role information of the first node and the second node includes: Receive voting request messages sent by the first node and the second node; Send an agree vote message or a reject vote message to the first node and the second node; The leader node is determined based on the sending of the agreed vote message or the rejected vote message.

7. The method according to claim 6, characterized in that, The step of determining the leader node based on the sending of the consent vote message or the rejection vote message includes: If the first node receives the "agree" vote message, the second node receives the "reject" vote message and determines that the first node is the leader node and the second node's node role is the follower. If the first node receives the rejection vote message, the second node receives the approval vote message and determines that the second node is the leader node, and the first node's node role is the follower.

8. A device for implementing a dual-datacenter arbitration system based on a distributed key-value repository, characterized in that, The dual-datacenter arbitration system includes an arbitration node, a first node, and a second node, wherein the first node and the second node are deployed in different datacenters. The device includes: The role information determination module is used to obtain configuration parameters and determine the role information of the arbitration node in response to the startup of the dual-data center arbitration system; The role information sending and receiving module is used to send the role information of the arbitration node to the first node and the second node via broadcast, and to receive the role information of the first node and the role information of the second node. The election module is used to select a leader node from the first node and the second node based on the role information of the first node and the role information of the second node; The message filtering module is used to obtain the message permission list of the arbitration node based on the role information of the arbitration node, and filter the operation instruction messages of the leader node through the message permission list; wherein, the operation instruction messages include data copying operations and data update operations.

9. An electronic device, characterized in that, The system includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When executed by the processor, the computer program implements the dual-datacenter arbitration system implementation method based on a distributed key-value store as described in any one of claims 1 to 7.

10. A readable storage medium, characterized in that, The readable storage medium stores a computer program, which, when executed by a processor, implements the dual-datacenter arbitration system implementation method based on a distributed key-value repository as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Raft distributed system leader election method, related equipment and system

    CN108616566A

  • Cluster fault processing method, system and device and storage medium

    CN115664915A