Skip to content

Commit

Permalink
cli: rebuildme logical modify
Browse files Browse the repository at this point in the history
idle and invalid nodes will not be bestone node
  • Loading branch information
TCeason authored and BohuTANG committed Jul 15, 2019
1 parent df24ca0 commit 90590e5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/cli/callx/callx.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,32 @@ func GetRaftState(endpoint string) (string, []string, error) {
return rsp.State, rsp.GetNodes(), nil
}

func IsNodeIdleOrInvalid(node string) (bool, error) {
cli, cleanup, err := GetClient(node)
if err != nil {
log.Warning("%s", err)
return false, err
}
defer cleanup()

method := model.RPCNodes
req := model.NewNodeRPCRequest()
rsp := model.NewNodeRPCResponse(model.OK)
if err := cli.Call(method, req, rsp); err != nil {
return false, err
}

if rsp.RetCode != model.OK {
return false, err
}

if rsp.State == raft.IDLE.String() || rsp.State == raft.INVALID.String() {
return true, nil
}

return false, nil
}

func GetClusterLeader(self string) (string, error) {
nodes, err := GetNodes(self)
if err != nil {
Expand Down Expand Up @@ -132,6 +158,15 @@ func FindBestoneForBackup(self string) (string, error) {

for _, node := range nodes {
if node != leader {
isIorIV, err := IsNodeIdleOrInvalid(node)
if err != nil {
log.Warning("%s", err)
continue
}

if isIorIV {
continue
}
if rsp, err := GetMysqlStatusRPC(node); err == nil {
GTID := rsp.GTID
if GTID.Slave_SQL_Running && GTID.Slave_IO_Running {
Expand Down

0 comments on commit 90590e5

Please sign in to comment.