forked from TrueCloudLab/frostfs-node
[#536] blobovnicza: Add blobovniczatree DB cache
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
c672f59ab8
commit
7456c8556a
10 changed files with 124 additions and 20 deletions
|
@ -21,15 +21,13 @@ func (b *Blobovniczas) Open(readOnly bool) error {
|
|||
func (b *Blobovniczas) Init() error {
|
||||
b.log.Debug(logs.BlobovniczatreeInitializingBlobovniczas)
|
||||
|
||||
b.openManagers()
|
||||
|
||||
if b.readOnly {
|
||||
b.log.Debug(logs.BlobovniczatreeReadonlyModeSkipBlobovniczasInitialization)
|
||||
return nil
|
||||
}
|
||||
|
||||
return b.iterateLeaves(context.TODO(), func(p string) (bool, error) {
|
||||
shBlz := b.openBlobovniczaNoCache(p)
|
||||
shBlz := b.getBlobovniczaWithoutCaching(p)
|
||||
_, err := shBlz.Open()
|
||||
if err != nil {
|
||||
return true, err
|
||||
|
@ -44,23 +42,25 @@ func (b *Blobovniczas) Init() error {
|
|||
func (b *Blobovniczas) openManagers() {
|
||||
b.commondbManager.Open() //order important
|
||||
b.activeDBManager.Open()
|
||||
b.dbCache.Open()
|
||||
}
|
||||
|
||||
// Close implements common.Storage.
|
||||
func (b *Blobovniczas) Close() error {
|
||||
b.activeDBManager.Close() //order important
|
||||
b.dbCache.Close() //order important
|
||||
b.activeDBManager.Close()
|
||||
b.commondbManager.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// opens and returns blobovnicza with path p.
|
||||
// returns blobovnicza with path p
|
||||
//
|
||||
// If blobovnicza is already opened and cached, instance from cache is returned w/o changes.
|
||||
func (b *Blobovniczas) openBlobovnicza(p string) *sharedDB {
|
||||
return b.openBlobovniczaNoCache(p)
|
||||
// If blobovnicza is already cached, instance from cache is returned w/o changes.
|
||||
func (b *Blobovniczas) getBlobovnicza(p string) *sharedDB {
|
||||
return b.dbCache.GetOrCreate(p)
|
||||
}
|
||||
|
||||
func (b *Blobovniczas) openBlobovniczaNoCache(p string) *sharedDB {
|
||||
func (b *Blobovniczas) getBlobovniczaWithoutCaching(p string) *sharedDB {
|
||||
return b.commondbManager.GetByPath(p)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue