batchedpaxos

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: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PropertyHeaderSlot   = "Slot"
	PropertyHeaderBallot = "Ballot"
	PropertyExecute      = "Execute"
	PropertyInProgress   = "Inprogress"
)

Variables

This section is empty.

Functions

func NewPendingBatch

func NewPendingBatch() *pendingBatch

Types

type CommandBallot

type CommandBallot struct {
	Commands []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 {
	Ballot idservice.Ballot
	ID     idservice.ID          // from node id
	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
	Command []db.Command
	P3msg   P3
}

P2a accept message

func (P2a) String

func (m P2a) String() string

type P2b

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

P2b accepted message

func (P2b) String

func (m P2b) 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
	Commands []db.Command
}

func (*P3RecoverReply) String

func (m *P3RecoverReply) String() string

type P3RecoverRequest

type P3RecoverRequest struct {
	Ballot idservice.Ballot
	Slot   int
	// contains filtered or unexported fields
}

func (*P3RecoverRequest) String

func (m *P3RecoverRequest) String() string

type Paxos

type Paxos struct {
	node.Node

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

Paxos instance

func NewPaxos

func NewPaxos(n node.Node, options ...func(*Paxos)) *Paxos

NewPaxos creates new paxos instance

func (*Paxos) Ballot

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

Ballot returns current ballot

func (*Paxos) CleanupLog

func (p *Paxos) CleanupLog()

func (*Paxos) GetSafeLogCleanupMarker

func (p *Paxos) GetSafeLogCleanupMarker() int

func (*Paxos) HandleP1a

func (p *Paxos) HandleP1a(m P1a)

HandleP1a handles P1a message

func (*Paxos) HandleP1b

func (p *Paxos) HandleP1b(m P1b)

HandleP1b handles P1b message

func (*Paxos) HandleP2a

func (p *Paxos) HandleP2a(m P2a)

HandleP2a handles P2a message

func (*Paxos) HandleP2b

func (p *Paxos) HandleP2b(m P2b)

HandleP2b handles P2b message

func (*Paxos) HandleP3

func (p *Paxos) HandleP3(m P3)

HandleP3 handles phase 3 commit message

func (*Paxos) HandleP3RecoverReply

func (p *Paxos) HandleP3RecoverReply(m P3RecoverReply)

HandleP3RecoverReply handles slot recovery

func (*Paxos) HandleP3RecoverRequest

func (p *Paxos) HandleP3RecoverRequest(m P3RecoverRequest)

HandleP3RecoverRequest handles slot recovery request at leader

func (*Paxos) IsLeader

func (p *Paxos) IsLeader() bool

IsLeader indicates if this node is current leader

func (*Paxos) Leader

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

Leader returns leader idservice of the current ballot

func (*Paxos) P1a

func (p *Paxos) P1a()

P1a starts phase 1 prepare

func (*Paxos) P2a

func (p *Paxos) P2a(pendingBatch *pendingBatch)

P2a starts phase 2 accept

func (*Paxos) P3Sync

func (p *Paxos) P3Sync(tnow int64)

forceful sync of P3 messages if no progress was done in past 10 ms and no P3 msg was piggybacked

func (*Paxos) SetActive

func (p *Paxos) SetActive(active bool)

SetActive sets current paxos instance as active leader

func (*Paxos) SetBallot

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

SetBallot sets a new ballot number

func (*Paxos) UpdateLastExecuteByNode

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

type Replica

type Replica struct {
	node.Node

	*Paxos
	// contains filtered or unexported fields
}

Replica for one Paxos instance

func NewReplica

func NewReplica(id idservice.ID) *Replica

NewReplica generates new Paxos replica

func (*Replica) HandleRequest

func (r *Replica) HandleRequest(req net.Request, reply reply)

HandleQuorumRequest handles request and start phase 1 or phase 2

Jump to

Keyboard shortcuts

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