week 4, election algorithms

36
Election Algorithms CS-4513 D-term 2008 1 Election Algorithms CS-4513 Distributed Computing Sy stems (Slides include materials from Operating System Concepts , 7 th ed., by Silbershatz, Galvin, & Gagne,  Distributed Systems: Principles & Paradigms , 2 nd ed. By Tanenbaum and Van Steen, and  Modern Operating Systems , 2 nd ed., by Tanenbaum)

Upload: pradeepgupta43

Post on 10-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 1/36

Election AlgorithmsCS-4513 D-term 2008 1

Election Algorithms

CS-4513

Distributed Computing Systems(Slides include materials from Operating System Concepts, 7th ed., by Silbershatz, Galvin, & Gagne,

 Distributed Systems: Principles & Paradigms, 2nd ed. By Tanenbaum and Van Steen, and Modern Operating Systems, 2nd ed., by Tanenbaum)

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 2/36

Election AlgorithmsCS-4513 D-term 2008 2

Election Algorithms

If we are using one process as a coordinator for a shared resource «

«how do we select that one process?

Often, there is no owner or master that is

automatically considered as coordinator  E.g., Grapevine, there is no owner for a Registry

By contrast:±DNS has a master for every domain

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 3/36

Election AlgorithmsCS-4513 D-term 2008 3

Solution ± an E lection

All nodes currently involved get together to

choose a coordinator 

If the coordinator crashes or becomesisolated, elect a new coordinator 

If a previously crashed or isolated node,

comes on line, a new election may have to

 be held.

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 4/36

Election AlgorithmsCS-4513 D-term 2008 4

Election Algorithms

Wired systems

Bully algorithm

Ring algorithm

Wireless systems

Very large-scale systems

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 5/36

Election AlgorithmsCS-4513 D-term 2008 5

Bully Algorithm

Assume

All processes know about each other 

Processes numbered uniquely

Suppose P notices no coordinator 

Sends election message to all higher numbered

 processes

If none response, P takes over as coordinator 

If any responds, P yields

«

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 6/36

Election AlgorithmsCS-4513 D-term 2008 6

Bully Algorithm (continued)

«

Suppose Q receives election message Replies OK to sender, saying it will take over 

Sends a new election message to higher numbered

 processes

Repeat until only one process left standing

Announces victory by sending message saying thatit is coordinator 

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 7/36

Election AlgorithmsCS-4513 D-term 2008 7

Bully Algorithm (continued)

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 8/36

Election AlgorithmsCS-4513 D-term 2008 8

Bully Algorithm (continued)

«

Suppose R comes back on line Sends a new election message to higher numbered

 processes

Repeat until only one process left standing Announces victory by sending message saying that

it is coordinator (if not already coordinator) Existing (lower numbered) coordinator yields

Hence the term ³bully´

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 9/36

Election AlgorithmsCS-4513 D-term 2008 9

Alternative ± Ring Algorithm

All processed organized in ring

Independent of process number 

Suppose P notices no coordinator  Sends election message to successor with own

 process number in body of message

(If successor is down, skip to next process, etc.)

Suppose Q receives an election message Adds own process number to list in message body

«

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 10/36

Election AlgorithmsCS-4513 D-term 2008 10

Alternative ± Ring Algorithm

Suppose P receives an election messagewith its own process number in body

Changes message to coordinator message,

 preserving body All processes recognize highest numbered process

as new coordinator 

If multiple messages circulate «

«they will all contain same list of processes(eventually)

If process comes back on-line Calls new election

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 11/36

Election AlgorithmsCS-4513 D-term 2008 11

Ring Algorithm (continued)

Coordinator=6

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 12/36

Election AlgorithmsCS-4513 D-term 2008 12

Ring Algorithm (continued)

[2,3,4][2,3,4,5]

[5,6,0,1]

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 13/36

Election AlgorithmsCS-4513 D-term 2008 13

Ring Algorithm (continued)

[5,6,0,1,2,3,4][2,3,4,5]

[1,2,3,4,5,6,0]

[5,6,0,1,2]

[2,3,4,5,6]

[2,3,4,5,6,0]

[5,6,0,1,2,3]

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 14/36

Election AlgorithmsCS-4513 D-term 2008 14

Ring Algorithm (concluded)

[5,6,0,1,2,3,4]

[1,2,3,4,5,6,0]

Coordinator=6

Coordinator=6

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 15/36

Election AlgorithmsCS-4513 D-term 2008 15

Ring Algorithm (concluded)

Suppose P receives an election messagewith its own process number in body

Changes message to coordinator message,

 preserving body All processes recognize highest numbered process

as new coordinator 

If multiple messages circulate «

«they will all contain same list of processes(eventually)

If process comes back on-line Calls new election

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 16/36

Election AlgorithmsCS-4513 D-term 2008 16

Questions?

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 17/36

