pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
election_internal.h File Reference

Functions for conducting elections. More...

#include <stdbool.h>
#include <glib.h>
#include <libxml/tree.h>
#include <crm/common/ipc.h>
#include <crm/cluster.h>
Include dependency graph for election_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  election_result {
  election_start = 0 , election_in_progress , election_lost , election_won ,
  election_error
}
 

Functions

void election_reset (pcmk_cluster_t *cluster)
 
void election_init (pcmk_cluster_t *cluster, void(*cb)(pcmk_cluster_t *))
 
void election_timeout_set_period (pcmk_cluster_t *cluster, guint period_ms)
 
void election_timeout_stop (pcmk_cluster_t *cluster)
 
void election_vote (pcmk_cluster_t *cluster)
 
bool election_check (pcmk_cluster_t *cluster)
 
void election_remove (pcmk_cluster_t *cluster, const char *uname)
 
enum election_result election_state (const pcmk_cluster_t *cluster)
 
enum election_result election_count_vote (pcmk_cluster_t *cluster, const xmlNode *message, bool can_win)
 
void election_clear_dampening (pcmk_cluster_t *cluster)
 

Detailed Description

Functions for conducting elections.

An election is useful for a daemon that runs on all nodes but needs any one instance to perform a special role.

Elections are closely tied to the cluster peer cache. Peers in the cache that are active members are eligible to vote. Elections are named for logging purposes, but only one election may exist at any time, so typically an election would be created at daemon start-up and freed at shutdown.

Pacemaker's election procedure has been heavily adapted from the Invitation Algorithm variant of the Garcia-Molina Bully Algorithm:

https://en.wikipedia.org/wiki/Bully_algorithm

Elections are conducted via cluster messages. There are two types of messages: a "vote" is a declaration of the voting node's candidacy, and is always broadcast; a "no-vote" is a concession by the responding node, and is always a reply to the preferred node's vote. (These correspond to "invite" and "accept" in the traditional algorithm.)

A vote together with any no-vote replies to it is considered an election round. Rounds are numbered with a simple counter unique to each node (this would be the group number in the traditional algorithm). Concurrent election rounds are possible.

An election round is started when any node broadcasts a vote. When a node receives another node's vote, it compares itself against the sending node according to certain metrics, and either starts a new round (if it prefers itself) or replies to the other node with a no-vote (if it prefers that node).

If a node receives no-votes from all other active nodes, it declares itself the winner. The library API does not notify other nodes of this; callers must implement that if desired.

Definition in file election_internal.h.

Enumeration Type Documentation

◆ election_result

Enumerator
election_start 
election_in_progress 
election_lost 
election_won 
election_error 

Definition at line 65 of file election_internal.h.

Function Documentation

◆ election_check()

bool election_check ( pcmk_cluster_t * cluster)

Definition at line 344 of file election.c.

◆ election_clear_dampening()

void election_clear_dampening ( pcmk_cluster_t * cluster)

Definition at line 734 of file election.c.

◆ election_count_vote()

enum election_result election_count_vote ( pcmk_cluster_t * cluster,
const xmlNode * message,
bool can_win )

Definition at line 524 of file election.c.

◆ election_init()

void election_init ( pcmk_cluster_t * cluster,
void(* cb )(pcmk_cluster_t *) )

Definition at line 92 of file election.c.

◆ election_remove()

void election_remove ( pcmk_cluster_t * cluster,
const char * uname )

Definition at line 118 of file election.c.

◆ election_reset()

void election_reset ( pcmk_cluster_t * cluster)

Definition at line 134 of file election.c.

◆ election_state()

enum election_result election_state ( const pcmk_cluster_t * cluster)

Definition at line 67 of file election.c.

◆ election_timeout_set_period()

void election_timeout_set_period ( pcmk_cluster_t * cluster,
guint period_ms )

Definition at line 195 of file election.c.

◆ election_timeout_stop()

void election_timeout_stop ( pcmk_cluster_t * cluster)

Definition at line 180 of file election.c.

◆ election_vote()

void election_vote ( pcmk_cluster_t * cluster)

Definition at line 278 of file election.c.