paxos

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2016 License: Apache-2.0 Imports: 1 Imported by: 11

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 mesh.PeerName, uid mesh.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) IsElector added in v1.5.0

func (node *Node) IsElector() bool

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) SetQuorum added in v1.5.0

func (node *Node) SetQuorum(quorum uint)

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 mesh.PeerName
	UID  mesh.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 Observer added in v1.5.0

type Observer struct {
}

func (*Observer) Consensus added in v1.5.0

func (observer *Observer) Consensus() (bool, AcceptedValue)

func (*Observer) GossipState added in v1.5.0

func (observer *Observer) GossipState() GossipState

func (*Observer) IsElector added in v1.5.0

func (observer *Observer) IsElector() bool

func (*Observer) Propose added in v1.5.0

func (observer *Observer) Propose()

func (*Observer) SetQuorum added in v1.5.0

func (observer *Observer) SetQuorum(uint)

func (*Observer) Think added in v1.5.0

func (observer *Observer) Think() bool

func (*Observer) Update added in v1.5.0

func (observer *Observer) Update(from GossipState) bool

type Participant added in v1.5.0

type Participant interface {
	GossipState() GossipState
	Update(from GossipState) bool
	SetQuorum(uint)
	Propose()
	Think() bool
	Consensus() (bool, AcceptedValue)
	IsElector() bool
}

func NewObserver added in v1.5.0

func NewObserver() Participant

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 {
	Elector    bool
	KnownNodes int
	Quorum     uint
}

func NewStatus added in v1.1.0

func NewStatus(node *Node) *Status

type Value

type Value []mesh.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