Election AlgorithmsCS-4513 D-term 2008 17

Wireless Networks

Different assumptions

Message passing is less reliable

Network topology constantly changing

Expanding ring of broadcast

Election messages

Decision rules for when to yield

Not very well developed.

Topic of current research

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 18/36

Election AlgorithmsCS-4513 D-term 2008 18

Very Large Scale Networks

Sometimes more than one node should be

selected

Nodes organized as peers and super-peers Elections held within each peer group

Super-peers coordinate among themselves

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 19/36

Election AlgorithmsCS-4513 D-term 2008 19

Reading Assignment

Tanenbaum & van Steen (2nd ed.)

§6.5.2 ± Elections in Wireless Systems

§6.5.3 ± Elections in Large Scale Systems

Potential topics for quiz or test!

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 20/36

Election AlgorithmsCS-4513 D-term 2008 20

Digression

Domain Name Service

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 21/36

Election AlgorithmsCS-4513 D-term 2008 21

DNS

Maps names of the form

www.cs.wpi.edu

to IP addresses Maps aliases to names

Maps mailbox requests to names

Maps service requests to names Maps IP addresses to names

I.e., reverse mapping

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 22/36

Election AlgorithmsCS-4513 D-term 2008 22

DNS Naming Hierarchy

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 23/36

Election AlgorithmsCS-4513 D-term 2008 23

Resolving DNS names to IP addresses

Two approaches:± 

 ± Iterative

 ± Recursive

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 24/36

Election AlgorithmsCS-4513 D-term 2008 24

Iterative Resolution of Names

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 25/36

Election AlgorithmsCS-4513 D-term 2008 25

Recursive Resolution of Names

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 26/36

Election AlgorithmsCS-4513 D-term 2008 26

DNS Domain Registry Database

Text file containing records

Each record is {Name, Type, value(s)}

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 27/36

Election AlgorithmsCS-4513 D-term 2008 27

Example

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 28/36

Election AlgorithmsCS-4513 D-term 2008 28

DNS Implementation

One master copy per domain or subdomain Edited manually by system administrator 

 ± Using text editor or GUI tool

Multiple slave copies Automatically copied / updated periodically from

master 

Stored in file on slave server, reloaded up restart

Caching in DNS clients Lots and lots of caching

Entries include TTL (time-to-live) specification

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 29/36

Election AlgorithmsCS-4513 D-term 2008 29

Implementation in Linux/Unix

B IND ² Berkeley Internet Name Domain

http://www.bind9.net/ 

named  ² the Name Daemon

 ± Implements local DNS service

 ± Multiple databases

Primary or  secondary

Secondary database points back to primary

 ± Pointer to ³higher level´ service

For resolving names not in own database

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 30/36

Election AlgorithmsCS-4513 D-term 2008 30

Example

Want to find www.cs.wpi.edu

My DNS contacts DNS server 68.87.71.226  A Comcast server specified in my DHCP lease

Comcast DNS service Almost certainly has root (global) domain in cache

Probably has many .edu entries in cache (very large)

Possibly has .wpi.edu in cache (many local users)

May have .cs.wpi.edu Consults cache or official server for IP address

nslookup

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 31/36

Election AlgorithmsCS-4513 D-term 2008 31

Example (continued)

C:\> nslookup cs.wpi.edu

Server: cns.chelmsfdrdc2.ma.boston.comcast.net

 Address: 68.87.71.226

 Non-authoritative answer:

 Name: cs.wpi.edu

 Address: 130.215.28.181

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 32/36

Election AlgorithmsCS-4513 D-term 2008 32

Some Special Cases

Google

Yahoo

MSN Need to distribute names geographically

Need to distribute different addresses for same name

Special handling of replicated databases

More (perhaps) later in term

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 33/36

Election AlgorithmsCS-4513 D-term 2008 33

 Naming Privacy

Problem:± corporations need to have own

domains www.merl.com

Some public hosts ± mail server, web server, etc.

Does not want to expose names of internal

hosts to outside world

E.g., proprietary stuff 

But wants to make them visible internally hotspur.merl.com

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 34/36

Election AlgorithmsCS-4513 D-term 2008 34

Solution

Two name services for same domain name! Internal

External

External ² 

visible to Internet (DMZ) Database contains only a few names

Points to other internet DNS¶s for resolution of internet names

Internal ² seen only by internal hosts

Database contains all internal names Points to external version for resolution of internet names

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 35/36

Election AlgorithmsCS-4513 D-term 2008 35

Result

Internal names can be resolved internally,

not externally hotspur.merl.com

Internal names and IP addresses are

invisible on Internet

All external names can be resolved

internally Two levels of indirection

8/8/2019 Week 4, Election Algorithms

http://slidepdf.com/reader/full/week-4-election-algorithms 36/36

Election AlgorithmsCS-4513 D-term 2008 36

Questions?