etcdserver: support Raft Pre-Vote

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-02-22 21:19:23 -08:00
parent 8aae8c1c9c
commit 78918848bd
3 changed files with 12 additions and 0 deletions

View File

@ -76,6 +76,9 @@ type ServerConfig struct {
InitialCorruptCheck bool
CorruptCheckTime time.Duration
// PreVote is true to enable Raft Pre-Vote.
PreVote bool
Debug bool
}

View File

@ -411,6 +411,7 @@ func startNode(cfg ServerConfig, cl *membership.RaftCluster, ids []types.ID) (id
MaxSizePerMsg: maxSizePerMsg,
MaxInflightMsgs: maxInflightMsgs,
CheckQuorum: true,
PreVote: cfg.PreVote,
}
n = raft.StartNode(c, peers)
@ -445,6 +446,7 @@ func restartNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types.ID, *member
MaxSizePerMsg: maxSizePerMsg,
MaxInflightMsgs: maxInflightMsgs,
CheckQuorum: true,
PreVote: cfg.PreVote,
}
n := raft.RestartNode(c)
@ -501,6 +503,7 @@ func restartAsStandaloneNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types
MaxSizePerMsg: maxSizePerMsg,
MaxInflightMsgs: maxInflightMsgs,
CheckQuorum: true,
PreVote: cfg.PreVote,
}
n := raft.RestartNode(c)
raftStatus = n.Status

View File

@ -258,6 +258,12 @@ type EtcdServer struct {
// NewServer creates a new EtcdServer from the supplied configuration. The
// configuration is considered static for the lifetime of the EtcdServer.
func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) {
if cfg.PreVote {
plog.Info("Raft Pre-Vote is enabled")
} else {
plog.Info("Raft Pre-Vote is disabled")
}
st := v2store.New(StoreClusterPrefix, StoreKeysPrefix)
var (