|
@@ -265,7 +265,7 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
|
|
|
storage: NewStorage(w, ss),
|
|
storage: NewStorage(w, ss),
|
|
|
stats: sstats,
|
|
stats: sstats,
|
|
|
lstats: lstats,
|
|
lstats: lstats,
|
|
|
- Ticker: time.Tick(100 * time.Millisecond),
|
|
|
|
|
|
|
+ Ticker: time.Tick(time.Duration(cfg.TickMs) * time.Millisecond),
|
|
|
SyncTicker: time.Tick(500 * time.Millisecond),
|
|
SyncTicker: time.Tick(500 * time.Millisecond),
|
|
|
snapCount: cfg.SnapCount,
|
|
snapCount: cfg.SnapCount,
|
|
|
reqIDGen: idutil.NewGenerator(uint8(id), time.Now()),
|
|
reqIDGen: idutil.NewGenerator(uint8(id), time.Now()),
|
|
@@ -870,12 +870,8 @@ func startNode(cfg *ServerConfig, ids []types.ID) (id types.ID, n raft.Node, s *
|
|
|
}
|
|
}
|
|
|
id = member.ID
|
|
id = member.ID
|
|
|
log.Printf("etcdserver: start member %s in cluster %s", id, cfg.Cluster.ID())
|
|
log.Printf("etcdserver: start member %s in cluster %s", id, cfg.Cluster.ID())
|
|
|
- election := cfg.ElectionTimeoutTicks
|
|
|
|
|
- if election == 0 {
|
|
|
|
|
- election = 10
|
|
|
|
|
- }
|
|
|
|
|
s = raft.NewMemoryStorage()
|
|
s = raft.NewMemoryStorage()
|
|
|
- n = raft.StartNode(uint64(id), peers, election, 1, s)
|
|
|
|
|
|
|
+ n = raft.StartNode(uint64(id), peers, cfg.ElectionTicks, 1, s)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -888,17 +884,13 @@ func restartNode(cfg *ServerConfig, snapshot *raftpb.Snapshot) (types.ID, raft.N
|
|
|
cfg.Cluster.SetID(cid)
|
|
cfg.Cluster.SetID(cid)
|
|
|
|
|
|
|
|
log.Printf("etcdserver: restart member %s in cluster %s at commit index %d", id, cfg.Cluster.ID(), st.Commit)
|
|
log.Printf("etcdserver: restart member %s in cluster %s at commit index %d", id, cfg.Cluster.ID(), st.Commit)
|
|
|
- election := cfg.ElectionTimeoutTicks
|
|
|
|
|
- if election == 0 {
|
|
|
|
|
- election = 10
|
|
|
|
|
- }
|
|
|
|
|
s := raft.NewMemoryStorage()
|
|
s := raft.NewMemoryStorage()
|
|
|
if snapshot != nil {
|
|
if snapshot != nil {
|
|
|
s.ApplySnapshot(*snapshot)
|
|
s.ApplySnapshot(*snapshot)
|
|
|
}
|
|
}
|
|
|
s.SetHardState(st)
|
|
s.SetHardState(st)
|
|
|
s.Append(ents)
|
|
s.Append(ents)
|
|
|
- n := raft.RestartNode(uint64(id), election, 1, s)
|
|
|
|
|
|
|
+ n := raft.RestartNode(uint64(id), cfg.ElectionTicks, 1, s)
|
|
|
return id, n, s, w
|
|
return id, n, s, w
|
|
|
}
|
|
}
|
|
|
|
|
|