paxos

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2015 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptedValue

type AcceptedValue struct {
	Value  Value
	Origin ProposalID
}

An AcceptedValue is a Value plus the proposal which originated that Value. The origin is not essential, but makes comparing AcceptedValues easy even if comparing Values is not.

type GossipState

type GossipState map[NodeID]NodeClaims

type Node

type Node struct {
	// contains filtered or unexported fields
}

func NewNode

func NewNode(name router.PeerName, uid router.PeerUID, quorum uint) *Node

func (*Node) Consensus

func (node *Node) Consensus() (bool, AcceptedValue)

Has a consensus been reached, based on the known claims of other nodes?

func (*Node) GossipState

func (node *Node) GossipState() GossipState

func (*Node) Propose

func (node *Node) Propose()

Initiate a new proposal, i.e. the Paxos "Prepare" step. This is simply a matter of gossipping a new proposal that supersedes all others.

func (*Node) Think

func (node *Node) Think() bool

The heart of the consensus algorithm. Return true if we have changed our claims.

func (*Node) Update

func (node *Node) Update(from GossipState) bool

Update this node's information about what other nodes know. Returns true if we learned something new.

type NodeClaims

type NodeClaims struct {
	// The node promises not to accept a proposal with id less
	// than this.
	Promise ProposalID

	// The accepted proposal, if valid
	Accepted    ProposalID
	AcceptedVal AcceptedValue
}

type NodeID

type NodeID struct {
	Name router.PeerName
	UID  router.PeerUID
}

The node identifier. The use of the UID here is important: Paxos acceptors must not forget their promises, so it's important that a node does not restart and lose its Paxos state but claim to have the same ID.

type ProposalID

type ProposalID struct {
	// round numbers begin at 1.  round 0 indicates an
	// uninitialized ProposalID, and precedes all other ProposalIDs
	Round    uint
	Proposer NodeID
}

note all fields exported in structs so we can Gob them

type Status added in v1.1.0

type Status struct {
	KnownNodes int
	Quorum     uint
}

func NewStatus added in v1.1.0

func NewStatus(node *Node) *Status

type Value

type Value []router.PeerName

For seeding IPAM, the value we want consensus on is a set of peer names

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL