mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix snapshot
This commit is contained in:
parent
ec175d4c47
commit
107762e82a
@ -60,7 +60,7 @@ func NewPeerServer(name string, path string, url string, listenHost string, tlsC
|
|||||||
tlsInfo: tlsInfo,
|
tlsInfo: tlsInfo,
|
||||||
registry: registry,
|
registry: registry,
|
||||||
store: store,
|
store: store,
|
||||||
snapConf: &snapshotConf{time.Second * 3, 0, 20 * 1000},
|
snapConf: &snapshotConf{time.Second * 3, 0, 2},
|
||||||
followersStats: &raftFollowersStats{
|
followersStats: &raftFollowersStats{
|
||||||
Leader: name,
|
Leader: name,
|
||||||
Followers: make(map[string]*raftFollowerStats),
|
Followers: make(map[string]*raftFollowerStats),
|
||||||
@ -391,10 +391,10 @@ func (s *PeerServer) PeerStats() []byte {
|
|||||||
func (s *PeerServer) monitorSnapshot() {
|
func (s *PeerServer) monitorSnapshot() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(s.snapConf.checkingInterval)
|
time.Sleep(s.snapConf.checkingInterval)
|
||||||
currentWrites := 0
|
currentWrites := s.store.TotalTransactions() - s.snapConf.lastWrites
|
||||||
if uint64(currentWrites) > s.snapConf.writesThr {
|
if uint64(currentWrites) > s.snapConf.writesThr {
|
||||||
s.raftServer.TakeSnapshot()
|
s.raftServer.TakeSnapshot()
|
||||||
s.snapConf.lastWrites = 0
|
s.snapConf.lastWrites = s.store.TotalTransactions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ func (s *Stats) TotalReads() uint64 {
|
|||||||
return s.GetSuccess + s.GetFail
|
return s.GetSuccess + s.GetFail
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stats) TotalWrites() uint64 {
|
func (s *Stats) TotalTranscations() uint64 {
|
||||||
return s.SetSuccess + s.SetFail +
|
return s.SetSuccess + s.SetFail +
|
||||||
s.DeleteSuccess + s.DeleteFail +
|
s.DeleteSuccess + s.DeleteFail +
|
||||||
s.CompareAndSwapSuccess + s.CompareAndSwapFail +
|
s.CompareAndSwapSuccess + s.CompareAndSwapFail +
|
||||||
|
@ -25,6 +25,7 @@ type Store interface {
|
|||||||
Watch(prefix string, recursive bool, sinceIndex uint64, index uint64, term uint64) (<-chan *Event, error)
|
Watch(prefix string, recursive bool, sinceIndex uint64, index uint64, term uint64) (<-chan *Event, error)
|
||||||
Save() ([]byte, error)
|
Save() ([]byte, error)
|
||||||
Recovery(state []byte) error
|
Recovery(state []byte) error
|
||||||
|
TotalTransactions() uint64
|
||||||
JsonStats() []byte
|
JsonStats() []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,3 +483,7 @@ func (s *store) JsonStats() []byte {
|
|||||||
s.Stats.Watchers = uint64(s.WatcherHub.count)
|
s.Stats.Watchers = uint64(s.WatcherHub.count)
|
||||||
return s.Stats.toJson()
|
return s.Stats.toJson()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *store) TotalTransactions() uint64 {
|
||||||
|
return s.Stats.TotalTranscations()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user