*: recover lessor when applying snapshot

release-2.3
Xiang Li 2016-03-10 17:06:10 -08:00
parent 6a3e8d4bde
commit adcba975cb
2 changed files with 10 additions and 2 deletions

View File

@ -616,6 +616,10 @@ func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
s.be = newbe
s.bemu.Unlock()
if s.lessor != nil {
s.lessor.Recover(s.be, s.kv)
}
}
if err := s.store.Recovery(apply.snapshot.Data); err != nil {
plog.Panicf("recovery store error: %v", err)

View File

@ -93,6 +93,9 @@ type Lessor interface {
// ExpiredLeasesC returns a chan that is used to receive expired leases.
ExpiredLeasesC() <-chan []*Lease
// Recover recovers the lessor state from the given backend and RangeDeleter.
Recover(b backend.Backend, rd RangeDeleter)
// Stop stops the lessor for managing leases. The behavior of calling Stop multiple
// times is undefined.
Stop()
@ -476,8 +479,7 @@ func int64ToBytes(n int64) []byte {
// FakeLessor is a fake implementation of Lessor interface.
// Used for testing only.
type FakeLessor struct {
}
type FakeLessor struct{}
func (fl *FakeLessor) SetRangeDeleter(dr RangeDeleter) {}
@ -499,4 +501,6 @@ func (le *FakeLessor) Lookup(id LeaseID) *Lease { return nil }
func (fl *FakeLessor) ExpiredLeasesC() <-chan []*Lease { return nil }
func (fl *FakeLessor) Recover(b backend.Backend, rd RangeDeleter) {}
func (fl *FakeLessor) Stop() {}