pigpaxos

package
v0.0.0-...-6206b6d Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const GrayTimeoutMultiplier = 1000
View Source
const TickerDuration = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type BalSlot

type BalSlot struct {
	idservice.Ballot
	// contains filtered or unexported fields
}

type CommandBallot

type CommandBallot struct {
	Command db.Command
	Ballot  idservice.Ballot
}

CommandBallot combines each command with its ballot number

func (CommandBallot) String

func (cb CommandBallot) String() string

type P1a

type P1a struct {
	Ballot idservice.Ballot
}

P1a prepare message

func (P1a) String

func (m P1a) String() string

type P1b

type P1b struct {
	ID     idservice.ID // from node id
	Ballot idservice.Ballot
	Log    map[int]CommandBallot // uncommitted logs
}

P1b promise message

func (P1b) String

func (m P1b) String() string

type P2a

type P2a struct {
	Ballot        idservice.Ballot
	Slot          int
	GlobalExecute int
	Command       db.Command
	P3msg         P3
}

P2a accept message

func (P2a) String

func (m P2a) String() string

type P2b

type P2b struct {
	ID     []idservice.ID // from node id
	Ballot idservice.Ballot
	Slot   int
}

P2b accepted message

func (P2b) String

func (m P2b) String() string

type P2bAggregated

type P2bAggregated struct {
	MissingIDs       []idservice.ID // node ids not collected by relay
	RelayID          idservice.ID
	RelayLastExecute int
	Ballot           idservice.Ballot
	Slot             int
}

P2b accepted message

func (P2bAggregated) String

func (m P2bAggregated) String() string

type P3

type P3 struct {
	Ballot idservice.Ballot
	Slot   []int
}

P3 commit message

func (P3) String

func (m P3) String() string

type P3RecoverReply

type P3RecoverReply struct {
	Ballot  idservice.Ballot
	Slot    int
	Command db.Command
}

func (P3RecoverReply) String

func (m P3RecoverReply) String() string

type P3RecoverRequest

type P3RecoverRequest struct {
	Ballot idservice.Ballot
	Slot   int
	NodeId idservice.ID
}

func (P3RecoverRequest) String

func (m P3RecoverRequest) String() string

type PeerGroup

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

func (*PeerGroup) GetRandomNodeId

func (pg *PeerGroup) GetRandomNodeId(excludeId idservice.ID, gray map[idservice.ID]time.Time) idservice.ID

func (PeerGroup) String

func (pg PeerGroup) String() string

type PigPaxos

type PigPaxos struct {
	node.Node

	// Quorums
	Q1              func(*quorum.Quorum) bool
	Q2              func(*quorum.Quorum) bool
	ReplyWhenCommit bool
	// contains filtered or unexported fields
}

Paxos instance

func NewPigPaxos

func NewPigPaxos(n node.Node, options ...func(*PigPaxos)) *PigPaxos

NewPaxos creates new paxos instance

func (*PigPaxos) Ballot

func (p *PigPaxos) Ballot() idservice.Ballot

Ballot returns current ballot

func (*PigPaxos) CheckTimeout

func (p *PigPaxos) CheckTimeout(timeout int64)

func (*PigPaxos) CleanupLog

func (p *PigPaxos) CleanupLog()

func (*PigPaxos) GetSafeLogCleanupMarker

func (p *PigPaxos) GetSafeLogCleanupMarker() int

func (*PigPaxos) HandleP1a

func (p *PigPaxos) HandleP1a(m P1a, reply idservice.ID)

HandleP1a handles P1a message

func (*PigPaxos) HandleP1b

func (p *PigPaxos) HandleP1b(m P1b)

HandleP1b handles P1b message

func (*PigPaxos) HandleP2a

func (p *PigPaxos) HandleP2a(m P2a, reply idservice.ID)

HandleP2a handles P2a message

func (*PigPaxos) HandleP2b

func (p *PigPaxos) HandleP2b(msgSlot int, msgBallot idservice.Ballot, votedIds []idservice.ID)

HandleP2b handles P2b message

func (*PigPaxos) HandleP3

func (p *PigPaxos) HandleP3(m P3)

HandleP3 handles phase 3 commit message

func (*PigPaxos) HandleP3RecoverReply

func (p *PigPaxos) HandleP3RecoverReply(m P3RecoverReply)

HandleP3RecoverReply handles slot recovery

func (*PigPaxos) HandleP3RecoverRequest

func (p *PigPaxos) HandleP3RecoverRequest(m P3RecoverRequest)

HandleP3RecoverRequest handles slot recovery request at leader

func (*PigPaxos) HandleRequest

func (p *PigPaxos) HandleRequest(r net.Request, reply reply)

HandleRequest handles request and start phase 1 or phase 2

func (*PigPaxos) IsLeader

func (p *PigPaxos) IsLeader() bool

IsLeader indicates if this node is current leader

func (*PigPaxos) Leader

func (p *PigPaxos) Leader() idservice.ID

Leader returns leader id of the current ballot

func (*PigPaxos) P1a

func (p *PigPaxos) P1a()

P1a starts phase 1 prepare

func (*PigPaxos) P2a

func (p *PigPaxos) P2a(r *net.Request, reply reply)

P2a starts phase 2 accept

func (*PigPaxos) RetryP1a

func (p *PigPaxos) RetryP1a()

func (*PigPaxos) RetryP2a

func (p *PigPaxos) RetryP2a(slot int, e *entry)

func (*PigPaxos) SetActive

func (p *PigPaxos) SetActive(active bool)

SetActive sets current paxos instance as active leader

func (*PigPaxos) SetBallot

func (p *PigPaxos) SetBallot(b idservice.Ballot)

SetBallot sets a new ballot number

func (*PigPaxos) UpdateLastExecuteByNode

func (p *PigPaxos) UpdateLastExecuteByNode(id idservice.ID, lastExecute int)

type RelayToLeader

type RelayToLeader struct {
	BalSlot
	// contains filtered or unexported fields
}

type Replica

type Replica struct {
	node.Node
	*PigPaxos

	NodeIdsToGroup map[idservice.ID]int

	// crash suspects
	GrayNodes map[idservice.ID]time.Time

	sync.RWMutex
	GrayLock sync.RWMutex
	// contains filtered or unexported fields
}

Replica for one PigPaxos instance

func NewReplica

func NewReplica(id idservice.ID) *Replica

NewReplica generates new Paxos replica

func (*Replica) Broadcast

func (r *Replica) Broadcast(m interface{})

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Messaging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Overrides Broadcast in node

func (*Replica) BroadcastToPeerGroup

func (r *Replica) BroadcastToPeerGroup(pg *PeerGroup, originalSourceToExclude idservice.ID, m RoutedMsg)

special broadcast for messages within the peer group

func (*Replica) Send

func (r *Replica) Send(to idservice.ID, m interface{}) error

overrides Send. Handles the errors by marking them to the gray list

type RoutedMsg

type RoutedMsg struct {
	Hops      []idservice.ID
	IsForward bool
	Progress  uint8
	Payload   interface{}
}

func (*RoutedMsg) GetLastProgressHop

func (m *RoutedMsg) GetLastProgressHop() idservice.ID

func (*RoutedMsg) GetPreviousProgressHop

func (m *RoutedMsg) GetPreviousProgressHop() idservice.ID

func (RoutedMsg) String

func (m RoutedMsg) String() string

Jump to

Keyboard shortcuts

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