move nextsynclogid to server

This commit is contained in:
siddontang 2014-09-25 22:33:09 +08:00
parent 962a087330
commit 05135a5ac9
2 changed files with 14 additions and 18 deletions

View File

@ -187,23 +187,6 @@ func (l *Ledis) ReadLogsToTimeout(startLogID uint64, w io.Writer, timeout int) (
return l.ReadLogsTo(startLogID, w)
}
func (l *Ledis) NextSyncLogID() (uint64, error) {
if !l.ReplicationUsed() {
return 0, ErrRplNotSupport
}
s, err := l.r.Stat()
if err != nil {
return 0, err
}
if s.LastID > s.CommitID {
return s.LastID + 1, nil
} else {
return s.CommitID + 1, nil
}
}
func (l *Ledis) propagate(rl *rpl.Log) {
for _, h := range l.rhs {
h(rl)

View File

@ -176,10 +176,23 @@ func (m *master) fullSync() error {
return nil
}
func (m *master) nextSyncLogID() (uint64, error) {
s, err := m.app.ldb.ReplicationStat()
if err != nil {
return 0, err
}
if s.LastID > s.CommitID {
return s.LastID + 1, nil
} else {
return s.CommitID + 1, nil
}
}
func (m *master) sync() error {
var err error
var syncID uint64
if syncID, err = m.app.ldb.NextSyncLogID(); err != nil {
if syncID, err = m.nextSyncLogID(); err != nil {
return err
}