Documentation
¶
Index ¶
- Constants
- func MockGetClient(t *testing.T, svrConn string) (*xrpc.Client, func())
- func MockSetMysqlHandler(raft *Raft, h mysql.MysqlHandler)
- func MockStateTransition(raft *Raft, state State)
- func MockWaitHeartBeatTimeout()
- func MockWaitLeaderEggs(rafts []*Raft, leadernums int) int
- func MockWaitMySQLPingTimeout()
- type Candidate
- type Follower
- type HARPC
- func (h *HARPC) HADisable(req *model.HARPCRequest, rsp *model.HARPCResponse) error
- func (h *HARPC) HAEnable(req *model.HARPCRequest, rsp *model.HARPCResponse) error
- func (h *HARPC) HASetLearner(req *model.HARPCRequest, rsp *model.HARPCResponse) error
- func (h *HARPC) HATryToLeader(req *model.HARPCRequest, rsp *model.HARPCResponse) error
- type Idle
- type Invalid
- type Leader
- type Learner
- type Peer
- type Raft
- func MockRafts(log *xlog.Log, port int, count int, idleStart int) ([]string, []*Raft, func())
- func MockRaftsWithConfig(log *xlog.Log, conf *config.RaftConfig, port int, count int, idleStart int) ([]string, []*Raft, func())
- func MockRaftsWithLong(log *xlog.Log, port int, count int, idleStart int) ([]string, []*Raft, func())
- func NewRaft(id string, conf *config.RaftConfig, log *xlog.Log, mysql *mysql.Mysql) *Raft
- func (r *Raft) AddIdlePeer(connStr string) error
- func (r *Raft) AddPeer(connStr string) error
- func (r *Raft) DEBUG(format string, v ...interface{})
- func (r *Raft) ERROR(format string, v ...interface{})
- func (r *Raft) GetAllPeers() []string
- func (r *Raft) GetEpochID() uint64
- func (s *Raft) GetHARPC() *HARPC
- func (r *Raft) GetIdlePeers() []string
- func (r *Raft) GetLeader() string
- func (r *Raft) GetMembers() int
- func (r *Raft) GetPeers() []string
- func (r *Raft) GetQuorums() int
- func (r *Raft) GetRaftRPC() *RaftRPC
- func (r *Raft) GetState() State
- func (r *Raft) GetVewiID() uint64
- func (r *Raft) INFO(format string, v ...interface{})
- func (s *Raft) IncCandidateDegrades()
- func (s *Raft) IncCandidatePromotes()
- func (s *Raft) IncLeaderDegrades()
- func (s *Raft) IncLeaderGetHeartbeatRequests()
- func (s *Raft) IncLeaderGetVoteRequests()
- func (s *Raft) IncLeaderPromotes()
- func (s *Raft) IncLeaderPurgeBinlogFails()
- func (s *Raft) IncLeaderPurgeBinlogs()
- func (s *Raft) IncLessHeartbeatAcks()
- func (r *Raft) PANIC(format string, v ...interface{})
- func (r *Raft) RemoveIdlePeer(connStr string) error
- func (r *Raft) RemovePeer(connStr string) error
- func (s *Raft) ResetRaftMysqlStatus()
- func (s *Raft) SetRaftMysqlStatus(rms model.RAFTMYSQL_STATUS)
- func (r *Raft) SetSkipCheckSemiSync(v bool)
- func (r *Raft) SetSkipPurgeBinlog(v bool)
- func (r *Raft) Start() error
- func (r *Raft) Stop() error
- func (r *Raft) WARNING(format string, v ...interface{})
- type RaftMeta
- type RaftRPC
- func (r *RaftRPC) DisableCheckSemiSync(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
- func (r *RaftRPC) DisablePurgeBinlog(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
- func (r *RaftRPC) EnableCheckSemiSync(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
- func (r *RaftRPC) EnablePurgeBinlog(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
- func (r *RaftRPC) Heartbeat(req *model.RaftRPCRequest, rsp *model.RaftRPCResponse) error
- func (r *RaftRPC) Ping(req *model.RaftRPCRequest, rsp *model.RaftRPCResponse) error
- func (r *RaftRPC) RequestVote(req *model.RaftRPCRequest, rsp *model.RaftRPCResponse) error
- func (r *RaftRPC) Status(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
- type State
Constants ¶
const ( // MsgNone type. MsgNone = iota + 1 // MsgRaftHeartbeat type. MsgRaftHeartbeat // MsgRaftRequestVote type. MsgRaftRequestVote // MsgRaftPing type. MsgRaftPing )
Variables ¶
This section is empty.
Functions ¶
func MockGetClient ¶
MockGetClient mock.
func MockSetMysqlHandler ¶
func MockSetMysqlHandler(raft *Raft, h mysql.MysqlHandler)
MockSetMysqlHandler used to set mysql repl hander for test.
func MockStateTransition ¶
MockStateTransition use to transfer the raft.state to state.
func MockWaitHeartBeatTimeout ¶
func MockWaitHeartBeatTimeout()
MockWaitHeartBeatTimeout used to wait mysql ping timeout.
func MockWaitLeaderEggs ¶
MockWaitLeaderEggs mock. wait the leader eggs when leadernums >0 if leadernums == 0, we just want to sleep for a heartbeat broadcast
func MockWaitMySQLPingTimeout ¶
func MockWaitMySQLPingTimeout()
MockWaitMySQLPingTimeout used to wait mysql ping timeout.
Types ¶
type Candidate ¶
type Candidate struct { *Raft // contains filtered or unexported fields }
Candidate tuple.
func (*Candidate) Loop ¶
func (r *Candidate) Loop()
Loop used to start the loop of the state machine. -------------------------------------- State Machine --------------------------------------
get majority votes
State1. CANDIDATE ------------------------> LEADER
higher viewid/new leader
State2. CANDIDATE ------------------------> FOLLOWER
timeout
State3. CANDIDATE ------------------------> CANDIDATE
type Follower ¶
type Follower struct { *Raft // Whether the 'change to master' is success or not when the new leader eggs. ChangeToMasterError bool // contains filtered or unexported fields }
Follower tuple.
type HARPC ¶
type HARPC struct {
// contains filtered or unexported fields
}
HARPC tuple.
func (*HARPC) HADisable ¶
func (h *HARPC) HADisable(req *model.HARPCRequest, rsp *model.HARPCResponse) error
HADisable rpc.
func (*HARPC) HAEnable ¶
func (h *HARPC) HAEnable(req *model.HARPCRequest, rsp *model.HARPCResponse) error
HAEnable rpc.
func (*HARPC) HASetLearner ¶
func (h *HARPC) HASetLearner(req *model.HARPCRequest, rsp *model.HARPCResponse) error
HASetLearner rpc.
func (*HARPC) HATryToLeader ¶
func (h *HARPC) HATryToLeader(req *model.HARPCRequest, rsp *model.HARPCResponse) error
HATryToLeader rpc.
type Invalid ¶
type Invalid struct { *Raft // contains filtered or unexported fields }
Invalid tuple.
type Learner ¶
type Learner struct { *Raft // contains filtered or unexported fields }
Learner tuple.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer tuple.
type Raft ¶
type Raft struct { L *Leader C *Candidate F *Follower I *Idle IV *Invalid LN *Learner // contains filtered or unexported fields }
Raft tuple.
func MockRaftsWithConfig ¶
func MockRaftsWithConfig(log *xlog.Log, conf *config.RaftConfig, port int, count int, idleStart int) ([]string, []*Raft, func())
MockRaftsWithConfig mock.
func MockRaftsWithLong ¶
func MockRaftsWithLong(log *xlog.Log, port int, count int, idleStart int) ([]string, []*Raft, func())
MockRaftsWithLong mock.
func (*Raft) AddIdlePeer ¶
AddIdlePeer used to add a idle peer to peers.
func (*Raft) GetAllPeers ¶
GetAllPeers returns all peers string.
func (*Raft) GetIdlePeers ¶
GetIdlePeers returns idle peers string.
func (*Raft) IncCandidateDegrades ¶
func (s *Raft) IncCandidateDegrades()
IncCandidateDegrades counter.
func (*Raft) IncCandidatePromotes ¶
func (s *Raft) IncCandidatePromotes()
IncCandidatePromotes counter.
func (*Raft) IncLeaderGetHeartbeatRequests ¶
func (s *Raft) IncLeaderGetHeartbeatRequests()
IncLeaderGetHeartbeatRequests counter.
func (*Raft) IncLeaderGetVoteRequests ¶
func (s *Raft) IncLeaderGetVoteRequests()
IncLeaderGetVoteRequests counter.
func (*Raft) IncLeaderPurgeBinlogFails ¶
func (s *Raft) IncLeaderPurgeBinlogFails()
IncLeaderPurgeBinlogFails counter.
func (*Raft) IncLeaderPurgeBinlogs ¶
func (s *Raft) IncLeaderPurgeBinlogs()
IncLeaderPurgeBinlogs counter.
func (*Raft) IncLessHeartbeatAcks ¶
func (s *Raft) IncLessHeartbeatAcks()
IncLessHeartbeatAcks counter.
func (*Raft) RemoveIdlePeer ¶
RemoveIdlePeer used to remove a idle peer from peers.
func (*Raft) RemovePeer ¶
RemovePeer used to remove a peer from peers.
func (*Raft) ResetRaftMysqlStatus ¶
func (s *Raft) ResetRaftMysqlStatus()
ResetRaftMysqlStatus used to reset mysql status.
func (*Raft) SetRaftMysqlStatus ¶
func (s *Raft) SetRaftMysqlStatus(rms model.RAFTMYSQL_STATUS)
SetRaftMysqlStatus used to set mysql status.
func (*Raft) SetSkipCheckSemiSync ¶
SetSkipCheckSemiSync used to set check semi-sync or not.
func (*Raft) SetSkipPurgeBinlog ¶
SetSkipPurgeBinlog used to set purge binlog or not.
type RaftMeta ¶
type RaftMeta struct { ViewID uint64 EpochID uint64 // The Peers(endpoint) expect SuperIDLE Peers []string // The SuperIDLE Peers(endpoint) IdlePeers []string }
RaftMeta tuple.
type RaftRPC ¶
type RaftRPC struct {
// contains filtered or unexported fields
}
RaftRPC tuple.
func (*RaftRPC) DisableCheckSemiSync ¶
func (r *RaftRPC) DisableCheckSemiSync(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
DisableCheckSemiSync rpc.
func (*RaftRPC) DisablePurgeBinlog ¶
func (r *RaftRPC) DisablePurgeBinlog(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
DisablePurgeBinlog rpc.
func (*RaftRPC) EnableCheckSemiSync ¶
func (r *RaftRPC) EnableCheckSemiSync(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
EnableCheckSemiSync rpc.
func (*RaftRPC) EnablePurgeBinlog ¶
func (r *RaftRPC) EnablePurgeBinlog(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
EnablePurgeBinlog rpc.
func (*RaftRPC) Heartbeat ¶
func (r *RaftRPC) Heartbeat(req *model.RaftRPCRequest, rsp *model.RaftRPCResponse) error
Heartbeat rpc.
func (*RaftRPC) Ping ¶
func (r *RaftRPC) Ping(req *model.RaftRPCRequest, rsp *model.RaftRPCResponse) error
Ping rpc. send MsgRaftPing
func (*RaftRPC) RequestVote ¶
func (r *RaftRPC) RequestVote(req *model.RaftRPCRequest, rsp *model.RaftRPCResponse) error
RequestVote rpc.
func (*RaftRPC) Status ¶
func (r *RaftRPC) Status(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
Status rpc.
type State ¶
type State int
State enum.
const ( // FOLLOWER state. FOLLOWER State = 1 << iota // CANDIDATE state. CANDIDATE // LEADER state. LEADER // IDLE state. // neither process heartbeat nor voterequest(return ErrorInvalidRequest) IDLE // INVALID state. // neither process heartbeat nor voterequest(return ErrorInvalidRequest) INVALID // LEARNER state. LEARNER // STOPPED state. STOPPED )