paxos

package
v0.0.0-...-6ec47af Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fate

type Fate int

px.Status() return values, indicating whether an agreement has been decided, or Paxos has not yet reached agreement, or it was agreed but forgotten (i.e. < Min()).

const (
	Decided   Fate = iota + 1
	Pending        // not yet decided.
	Forgotten      // decided but forgotten.
)

type Paxos

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

func Make

func Make(peers []string, me int, rpcs *rpc.Server) *Paxos

the application wants to create a paxos peer. the ports of all the paxos peers (including this one) are in peers[]. this servers port is peers[me].

func (*Paxos) Done

func (px *Paxos) Done(seq int)

the application on this machine is done with all instances <= seq.

see the comments for Min() for more explanation.

func (*Paxos) Kill

func (px *Paxos) Kill()

tell the peer to shut itself down. for testing. please do not change these two functions.

func (*Paxos) Max

func (px *Paxos) Max() int

the application wants to know the highest instance sequence known to this peer.

func (*Paxos) Min

func (px *Paxos) Min() int

Min() should return one more than the minimum among z_i, where z_i is the highest number ever passed to Done() on peer i. A peers z_i is -1 if it has never called Done().

Paxos is required to have forgotten all information about any instances it knows that are < Min(). The point is to free up memory in long-running Paxos-based servers.

Paxos peers need to exchange their highest Done() arguments in order to implement Min(). These exchanges can be piggybacked on ordinary Paxos agreement protocol messages, so it is OK if one peers Min does not reflect another Peers Done() until after the next instance is agreed to.

The fact that Min() is defined as a minimum over *all* Paxos peers means that Min() cannot increase until all peers have been heard from. So if a peer is dead or unreachable, other peers Min()s will not increase even if all reachable peers call Done. The reason for this is that when the unreachable peer comes back to life, it will need to catch up on instances that it missed -- the other peers therefor cannot forget these instances.

func (*Paxos) Start

func (px *Paxos) Start(seq int, v interface{})

the application wants paxos to start agreement on instance seq, with proposed value v. Start() returns right away; the application will call Status() to find out if/when agreement is reached.

func (*Paxos) Status

func (px *Paxos) Status(seq int) (Fate, interface{})

the application wants to know whether this peer thinks an instance has been decided, and if so what the agreed value is. Status() should just inspect the local peer state; it should not contact other Paxos peers.

Jump to

Keyboard shortcuts

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