forked from mirror/ledisdb
add some replication info
This commit is contained in:
parent
f907234638
commit
4adf3e8996
|
@ -28,6 +28,11 @@ type info struct {
|
|||
Persistence struct {
|
||||
DBName string
|
||||
}
|
||||
|
||||
Replication struct {
|
||||
PubLogNum int64
|
||||
PubLogTotalTime int64 //milliseconds
|
||||
}
|
||||
}
|
||||
|
||||
func newInfo(app *App) (i *info, err error) {
|
||||
|
@ -156,6 +161,15 @@ func (i *info) dumpReplication(buf *bytes.Buffer) {
|
|||
slaves = append(slaves, s.remoteAddr)
|
||||
}
|
||||
|
||||
num := i.Replication.PubLogNum
|
||||
p = append(p, infoPair{"pub_log_num", num})
|
||||
|
||||
if num != 0 {
|
||||
p = append(p, infoPair{"pub_log_per_time", i.Replication.PubLogTotalTime / num})
|
||||
} else {
|
||||
p = append(p, infoPair{"pub_log_per_time", 0})
|
||||
}
|
||||
|
||||
p = append(p, infoPair{"slaveof", i.app.cfg.SlaveOf})
|
||||
|
||||
if len(slaves) > 0 {
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"path"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -336,6 +337,8 @@ func (app *App) publishNewLog(l *rpl.Log) {
|
|||
return
|
||||
}
|
||||
|
||||
startTime := time.Now()
|
||||
|
||||
ack := &syncAck{
|
||||
logId, make(chan uint64, len(ss)),
|
||||
}
|
||||
|
@ -369,4 +372,8 @@ func (app *App) publishNewLog(l *rpl.Log) {
|
|||
case <-time.After(time.Duration(app.cfg.Replication.WaitSyncTime) * time.Millisecond):
|
||||
log.Info("replication wait timeout")
|
||||
}
|
||||
|
||||
stopTime := time.Now()
|
||||
atomic.AddInt64(&app.info.Replication.PubLogNum, 1)
|
||||
atomic.AddInt64(&app.info.Replication.PubLogTotalTime, stopTime.Sub(startTime).Nanoseconds()/1e6)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue