memStore chunk protection added, no chunk removed without being written to disk

This commit is contained in:
zelig 2015-05-13 20:10:16 +02:00
parent 53a00eeb41
commit 638bc6d364
4 changed files with 19 additions and 8 deletions

View file

@ -287,6 +287,9 @@ func (s *dbStore) Put(chunk *Chunk) {
batch.Put(ikey, idata)
s.db.Write(batch)
if chunk.dbStored != nil {
close(chunk.dbStored)
}
}
// try to find index; if found, update access cnt and return true

View file

@ -60,6 +60,7 @@ type Chunk struct {
C chan bool // to signal data delivery by the dpa
req *requestStatus //
wg *sync.WaitGroup
dbStored chan bool
}
type ChunkStore interface {

View file

@ -9,6 +9,7 @@ type localStore struct {
// localStore is itself a chunk store , to stores a chunk only
// its integrity is checked ?
func (self *localStore) Put(chunk *Chunk) {
chunk.dbStored = make(chan bool)
self.memStore.Put(chunk)
if chunk.wg != nil {
chunk.wg.Add(1)

View file

@ -314,8 +314,14 @@ func (s *memStore) removeOldest() {
}
if node.entry.dbStored != nil {
<-node.entry.dbStored
}
if node.entry.SData != nil {
node.entry = nil
s.entryCnt--
}
node.access[0] = 0
//---