Skip to content

Instantly share code, notes, and snippets.

@colinrymer
Last active December 16, 2015 05:59
Show Gist options
  • Save colinrymer/5388324 to your computer and use it in GitHub Desktop.
Save colinrymer/5388324 to your computer and use it in GitHub Desktop.

Given

  • Nodes can be either master or slaves.
  • Nodes register themselves with their master on creation.

Scenario 1 - No existing nodes

Some number (n) of new nodes are created. Nodes have no knowledge of other nodes being created and elect themselves as master. This results in n master nodes and 0 slave nodes.

Nodes must learn of other nodes existence and elect a single master with the rest becoming slaves. Any information stored in former master nodes must be migrated to the new master.

Scenario 2 - Existing master and slaves

Some number of nodes exist with one elected as master and the rest serving as slaves.

a - Non-master candidate

A new node is introduced that does not qualify to become a new master.

b - Master candidate

A new node is introduced that meets the criteria to become the master. For example, if the master is chosen by the lowest ip address among the nodes, then the new node would be one with an address lower than all existing nodes.

Scenario 3 - Existing slaves with no master

Some number of nodes exist that are slaves to a master than is no longer functioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment