replica

package
v0.0.0-...-3e9ff4f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEND_ALL = iota
	SEND_QUORUM
	SEND_EXCEPT
	SEND_SINGLE
	SEND_CLIENT
	SEND_ALL_EXCEPT
)
View Source
const ARGS_NUM = defs.CHAN_BUFFER_SIZE

Variables

View Source
var (
	NO_QUORUM_FILE = errors.New("Quorum file is not provided")
	THREE_QUARTERS = errors.New("ThreeQuarters")
)

Functions

func Leader

func Leader(ballot int32, repNum int) int32

func NextBallotOf

func NextBallotOf(rid, oldBallot int32, repNum int) int32

Types

type Majority

type Majority int

func NewMajorityOf

func NewMajorityOf(N int) Majority

func (Majority) Contains

func (m Majority) Contains(int32) bool

func (Majority) Size

func (m Majority) Size() int

type MsgSet

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

func NewMsgSet

func NewMsgSet(q QuorumI, accept func(interface{}, interface{}) bool,
	freeMsg func(interface{}), handler MsgSetHandler) *MsgSet

func (*MsgSet) Add

func (ms *MsgSet) Add(repId int32, isLeader bool, msg interface{}) bool

func (*MsgSet) Free

func (ms *MsgSet) Free()

func (*MsgSet) ReinitMsgSet

func (ms *MsgSet) ReinitMsgSet(q QuorumI, accept func(interface{}, interface{}) bool,
	freeMsg func(interface{}), handler MsgSetHandler) *MsgSet

type MsgSetHandler

type MsgSetHandler func(interface{}, []interface{})

type Quorum

type Quorum map[int32]struct{}

func NewQuorum

func NewQuorum(size int) Quorum

func NewQuorumOfAll

func NewQuorumOfAll(size int) Quorum

func NewQuorumsFromFile

func NewQuorumsFromFile(qfile string, r *Replica) ([]Quorum, []int32, error)

func (Quorum) Contains

func (q Quorum) Contains(repId int32) bool

func (Quorum) Equals

func (q1 Quorum) Equals(q2 Quorum) bool

func (Quorum) Size

func (q Quorum) Size() int

type QuorumI

type QuorumI interface {
	Size() int
	Contains(int32) bool
}

type QuorumSet

type QuorumSet map[int32]QuorumsOfLeader

func NewQuorumSet

func NewQuorumSet(quorumSize, repNum int) QuorumSet

func (QuorumSet) AQ

func (qs QuorumSet) AQ(ballot int32) Quorum

func (QuorumSet) BallotOf

func (qs QuorumSet) BallotOf(leader int32, q Quorum) int32

type QuorumSystem

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

func NewQuorumSystem

func NewQuorumSystem(quorumSize int, r *Replica, qfile string) (*QuorumSystem, error)

func (QuorumSystem) AQ

func (sys QuorumSystem) AQ(ballot int32) Quorum

func (*QuorumSystem) BallotAt

func (sys *QuorumSystem) BallotAt(i int) int32

func (*QuorumSystem) BallotOf

func (sys *QuorumSystem) BallotOf(leader int32, q Quorum) int32

func (*QuorumSystem) SameHigher

func (sys *QuorumSystem) SameHigher(sameAs, higherThan int32) int32

type QuorumsOfLeader

type QuorumsOfLeader map[int32]Quorum

func NewQuorumsOfLeader

func NewQuorumsOfLeader() QuorumsOfLeader

type Replica

type Replica struct {
	*dlog.Logger

	M     sync.Mutex
	N     int
	F     int
	Id    int32
	Alias string

	PeerAddrList       []string
	Peers              []net.Conn
	PeerReaders        []*bufio.Reader
	PeerWriters        []*bufio.Writer
	ClientWriters      map[int32]*bufio.Writer
	Config             *config.Config
	Alive              []bool
	PreferredPeerOrder []int32

	State       *state.State
	RPC         *fastrpc.Table
	StableStore *os.File
	Stats       *defs.Stats
	Shutdown    bool
	Listener    net.Listener
	ProposeChan chan *defs.GPropose
	BeaconChan  chan *defs.GBeacon

	Thrifty bool
	Exec    bool
	LRead   bool
	Dreply  bool
	Beacon  bool
	Durable bool

	Ewma      []float64
	Latencies []int64

	Dt *defs.LatencyTable
}

func New

func New(alias string, id, f int, addrs []string, thrifty, exec, lread bool, config *config.Config, l *dlog.Logger) *Replica

func (*Replica) BeTheLeader

func (r *Replica) BeTheLeader(args *defs.BeTheLeaderArgs, reply *defs.BeTheLeaderReply) error

func (*Replica) ComputeClosestPeers

func (r *Replica) ComputeClosestPeers() []float64

func (*Replica) ConnectToPeers

func (r *Replica) ConnectToPeers()

func (*Replica) ConnectToPeersNoListeners

func (r *Replica) ConnectToPeersNoListeners()

func (*Replica) FastQuorumSize

func (r *Replica) FastQuorumSize() int

func (*Replica) Ping

func (r *Replica) Ping(args *defs.PingArgs, reply *defs.PingReply) error

func (*Replica) ReadQuorumSize

func (r *Replica) ReadQuorumSize() int

func (*Replica) ReplyBeacon

func (r *Replica) ReplyBeacon(beacon *defs.GBeacon)

func (*Replica) ReplyProposeTS

func (r *Replica) ReplyProposeTS(reply *defs.ProposeReplyTS, w *bufio.Writer, lock *sync.Mutex)

func (*Replica) SendBeacon

func (r *Replica) SendBeacon(peerId int32)

func (*Replica) SendClientMsg

func (r *Replica) SendClientMsg(id int32, code uint8, msg fastrpc.Serializable)

func (*Replica) SendMsg

func (r *Replica) SendMsg(peerId int32, code uint8, msg fastrpc.Serializable)

func (*Replica) SendMsgNoFlush

func (r *Replica) SendMsgNoFlush(peerId int32, code uint8, msg fastrpc.Serializable)

func (*Replica) SlowQuorumSize

func (r *Replica) SlowQuorumSize() int

func (*Replica) UpdatePreferredPeerOrder

func (r *Replica) UpdatePreferredPeerOrder(quorum []int32)

func (*Replica) WaitForClientConnections

func (r *Replica) WaitForClientConnections()

func (*Replica) WriteQuorumSize

func (r *Replica) WriteQuorumSize() int

type SendArg

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

type SendType

type SendType int32

type Sender

type Sender chan SendArg

func NewSender

func NewSender(r *Replica) Sender

func (Sender) SendExcept

func (s Sender) SendExcept(q Quorum, msg fastrpc.Serializable, rpc uint8)

func (Sender) SendExceptAndFree

func (s Sender) SendExceptAndFree(q Quorum,
	msg fastrpc.Serializable, rpc uint8, free func())

func (Sender) SendTo

func (s Sender) SendTo(id int32, msg fastrpc.Serializable, rpc uint8)

func (Sender) SendToAll

func (s Sender) SendToAll(msg fastrpc.Serializable, rpc uint8)

func (Sender) SendToAllAndFree

func (s Sender) SendToAllAndFree(msg fastrpc.Serializable,
	rpc uint8, free func())

func (Sender) SendToAllExecpt

func (s Sender) SendToAllExecpt(except int32, msg fastrpc.Serializable, rpc uint8)

func (Sender) SendToAllExecptAndFree

func (s Sender) SendToAllExecptAndFree(except int32, msg fastrpc.Serializable, rpc uint8, free func())

func (Sender) SendToAndFree

func (s Sender) SendToAndFree(id int32,
	msg fastrpc.Serializable, rpc uint8, free func())

func (Sender) SendToClient

func (s Sender) SendToClient(cid int32, msg fastrpc.Serializable, rpc uint8)

func (Sender) SendToClientAndFree

func (s Sender) SendToClientAndFree(cid int32,
	msg fastrpc.Serializable, rpc uint8, free func())

func (Sender) SendToQuorum

func (s Sender) SendToQuorum(q Quorum, msg fastrpc.Serializable, rpc uint8)

func (Sender) SendToQuorumAndFree

func (s Sender) SendToQuorumAndFree(q Quorum,
	msg fastrpc.Serializable, rpc uint8, free func())

type ThreeQuarters

type ThreeQuarters int

func NewThreeQuartersOf

func NewThreeQuartersOf(N int) ThreeQuarters

func (ThreeQuarters) Contains

func (m ThreeQuarters) Contains(int32) bool

func (ThreeQuarters) Size

func (m ThreeQuarters) Size() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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