mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add snpshot
This commit is contained in:
parent
9fd62298ff
commit
64eeca3941
34
snapshot.go
Normal file
34
snapshot.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type snapshotConf struct {
|
||||||
|
// basic
|
||||||
|
checkingInterval time.Duration
|
||||||
|
lastWrites uint64
|
||||||
|
writesThr uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
var snapConf *snapshotConf
|
||||||
|
|
||||||
|
func newSnapshotConf() *snapshotConf {
|
||||||
|
return &snapshotConf {time.Second*3, etcdStore.TotalWrites(), 20*1000}
|
||||||
|
}
|
||||||
|
|
||||||
|
func monitorSnapshot() {
|
||||||
|
for {
|
||||||
|
time.Sleep(snapConf.checkingInterval)
|
||||||
|
currentWrites := etcdStore.TotalWrites() - snapConf.lastWrites
|
||||||
|
|
||||||
|
if currentWrites > snapConf.writesThr {
|
||||||
|
raftServer.TakeSnapshot()
|
||||||
|
snapConf.lastWrites = etcdStore.TotalWrites()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fmt.Println(currentWrites)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user