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 MockWaitLeaderEggs(rafts []*Raft, leadernums int) int
- func MockWaitMySQLPingTimeout()
- type Candidate
- type Follower
- type HARPC
- type Idle
- type Leader
- type Peer
- type Raft
- func MockRafts(log *xlog.Log, port int, count int) ([]string, []*Raft, func())
- func MockRaftsWithConfig(log *xlog.Log, conf *config.RaftConfig, port int, count int) ([]string, []*Raft, func())
- func MockRaftsWithLong(log *xlog.Log, port int, count int) ([]string, []*Raft, func())
- func NewRaft(id string, conf *config.RaftConfig, log *xlog.Log, mysql *mysql.Mysql) *Raft
- 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) GetEpochID() uint64
- func (s *Raft) GetHARPC() *HARPC
- 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) RemovePeer(connStr string) error
- func (s *Raft) ResetRaftMysqlStatus()
- func (s *Raft) SetRaftMysqlStatus(rms model.RAFTMYSQL_STATUS)
- 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) DisablePurgeBinlog(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) 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 )
Variables ¶
This section is empty.
Functions ¶
func MockGetClient ¶
MockGetClient mock.
func MockSetMysqlHandler ¶ added in v1.0.5
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 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) HATryToLeader ¶
func (h *HARPC) HATryToLeader(req *model.HARPCRequest, rsp *model.HARPCResponse) error
HATryToLeader rpc.
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 // contains filtered or unexported fields }
Raft tuple.
func MockRaftsWithConfig ¶
func MockRaftsWithConfig(log *xlog.Log, conf *config.RaftConfig, port int, count int) ([]string, []*Raft, func())
MockRaftsWithConfig mock.
func MockRaftsWithLong ¶
MockRaftsWithLong mock.
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) 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) SetSkipPurgeBinlog ¶
SetSkipPurgeBinlog used to set purge binlog or not.
type RaftRPC ¶
type RaftRPC struct {
// contains filtered or unexported fields
}
RaftRPC tuple.
func (*RaftRPC) DisablePurgeBinlog ¶
func (r *RaftRPC) DisablePurgeBinlog(req *model.RaftStatusRPCRequest, rsp *model.RaftStatusRPCResponse) error
DisablePurgeBinlog 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) 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.