wpaxos

package
v0.0.0-...-2ee7648 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NumZones total number of sites
	NumZones int
	// NumNodes total number of nodes
	NumNodes int
	// NumLocalNodes number of nodes per site
	NumLocalNodes int
	// F number of zone failures
	F int
	// QuorumType name of the quorums
	QuorumType string
)
View Source
var (
	ErrTXPreempted = errors.New("TX was preempted before issuing a lease")
)
View Source
var (
	Migration_majority float64
)
View Source
var (
	NANOSECONDS_PER_SECOND = int64(1000000000)
)

Functions

func LeaderID

func LeaderID(ballot int) ids.ID

LeaderID return the node id from ballot number

func NewStat

func NewStat() *keystat

func NextBallot

func NextBallot(ballot int, id ids.ID) int

NextBallot generates next ballot number given current ballot bumber and node id

Types

type Accept

type Accept struct {
	Ballot    Ballot
	Slot      int
	EpochSlot int
	Command   kv_store.Command
	// contains filtered or unexported fields
}

Accept phase 2a

func (Accept) String

func (a Accept) String() string

type AcceptTX

type AcceptTX struct {
	TxID     ids.TXID
	LeaderID ids.ID
	P2as     []Accept
}

Accept phase 2a for TX

func (AcceptTX) String

func (a AcceptTX) String() string

type Accepted

type Accepted struct {
	Table  string
	Key    kv_store.Key
	Ballot Ballot
	ID     ids.ID // from node id
	Slot   int
}

Accepted phase 2b

func (Accepted) String

func (a Accepted) String() string

type AcceptedTX

type AcceptedTX struct {
	TxID ids.TXID
	P2bs []Accepted
}

Accepted phase 2b

func (AcceptedTX) String

func (a AcceptedTX) String() string

type Ballot

type Ballot uint64

func NewBallot

func NewBallot(n int, id ids.ID) Ballot

NewBallot generates ballot number in format <n, zone, node>

func (Ballot) ID

func (b Ballot) ID() ids.ID

func (Ballot) N

func (b Ballot) N() int

func (*Ballot) Next

func (b *Ballot) Next(id ids.ID)

func (Ballot) String

func (b Ballot) String() string

type CommandBallot

type CommandBallot struct {
	Command   kv_store.Command
	Ballot    Ballot
	Executed  bool
	Committed bool
	HasTx     bool
	Tx        fleetdb.Transaction
}

func (CommandBallot) String

func (cb CommandBallot) String() string

type Commit

type Commit struct {
	Slot    int
	Command kv_store.Command
}

Commit phase 3

func (Commit) String

func (c Commit) String() string

type CommitTX

type CommitTX struct {
	ids.TXID
	P3s []Commit
}

Commit phase 3

func (CommitTX) String

func (c CommitTX) String() string

type Exec

type Exec struct {
	Slot      int
	EpochSlot int
	Command   kv_store.Command
}

Commit phase 3 - outside Q2

func (Exec) String

func (e Exec) String() string

type GossipBalance

type GossipBalance struct {
	Items int64
}

func (GossipBalance) String

func (gb GossipBalance) String() string

type LeaderChange

type LeaderChange struct {
	Key    kv_store.Key
	Table  string
	To     ids.ID
	From   ids.ID
	Ballot Ballot
}

LeaderChange switch leader

func (LeaderChange) String

func (l LeaderChange) String() string

type Paxos

type Paxos struct {
	fleetdb.Node

	Table *string
	Key   kv_store.Key

	Active bool // Active leader
	Try    int  //Try Number for P1a

	Token chan bool
	// contains filtered or unexported fields
}

Paxos instance

func NewPaxos

func NewPaxos(n fleetdb.Node, key kv_store.Key, table *string) *Paxos

NewPaxos creates new paxos instance

func (*Paxos) AddRequest

func (p *Paxos) AddRequest(req fleetdb.Request)

func (*Paxos) Ballot

func (p *Paxos) Ballot() Ballot

ballot returns current ballot

func (*Paxos) Exec

func (p *Paxos) Exec()

func (*Paxos) ExecTXCmd

func (p *Paxos) ExecTXCmd() kv_store.Value

func (*Paxos) GetAccessToken

func (p *Paxos) GetAccessToken() bool

func (*Paxos) HandleP1a

func (p *Paxos) HandleP1a(m Prepare)

func (*Paxos) HandleP1b

func (p *Paxos) HandleP1b(m Promise)

HandleP1b handles p1b message

func (*Paxos) HandleP2a

func (p *Paxos) HandleP2a(m Accept)

func (*Paxos) HandleP2b

func (p *Paxos) HandleP2b(m Accepted) bool

func (*Paxos) HandleP2bTX

func (p *Paxos) HandleP2bTX(m Accepted) int

func (*Paxos) HandleP3

func (p *Paxos) HandleP3(m Commit)

func (*Paxos) HandleRequest

func (p *Paxos) HandleRequest(r fleetdb.Request)

HandleRequest handles request and start phase 1 or phase 2

func (*Paxos) HasTXLease

func (p *Paxos) HasTXLease(txtime int64) bool

func (*Paxos) IsLeader

func (p *Paxos) IsLeader() bool

IsLeader indicates if this node is current leader

