1. volume server now sends master server its max file key, so that
master server does not need to store the sequence on disk any more 2. fix raft server's failure to init cluster during bootstrapping
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package sequence
|
||||
|
||||
import ()
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// just for testing
|
||||
type MemorySequencer struct {
|
||||
counter uint64
|
||||
counter uint64
|
||||
sequenceLock sync.Mutex
|
||||
}
|
||||
|
||||
func NewMemorySequencer() (m *MemorySequencer) {
|
||||
@@ -13,7 +16,21 @@ func NewMemorySequencer() (m *MemorySequencer) {
|
||||
}
|
||||
|
||||
func (m *MemorySequencer) NextFileId(count int) (uint64, int) {
|
||||
m.sequenceLock.Lock()
|
||||
defer m.sequenceLock.Unlock()
|
||||
ret := m.counter
|
||||
m.counter += uint64(count)
|
||||
return ret, count
|
||||
}
|
||||
|
||||
func (m *MemorySequencer) SetMax(seenValue uint64) {
|
||||
m.sequenceLock.Lock()
|
||||
defer m.sequenceLock.Unlock()
|
||||
if m.counter <= seenValue {
|
||||
m.counter = seenValue + 1
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MemorySequencer) Peek() uint64 {
|
||||
return m.counter
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user