5: Leader Elections

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/21

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

22 Terms

1
New cards

Synchronous Network Model

A directed graph, often representing nodes in a system, where messages can be exchanged with each other.

  • G = (V, E) with a fixed alphabet M

2
New cards

Distance

The shortest path between two nodes is the length of the shortest path between those two nodes.

3
New cards

Distance of a Graph

The maximum distance between any two nodes.

4
New cards

Synchronous Network Model - Node Contents

  • statesi - set of states

  • starti - starting states

  • messagesi - message generation function

  • transi - state transition functions mapping statesi and vectors

5
New cards

Synchronous Network Model - Edge (Channel) Contents

Either nothing, or a single message M.

6
New cards

Synchronous Network Model - Process

  • All processes (nodes) begin in arbitrary start states

  • All channels (edges) are empty

  • Processes repeat continually:

    • Apply message-generation function to current state to generate a message sent to all outgoing neighbours

    • Messages are put in appropriate channels

    • Apply the state-transformation function to the current state and incoming messages to obtain the new state

    • Remove all messages from channels

7
New cards

Synchronous Network Model - What Can Go Wrong

  • Link failure - channel loses messages

  • Stop failure - process stops mid-execution

  • Byzantine failure - an arbitrary message/state is generated that doesn’t follow the rules of the message generation/state transition functions

8
New cards

Leader Election Problem

The problem of choosing a “leader” node in a network and holding the data necessary for the function.

9
New cards

Leader Election Problem - Variations

  • Unidirectional/Bidirectional Path

  • Number of processes may be known or unknown

  • Non-leaders may be required to acknowledge that they are not the leader

  • Unique IDs may be consecutive integers or not

  • Unique IDs may admit operations other than comparison

10
New cards

Leader Election Problem - Safety Specification

There is at most one leader in the system.

11
New cards

Leader Election Problem - Liveness Specification

Sometimes, there exists a leader (either no correct node exists or a node is eventually elected leader).

12
New cards

Leader Election Problem - Problem Modelling (Token Ring Network)

  • Network is a connected ring

  • Nodes have consecutive unique identifiers

  • Synchronous model

  • Each node knows its right and left neighbour

  • Addition is module-N

  • Unidirectional ring of unknown size

13
New cards

LCR Algorithm

A solution to the Leader Election Problem by electing the process with the highest identifier.

14
New cards

LCR Algorithm - Process

  • A process notes a lack of leader and initiates an election.

  • It creates an election message and passes it to neighbouring nodes.

  • When a node receives an election message:

    • The receiving UID is checked against its own UID

    • If the receiving UID is bigger, then the node continues passing the original election message

    • If the receiving UID is smaller, then the node passes on a new election message containing its own UID.

    • The node becomes a candidate.

  • If a candidate receives an election message:

    • If the UID is its own, then it is the leader.

    • If its UID is not its own, then the election is lost.

  • The leader sends a message across the network informing other nodes it has been elected.

15
New cards

LCR Algorithm - Liveness

A process imax outputs a leader by the end of round n.

  • We know umax is the initial value of uimax by initialisation

  • The values of u never change and are distinct by assumption

  • imax has the largest u value by definition of imax

  • Suffices to show that after n rounds, statusimax = leader

16
New cards

LCR Algorithm - Safety

No process other than imax ever outputs the value leader.

  • All other processes always have the status = unknown

17
New cards

LCR Algorithm - Message Complexity

O(n2)

  • n rounds before a leader is elected

18
New cards

LCR Algorithm - Halting

All processes never reach a halting state.

  • We can add a “finished” message initiated by the elected leader.

  • 2n rounds before a leader is elected, but message complexity remains the same

19
New cards

Hirschberg and Sinclair (HS)

A solution to the Leader Election Problem by sending a token in each direction before returning back to the origin node.

<p>A solution to the Leader Election Problem by sending a token in each direction before returning back to the origin node.</p>
20
New cards

Hirschberg and Sinclair (HS) - Process

  • Each process, i, operates in a phase, e.g. 0, 1, 2…

  • In phase l, process i sends out “tokens” containing its identifier ui in each direction

  • Intended to have travel distance 2l before returning back to i

  • If both tokens make it back safely, then process i continues the following phase

  • Whilst ui is proceeding in the outbound direction, each other process j on the path compares ui with its own identifier, uj

    • If ui < uj then j discards the token and returns its own

    • If ui > uj then j relays ui

    • If ui = uj, then process j has received its own identifier before the token has turned around, so it elects itself leader

21
New cards

Hirschberg and Sinclair (HS) - Message Format

<id, direction, hop_count>

22
New cards

Hirschberg and Sinclair (HS) - Individual State Contents

  • u, a unique ID

  • send+, containing either an element of M or null

  • send-, containing either an element of M or null

  • status, {unknown, leader} (initially unknown)

  • phase, non-negative int (initially zero)

  • message generation function:

    • Send the current value of send to process i + 1

    • Send the current value of send to process i - 1

<ul><li><p>u, a unique ID</p></li><li><p>send+, containing either an element of M or null</p></li><li><p>send-, containing either an element of M or null</p></li><li><p>status, {unknown, leader} (initially unknown)</p></li><li><p>phase, non-negative int (initially zero)</p></li><li><p>message generation function:</p><ul><li><p>Send the current value of send to process i + 1</p></li><li><p>Send the current value of send to process i - 1</p></li></ul></li></ul><p></p>