func (*Paxos) Leader

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

Leader returns leader id of the current ballot

func (*Paxos) P1a

func (p *Paxos) P1a()

P1a starts phase 1 prepare

func (*Paxos) P1aNoBallotIncrease

func (p *Paxos) P1aNoBallotIncrease()

P1a starts phase 1 prepare

func (*Paxos) P1aRetry

func (p *Paxos) P1aRetry(try int)

func (*Paxos) P1aTX

func (p *Paxos) P1aTX(t int64)

P1a starts phase 1 prepare

func (*Paxos) P2a

func (p *Paxos) P2a(r *fleetdb.Request)

P2a starts phase 2 accept

func (*Paxos) P2aFillSlot

func (p *Paxos) P2aFillSlot(cmd kv_store.Command, req *fleetdb.Request, tx *fleetdb.Transaction)

func (*Paxos) ProcessP2a

func (p *Paxos) ProcessP2a(m Accept, tx *fleetdb.Transaction)

func (*Paxos) ReleaseAccessToken

func (p *Paxos) ReleaseAccessToken()

func (*Paxos) SlotNOOP

func (p *Paxos) SlotNOOP(slot int)

func (*Paxos) SlotNum

func (p *Paxos) SlotNum() int

SlotNum returns current ballot

type Prepare

type Prepare struct {
	Key    kv_store.Key
	Table  string
	Ballot Ballot

	Try int
	// contains filtered or unexported fields
}

Prepare phase 1a

func (Prepare) String

func (p Prepare) String() string

type Promise

type Promise struct {
	Key    kv_store.Key
	Table  string
	Ballot Ballot
	ID     ids.ID // from node id
	LPF    bool   //Lease Promise Failure
	Try    int
	Log    map[int]CommandBallot // log since last execute (includes last execute)
}

Promise phase 1b

func (Promise) String

func (p Promise) String() string

type Quorum

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

func NewQuorum

func NewQuorum() *Quorum

func (*Quorum) ACK

func (q *Quorum) ACK(id ids.ID)

func (*Quorum) ADD

func (q *Quorum) ADD()

func (*Quorum) AllZones

func (q *Quorum) AllZones() bool

func (*Quorum) FGridQ1

func (q *Quorum) FGridQ1() bool

func (*Quorum) FGridQ2

func (q *Quorum) FGridQ2() bool

func (*Quorum) FastPath

func (q *Quorum) FastPath() bool

func (*Quorum) FastQuorum

func (q *Quorum) FastQuorum() bool

func (*Quorum) GridColumn

func (q *Quorum) GridColumn() bool

func (*Quorum) GridRow

func (q *Quorum) GridRow() bool

func (*Quorum) Majority

func (q *Quorum) Majority() bool

func (*Quorum) NACK

func (q *Quorum) NACK(id ids.ID)

func (*Quorum) Q1

func (q *Quorum) Q1() bool

func (*Quorum) Q2

func (q *Quorum) Q2() bool

func (*Quorum) Reset

func (q *Quorum) Reset()

func (*Quorum) Size

func (q *Quorum) Size() int

func (*Quorum) ZoneMajority

func (q *Quorum) ZoneMajority() bool

type Replica

type Replica struct {
	fleetdb.Node

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewReplica

func NewReplica() *Replica

func (*Replica) CountKeys

func (r *Replica) CountKeys() int

func (*Replica) ExecTx

func (r *Replica) ExecTx(tx *fleetdb.Transaction)

func (*Replica) GetPaxos

func (r *Replica) GetPaxos(key kv_store.Key, table string) *Paxos

func (*Replica) GetPaxosByCmd

func (r *Replica) GetPaxosByCmd(cmd kv_store.Command) *Paxos

func (*Replica) GetTX

func (r *Replica) GetTX(txid ids.TXID) *fleetdb.Transaction

func (*Replica) GetTable

func (r *Replica) GetTable(tableName string) *Table

func (*Replica) HandlePrepare

func (r *Replica) HandlePrepare(m Prepare)

WPaxos

func (*Replica) HandleRequest

func (r *Replica) HandleRequest(m fleetdb.Request)

Request

func (*Replica) HandleTransaction

func (r *Replica) HandleTransaction(m fleetdb.Transaction)

---------------------------------------------------------------------- * * Transactions * * ---------------------------------------------------------------------

type Table

type Table struct {
	TableName *string
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTable

func NewTable(table string) *Table

func (*Table) CountKeys

func (t *Table) CountKeys() int

func (*Table) FindLeastUsedKey

func (t *Table) FindLeastUsedKey() kv_store.Key

func (*Table) GetPaxos

func (t *Table) GetPaxos(key kv_store.Key) *Paxos

func (*Table) HitKey

func (t *Table) HitKey(key kv_store.Key, clientID ids.ID, timestamp int64) ids.ID

func (*Table) Init

func (t *Table) Init(key kv_store.Key, r *Replica)

func (*Table) InitStat

func (t *Table) InitStat(key kv_store.Key)

func (*Table) MarkKeyEvicting

func (t *Table) MarkKeyEvicting(k kv_store.Key)

func (*Table) RemoveStats

func (t *Table) RemoveStats(key kv_store.Key)

Jump to

Keyboard shortcuts

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