mirror of https://github.com/ledisdb/ledisdb.git
add some replication info
This commit is contained in:
parent
f907234638
commit
4adf3e8996
|
@ -28,6 +28,11 @@ type info struct {
|
||||||
Persistence struct {
|
Persistence struct {
|
||||||
DBName string
|
DBName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Replication struct {
|
||||||
|
PubLogNum int64
|
||||||
|
PubLogTotalTime int64 //milliseconds
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInfo(app *App) (i *info, err error) {
|
func newInfo(app *App) (i *info, err error) {
|
||||||
|
@ -156,6 +161,15 @@ func (i *info) dumpReplication(buf *bytes.Buffer) {
|
||||||
slaves = append(slaves, s.remoteAddr)
|
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})
|
p = append(p, infoPair{"slaveof", i.app.cfg.SlaveOf})
|
||||||
|
|
||||||
if len(slaves) > 0 {
|
if len(slaves) > 0 {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -336,6 +337,8 @@ func (app *App) publishNewLog(l *rpl.Log) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startTime := time.Now()
|
||||||
|
|
||||||
ack := &syncAck{
|
ack := &syncAck{
|
||||||
logId, make(chan uint64, len(ss)),
|
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):
|
case <-time.After(time.Duration(app.cfg.Replication.WaitSyncTime) * time.Millisecond):
|
||||||
log.Info("replication wait timeout")
|
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