forked from TrueCloudLab/frostfs-node
[#1437] node: Fix contextcheck linter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
6921a89061
commit
7429553266
209 changed files with 1068 additions and 1036 deletions
|
@ -18,8 +18,8 @@ func (db *activeDB) Blobovnicza() *blobovnicza.Blobovnicza {
|
|||
return db.blz
|
||||
}
|
||||
|
||||
func (db *activeDB) Close() {
|
||||
db.shDB.Close()
|
||||
func (db *activeDB) Close(ctx context.Context) {
|
||||
db.shDB.Close(ctx)
|
||||
}
|
||||
|
||||
func (db *activeDB) SystemPath() string {
|
||||
|
@ -73,12 +73,12 @@ func (m *activeDBManager) Open() {
|
|||
m.closed = false
|
||||
}
|
||||
|
||||
func (m *activeDBManager) Close() {
|
||||
func (m *activeDBManager) Close(ctx context.Context) {
|
||||
m.levelToActiveDBGuard.Lock()
|
||||
defer m.levelToActiveDBGuard.Unlock()
|
||||
|
||||
for _, db := range m.levelToActiveDB {
|
||||
db.Close()
|
||||
db.Close(ctx)
|
||||
}
|
||||
m.levelToActiveDB = make(map[string]*sharedDB)
|
||||
m.closed = true
|
||||
|
@ -103,7 +103,7 @@ func (m *activeDBManager) getCurrentActiveIfOk(ctx context.Context, lvlPath stri
|
|||
}
|
||||
|
||||
if blz.IsFull() {
|
||||
db.Close()
|
||||
db.Close(ctx)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -168,10 +168,10 @@ func (m *activeDBManager) getNextSharedDB(ctx context.Context, lvlPath string) (
|
|||
|
||||
previous, updated := m.replace(lvlPath, next)
|
||||
if !updated && next != nil {
|
||||
next.Close() // manager is closed, so don't hold active DB open
|
||||
next.Close(ctx) // manager is closed, so don't hold active DB open
|
||||
}
|
||||
if updated && previous != nil {
|
||||
previous.Close()
|
||||
previous.Close(ctx)
|
||||
}
|
||||
return next, nil
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ func (b *Blobovniczas) Compressor() *compression.Config {
|
|||
}
|
||||
|
||||
// SetReportErrorFunc implements common.Storage.
|
||||
func (b *Blobovniczas) SetReportErrorFunc(f func(string, error)) {
|
||||
func (b *Blobovniczas) SetReportErrorFunc(f func(context.Context, string, error)) {
|
||||
b.reportError = f
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ func newDBCache(parentCtx context.Context, size int,
|
|||
ch := cache.NewCache[string, *sharedDB]().
|
||||
WithTTL(ttl).WithLRU().WithMaxKeys(size).
|
||||
WithOnEvicted(func(_ string, db *sharedDB) {
|
||||
db.Close()
|
||||
db.Close(parentCtx)
|
||||
})
|
||||
ctx, cancel := context.WithCancel(parentCtx)
|
||||
res := &dbCache{
|
||||
|
@ -138,7 +138,7 @@ func (c *dbCache) create(ctx context.Context, path string) *sharedDB {
|
|||
return value
|
||||
}
|
||||
if added := c.put(path, value); !added {
|
||||
value.Close()
|
||||
value.Close(ctx)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestBlobovniczaTree_Concurrency(t *testing.T) {
|
|||
require.NoError(t, st.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, st.Init())
|
||||
defer func() {
|
||||
require.NoError(t, st.Close())
|
||||
require.NoError(t, st.Close(context.Background()))
|
||||
}()
|
||||
|
||||
objGen := &testutil.SeqObjGenerator{ObjSize: 1}
|
||||
|
|
|
@ -50,7 +50,7 @@ func (b *Blobovniczas) initializeDBs(ctx context.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(egCtx)
|
||||
|
||||
moveInfo, err := blz.ListMoveInfo(egCtx)
|
||||
if err != nil {
|
||||
|
@ -80,9 +80,9 @@ func (b *Blobovniczas) openManagers() {
|
|||
}
|
||||
|
||||
// Close implements common.Storage.
|
||||
func (b *Blobovniczas) Close() error {
|
||||
func (b *Blobovniczas) Close(ctx context.Context) error {
|
||||
b.dbCache.Close() // order important
|
||||
b.activeDBManager.Close()
|
||||
b.activeDBManager.Close(ctx)
|
||||
b.commondbManager.Close()
|
||||
|
||||
return nil
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestObjectsAvailableAfterDepthAndWidthEdit(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.EqualValues(t, obj35, gRes.Object)
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
// change depth and width
|
||||
blz = NewBlobovniczaTree(
|
||||
|
@ -89,7 +89,7 @@ func TestObjectsAvailableAfterDepthAndWidthEdit(t *testing.T) {
|
|||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
// change depth and width back
|
||||
blz = NewBlobovniczaTree(
|
||||
|
@ -127,5 +127,5 @@ func TestObjectsAvailableAfterDepthAndWidthEdit(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.EqualValues(t, obj52, gRes.Object)
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func (b *Blobovniczas) ObjectsCount(ctx context.Context) (uint64, error) {
|
|||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
defer shDB.Close()
|
||||
defer shDB.Close(ctx)
|
||||
|
||||
result += blz.ObjectsCount()
|
||||
return false, nil
|
||||
|
|
|
@ -66,7 +66,7 @@ func (b *Blobovniczas) Delete(ctx context.Context, prm common.DeletePrm) (res co
|
|||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
if res, err = b.deleteObject(ctx, blz, bPrm); err == nil {
|
||||
success = true
|
||||
|
@ -114,7 +114,7 @@ func (b *Blobovniczas) deleteObjectFromLevel(ctx context.Context, prm blobovnicz
|
|||
if err != nil {
|
||||
return common.DeleteRes{}, err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
return b.deleteObject(ctx, blz, prm)
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func (b *Blobovniczas) Exists(ctx context.Context, prm common.ExistsPrm) (common
|
|||
if err != nil {
|
||||
return common.ExistsRes{}, err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
exists, err := blz.Exists(ctx, prm.Address)
|
||||
return common.ExistsRes{Exists: exists}, err
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestExistsInvalidStorageID(t *testing.T) {
|
|||
WithBlobovniczaSize(1<<20))
|
||||
require.NoError(t, b.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, b.Init())
|
||||
defer func() { require.NoError(t, b.Close()) }()
|
||||
defer func() { require.NoError(t, b.Close(context.Background())) }()
|
||||
|
||||
obj := blobstortest.NewObject(1024)
|
||||
addr := object.AddressOf(obj)
|
||||
|
|
|
@ -53,7 +53,7 @@ func (b *Blobovniczas) Get(ctx context.Context, prm common.GetPrm) (res common.G
|
|||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
res, err = b.getObject(ctx, blz, bPrm)
|
||||
if err == nil {
|
||||
|
@ -100,7 +100,7 @@ func (b *Blobovniczas) getObjectFromLevel(ctx context.Context, prm blobovnicza.G
|
|||
if err != nil {
|
||||
return common.GetRes{}, err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
return b.getObject(ctx, blz, prm)
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func (b *Blobovniczas) GetRange(ctx context.Context, prm common.GetRangePrm) (re
|
|||
if err != nil {
|
||||
return common.GetRangeRes{}, err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
res, err := b.getObjectRange(ctx, blz, prm)
|
||||
if err == nil {
|
||||
|
@ -108,7 +108,7 @@ func (b *Blobovniczas) getRangeFromLevel(ctx context.Context, prm common.GetRang
|
|||
if err != nil {
|
||||
return common.GetRangeRes{}, err
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
return b.getObjectRange(ctx, blz, prm)
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ func (b *Blobovniczas) iterateBlobovniczas(ctx context.Context, ignoreErrors boo
|
|||
}
|
||||
return false, fmt.Errorf("could not open blobovnicza %s: %w", p, err)
|
||||
}
|
||||
defer shBlz.Close()
|
||||
defer shBlz.Close(ctx)
|
||||
|
||||
err = f(p, blz)
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ func (b *sharedDB) Open(ctx context.Context) (*blobovnicza.Blobovnicza, error) {
|
|||
if err := blz.Open(ctx); err != nil {
|
||||
return nil, fmt.Errorf("could not open blobovnicza %s: %w", b.path, err)
|
||||
}
|
||||
if err := blz.Init(); err != nil {
|
||||
if err := blz.Init(ctx); err != nil {
|
||||
return nil, fmt.Errorf("could not init blobovnicza %s: %w", b.path, err)
|
||||
}
|
||||
|
||||
|
@ -82,20 +82,20 @@ func (b *sharedDB) Open(ctx context.Context) (*blobovnicza.Blobovnicza, error) {
|
|||
return blz, nil
|
||||
}
|
||||
|
||||
func (b *sharedDB) Close() {
|
||||
func (b *sharedDB) Close(ctx context.Context) {
|
||||
b.cond.L.Lock()
|
||||
defer b.cond.L.Unlock()
|
||||
|
||||
if b.refCount == 0 {
|
||||
b.log.Error(context.Background(), logs.AttemtToCloseAlreadyClosedBlobovnicza, zap.String("id", b.path))
|
||||
b.log.Error(ctx, logs.AttemtToCloseAlreadyClosedBlobovnicza, zap.String("id", b.path))
|
||||
b.cond.Broadcast()
|
||||
return
|
||||
}
|
||||
|
||||
if b.refCount == 1 {
|
||||
b.refCount = 0
|
||||
if err := b.blcza.Close(); err != nil {
|
||||
b.log.Error(context.Background(), logs.BlobovniczatreeCouldNotCloseBlobovnicza,
|
||||
if err := b.blcza.Close(ctx); err != nil {
|
||||
b.log.Error(ctx, logs.BlobovniczatreeCouldNotCloseBlobovnicza,
|
||||
zap.String("id", b.path),
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
@ -111,7 +111,7 @@ func (b *sharedDB) Close() {
|
|||
}
|
||||
}
|
||||
|
||||
func (b *sharedDB) CloseAndRemoveFile() error {
|
||||
func (b *sharedDB) CloseAndRemoveFile(ctx context.Context) error {
|
||||
b.cond.L.Lock()
|
||||
if b.refCount > 1 {
|
||||
b.cond.Wait()
|
||||
|
@ -122,8 +122,8 @@ func (b *sharedDB) CloseAndRemoveFile() error {
|
|||
return errClosingClosedBlobovnicza
|
||||
}
|
||||
|
||||
if err := b.blcza.Close(); err != nil {
|
||||
b.log.Error(context.Background(), logs.BlobovniczatreeCouldNotCloseBlobovnicza,
|
||||
if err := b.blcza.Close(ctx); err != nil {
|
||||
b.log.Error(ctx, logs.BlobovniczatreeCouldNotCloseBlobovnicza,
|
||||
zap.String("id", b.path),
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package blobovniczatree
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/fs"
|
||||
"time"
|
||||
|
||||
|
@ -20,7 +21,7 @@ type cfg struct {
|
|||
blzShallowWidth uint64
|
||||
compression *compression.Config
|
||||
blzOpts []blobovnicza.Option
|
||||
reportError func(string, error) // reportError is the function called when encountering disk errors.
|
||||
reportError func(context.Context, string, error) // reportError is the function called when encountering disk errors.
|
||||
metrics Metrics
|
||||
waitBeforeDropDB time.Duration
|
||||
blzInitWorkerCount int
|
||||
|
@ -54,7 +55,7 @@ func initConfig(c *cfg) {
|
|||
openedCacheExpInterval: defaultOpenedCacheInterval,
|
||||
blzShallowDepth: defaultBlzShallowDepth,
|
||||
blzShallowWidth: defaultBlzShallowWidth,
|
||||
reportError: func(string, error) {},
|
||||
reportError: func(context.Context, string, error) {},
|
||||
metrics: &noopMetrics{},
|
||||
waitBeforeDropDB: defaultWaitBeforeDropDB,
|
||||
blzInitWorkerCount: defaultBlzInitWorkerCount,
|
||||
|
|
|
@ -80,7 +80,7 @@ func (i *putIterator) iterate(ctx context.Context, lvlPath string) (bool, error)
|
|||
active, err := i.B.activeDBManager.GetOpenedActiveDBForLevel(ctx, lvlPath)
|
||||
if err != nil {
|
||||
if !isLogical(err) {
|
||||
i.B.reportError(logs.BlobovniczatreeCouldNotGetActiveBlobovnicza, err)
|
||||
i.B.reportError(ctx, logs.BlobovniczatreeCouldNotGetActiveBlobovnicza, err)
|
||||
} else {
|
||||
i.B.log.Debug(ctx, logs.BlobovniczatreeCouldNotGetActiveBlobovnicza,
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -95,14 +95,14 @@ func (i *putIterator) iterate(ctx context.Context, lvlPath string) (bool, error)
|
|||
zap.String("trace_id", tracingPkg.GetTraceID(ctx)))
|
||||
return false, nil
|
||||
}
|
||||
defer active.Close()
|
||||
defer active.Close(ctx)
|
||||
|
||||
i.AllFull = false
|
||||
|
||||
_, err = active.Blobovnicza().Put(ctx, i.PutPrm)
|
||||
if err != nil {
|
||||
if !isLogical(err) {
|
||||
i.B.reportError(logs.BlobovniczatreeCouldNotPutObjectToActiveBlobovnicza, err)
|
||||
i.B.reportError(ctx, logs.BlobovniczatreeCouldNotPutObjectToActiveBlobovnicza, err)
|
||||
} else {
|
||||
i.B.log.Debug(ctx, logs.BlobovniczatreeCouldNotPutObjectToActiveBlobovnicza,
|
||||
zap.String("path", active.SystemPath()),
|
||||
|
|
|
@ -186,7 +186,7 @@ func (b *Blobovniczas) rebuildBySize(ctx context.Context, path string, targetFil
|
|||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer shDB.Close()
|
||||
defer shDB.Close(ctx)
|
||||
fp := blz.FillPercent()
|
||||
// accepted fill percent defines as
|
||||
// |----|+++++++++++++++++|+++++++++++++++++|---------------
|
||||
|
@ -206,9 +206,9 @@ func (b *Blobovniczas) rebuildDB(ctx context.Context, path string, meta common.M
|
|||
if shDBClosed {
|
||||
return
|
||||
}
|
||||
shDB.Close()
|
||||
shDB.Close(ctx)
|
||||
}()
|
||||
dropTempFile, err := b.addRebuildTempFile(path)
|
||||
dropTempFile, err := b.addRebuildTempFile(ctx, path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ func (b *Blobovniczas) rebuildDB(ctx context.Context, path string, meta common.M
|
|||
return migratedObjects, err
|
||||
}
|
||||
|
||||
func (b *Blobovniczas) addRebuildTempFile(path string) (func(), error) {
|
||||
func (b *Blobovniczas) addRebuildTempFile(ctx context.Context, path string) (func(), error) {
|
||||
sysPath := filepath.Join(b.rootPath, path)
|
||||
sysPath = sysPath + rebuildSuffix
|
||||
_, err := os.OpenFile(sysPath, os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, b.perm)
|
||||
|
@ -233,7 +233,7 @@ func (b *Blobovniczas) addRebuildTempFile(path string) (func(), error) {
|
|||
}
|
||||
return func() {
|
||||
if err := os.Remove(sysPath); err != nil {
|
||||
b.log.Warn(context.Background(), logs.BlobovniczatreeFailedToRemoveRebuildTempFile, zap.Error(err))
|
||||
b.log.Warn(ctx, logs.BlobovniczatreeFailedToRemoveRebuildTempFile, zap.Error(err))
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ func (b *Blobovniczas) dropDB(ctx context.Context, path string, shDb *sharedDB)
|
|||
b.dbFilesGuard.Lock()
|
||||
defer b.dbFilesGuard.Unlock()
|
||||
|
||||
if err := shDb.CloseAndRemoveFile(); err != nil {
|
||||
if err := shDb.CloseAndRemoveFile(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
b.commondbManager.CleanResources(path)
|
||||
|
@ -370,7 +370,7 @@ func (b *Blobovniczas) completeIncompletedMove(ctx context.Context, metaStore co
|
|||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
defer shDB.Close()
|
||||
defer shDB.Close(ctx)
|
||||
|
||||
incompletedMoves, err := blz.ListMoveInfo(ctx)
|
||||
if err != nil {
|
||||
|
@ -403,7 +403,7 @@ func (b *Blobovniczas) performMove(ctx context.Context, source *blobovnicza.Blob
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer targetDB.Close()
|
||||
defer targetDB.Close(ctx)
|
||||
|
||||
existsInSource := true
|
||||
var gPrm blobovnicza.GetPrm
|
||||
|
@ -480,7 +480,7 @@ func (i *moveIterator) tryMoveToLvl(ctx context.Context, lvlPath string) (bool,
|
|||
target, err := i.B.activeDBManager.GetOpenedActiveDBForLevel(ctx, lvlPath)
|
||||
if err != nil {
|
||||
if !isLogical(err) {
|
||||
i.B.reportError(logs.BlobovniczatreeCouldNotGetActiveBlobovnicza, err)
|
||||
i.B.reportError(ctx, logs.BlobovniczatreeCouldNotGetActiveBlobovnicza, err)
|
||||
} else {
|
||||
i.B.log.Warn(ctx, logs.BlobovniczatreeCouldNotGetActiveBlobovnicza, zap.Error(err))
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ func (i *moveIterator) tryMoveToLvl(ctx context.Context, lvlPath string) (bool,
|
|||
i.B.log.Warn(ctx, logs.BlobovniczatreeBlobovniczaOverflowed, zap.String("level", lvlPath))
|
||||
return false, nil
|
||||
}
|
||||
defer target.Close()
|
||||
defer target.Close(ctx)
|
||||
|
||||
i.AllFull = false
|
||||
|
||||
|
@ -503,7 +503,7 @@ func (i *moveIterator) tryMoveToLvl(ctx context.Context, lvlPath string) (bool,
|
|||
TargetStorageID: targetStorageID.Bytes(),
|
||||
}); err != nil {
|
||||
if !isLogical(err) {
|
||||
i.B.reportError(logs.BlobovniczatreeCouldNotPutMoveInfoToSourceBlobovnicza, err)
|
||||
i.B.reportError(ctx, logs.BlobovniczatreeCouldNotPutMoveInfoToSourceBlobovnicza, err)
|
||||
} else {
|
||||
i.B.log.Warn(ctx, logs.BlobovniczatreeCouldNotPutMoveInfoToSourceBlobovnicza, zap.String("path", i.SourceSysPath), zap.Error(err))
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ func (i *moveIterator) tryMoveToLvl(ctx context.Context, lvlPath string) (bool,
|
|||
_, err = target.Blobovnicza().Put(ctx, putPrm)
|
||||
if err != nil {
|
||||
if !isLogical(err) {
|
||||
i.B.reportError(logs.BlobovniczatreeCouldNotPutObjectToActiveBlobovnicza, err)
|
||||
i.B.reportError(ctx, logs.BlobovniczatreeCouldNotPutObjectToActiveBlobovnicza, err)
|
||||
} else {
|
||||
i.B.log.Warn(ctx, logs.BlobovniczatreeCouldNotPutObjectToActiveBlobovnicza, zap.String("path", target.SystemPath()), zap.Error(err))
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ func (i *moveIterator) tryMoveToLvl(ctx context.Context, lvlPath string) (bool,
|
|||
deletePrm.SetAddress(i.Address)
|
||||
if _, err = i.Source.Delete(ctx, deletePrm); err != nil {
|
||||
if !isLogical(err) {
|
||||
i.B.reportError(logs.BlobovniczatreeCouldNotDeleteFromSource, err)
|
||||
i.B.reportError(ctx, logs.BlobovniczatreeCouldNotDeleteFromSource, err)
|
||||
} else {
|
||||
i.B.log.Warn(ctx, logs.BlobovniczatreeCouldNotDeleteFromSource, zap.String("path", i.SourceSysPath), zap.Error(err))
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ func (i *moveIterator) tryMoveToLvl(ctx context.Context, lvlPath string) (bool,
|
|||
|
||||
if err = i.Source.DropMoveInfo(ctx, i.Address); err != nil {
|
||||
if !isLogical(err) {
|
||||
i.B.reportError(logs.BlobovniczatreeCouldNotDropMoveInfo, err)
|
||||
i.B.reportError(ctx, logs.BlobovniczatreeCouldNotDropMoveInfo, err)
|
||||
} else {
|
||||
i.B.log.Warn(ctx, logs.BlobovniczatreeCouldNotDropMoveInfo, zap.String("path", i.SourceSysPath), zap.Error(err))
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func testRebuildFailoverOnlyMoveInfoSaved(t *testing.T) {
|
|||
|
||||
blz := blobovnicza.New(blobovnicza.WithPath(filepath.Join(dir, "0", "0", "1.db")))
|
||||
require.NoError(t, blz.Open(context.Background()))
|
||||
require.NoError(t, blz.Init())
|
||||
require.NoError(t, blz.Init(context.Background()))
|
||||
|
||||
obj := blobstortest.NewObject(1024)
|
||||
data, err := obj.Marshal()
|
||||
|
@ -53,7 +53,7 @@ func testRebuildFailoverOnlyMoveInfoSaved(t *testing.T) {
|
|||
TargetStorageID: []byte("0/0/0"),
|
||||
}))
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
_, err = os.OpenFile(filepath.Join(dir, "0", "0", "1.db.rebuild"), os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, defaultPerm)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -66,7 +66,7 @@ func testRebuildFailoverObjectSavedToTarget(t *testing.T) {
|
|||
|
||||
blz := blobovnicza.New(blobovnicza.WithPath(filepath.Join(dir, "0", "0", "1.db")))
|
||||
require.NoError(t, blz.Open(context.Background()))
|
||||
require.NoError(t, blz.Init())
|
||||
require.NoError(t, blz.Init(context.Background()))
|
||||
|
||||
obj := blobstortest.NewObject(1024)
|
||||
data, err := obj.Marshal()
|
||||
|
@ -83,19 +83,19 @@ func testRebuildFailoverObjectSavedToTarget(t *testing.T) {
|
|||
TargetStorageID: []byte("0/0/0"),
|
||||
}))
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
_, err = os.OpenFile(filepath.Join(dir, "0", "0", "1.db.rebuild"), os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, defaultPerm)
|
||||
require.NoError(t, err)
|
||||
|
||||
blz = blobovnicza.New(blobovnicza.WithPath(filepath.Join(dir, "0", "0", "0.db")))
|
||||
require.NoError(t, blz.Open(context.Background()))
|
||||
require.NoError(t, blz.Init())
|
||||
require.NoError(t, blz.Init(context.Background()))
|
||||
|
||||
_, err = blz.Put(context.Background(), pPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
testRebuildFailoverValidate(t, dir, obj, true)
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func testRebuildFailoverObjectDeletedFromSource(t *testing.T) {
|
|||
|
||||
blz := blobovnicza.New(blobovnicza.WithPath(filepath.Join(dir, "0", "0", "1.db")))
|
||||
require.NoError(t, blz.Open(context.Background()))
|
||||
require.NoError(t, blz.Init())
|
||||
require.NoError(t, blz.Init(context.Background()))
|
||||
|
||||
obj := blobstortest.NewObject(1024)
|
||||
data, err := obj.Marshal()
|
||||
|
@ -117,14 +117,14 @@ func testRebuildFailoverObjectDeletedFromSource(t *testing.T) {
|
|||
TargetStorageID: []byte("0/0/0"),
|
||||
}))
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
_, err = os.OpenFile(filepath.Join(dir, "0", "0", "1.db.rebuild"), os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, defaultPerm)
|
||||
require.NoError(t, err)
|
||||
|
||||
blz = blobovnicza.New(blobovnicza.WithPath(filepath.Join(dir, "0", "0", "0.db")))
|
||||
require.NoError(t, blz.Open(context.Background()))
|
||||
require.NoError(t, blz.Init())
|
||||
require.NoError(t, blz.Init(context.Background()))
|
||||
|
||||
var pPrm blobovnicza.PutPrm
|
||||
pPrm.SetAddress(object.AddressOf(obj))
|
||||
|
@ -132,7 +132,7 @@ func testRebuildFailoverObjectDeletedFromSource(t *testing.T) {
|
|||
_, err = blz.Put(context.Background(), pPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
testRebuildFailoverValidate(t, dir, obj, false)
|
||||
}
|
||||
|
@ -170,11 +170,11 @@ func testRebuildFailoverValidate(t *testing.T, dir string, obj *objectSDK.Object
|
|||
require.Equal(t, uint64(1), rRes.ObjectsMoved)
|
||||
require.Equal(t, uint64(0), rRes.FilesRemoved)
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
|
||||
blz := blobovnicza.New(blobovnicza.WithPath(filepath.Join(dir, "0", "0", "1.db")))
|
||||
require.NoError(t, blz.Open(context.Background()))
|
||||
require.NoError(t, blz.Init())
|
||||
require.NoError(t, blz.Init(context.Background()))
|
||||
|
||||
moveInfo, err := blz.ListMoveInfo(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
@ -185,11 +185,11 @@ func testRebuildFailoverValidate(t *testing.T, dir string, obj *objectSDK.Object
|
|||
_, err = blz.Get(context.Background(), gPrm)
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
blz = blobovnicza.New(blobovnicza.WithPath(filepath.Join(dir, "0", "0", "0.db")))
|
||||
require.NoError(t, blz.Open(context.Background()))
|
||||
require.NoError(t, blz.Init())
|
||||
require.NoError(t, blz.Init(context.Background()))
|
||||
|
||||
moveInfo, err = blz.ListMoveInfo(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
@ -203,7 +203,7 @@ func testRebuildFailoverValidate(t *testing.T, dir string, obj *objectSDK.Object
|
|||
require.True(t, bytes.Equal([]byte("0/0/0"), metaStub.storageIDs[object.AddressOf(obj)]))
|
||||
}
|
||||
|
||||
require.NoError(t, blz.Close())
|
||||
require.NoError(t, blz.Close(context.Background()))
|
||||
|
||||
_, err = os.Stat(filepath.Join(dir, "0", "0", "1.db.rebuild"))
|
||||
require.True(t, os.IsNotExist(err))
|
||||
|
|
|
@ -93,7 +93,7 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
})
|
||||
|
||||
t.Run("no rebuild single db", func(t *testing.T) {
|
||||
|
@ -145,7 +145,7 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
})
|
||||
|
||||
t.Run("rebuild by fill percent", func(t *testing.T) {
|
||||
|
@ -214,7 +214,7 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
})
|
||||
|
||||
t.Run("rebuild by overflow", func(t *testing.T) {
|
||||
|
@ -251,7 +251,7 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
storageIDs: storageIDs,
|
||||
guard: &sync.Mutex{},
|
||||
}
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
b = NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
|
@ -284,7 +284,7 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ func TestBlobovniczaTreeRebuildLargeObject(t *testing.T) {
|
|||
storageIDs := make(map[oid.Address][]byte)
|
||||
storageIDs[prm.Address] = res.StorageID
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
|
||||
b = NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
|
@ -355,7 +355,7 @@ func TestBlobovniczaTreeRebuildLargeObject(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
}
|
||||
|
||||
func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, targetDepth, targetWidth uint64, shouldMigrate bool) {
|
||||
|
@ -399,7 +399,7 @@ func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, ta
|
|||
}
|
||||
|
||||
require.NoError(t, eg.Wait())
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
|
||||
b = NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
|
@ -444,7 +444,7 @@ func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, ta
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
require.NoError(t, b.Close())
|
||||
require.NoError(t, b.Close(context.Background()))
|
||||
}
|
||||
|
||||
type storageIDUpdateStub struct {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package blobstor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
|
@ -139,7 +140,7 @@ func WithUncompressableContentTypes(values []string) Option {
|
|||
|
||||
// SetReportErrorFunc allows to provide a function to be called on disk errors.
|
||||
// This function MUST be called before Open.
|
||||
func (b *BlobStor) SetReportErrorFunc(f func(string, error)) {
|
||||
func (b *BlobStor) SetReportErrorFunc(f func(context.Context, string, error)) {
|
||||
for i := range b.storage {
|
||||
b.storage[i].Storage.SetReportErrorFunc(f)
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ func TestCompression(t *testing.T) {
|
|||
WithCompressObjects(compress),
|
||||
WithStorages(defaultStorages(dir, smallSizeLimit)))
|
||||
require.NoError(t, bs.Open(context.Background(), mode.ReadWrite))
|
||||
require.NoError(t, bs.Init())
|
||||
require.NoError(t, bs.Init(context.Background()))
|
||||
return bs
|
||||
}
|
||||
|
||||
|
@ -91,20 +91,20 @@ func TestCompression(t *testing.T) {
|
|||
blobStor := newBlobStor(t, false)
|
||||
testPut(t, blobStor, 0)
|
||||
testGet(t, blobStor, 0)
|
||||
require.NoError(t, blobStor.Close())
|
||||
require.NoError(t, blobStor.Close(context.Background()))
|
||||
|
||||
blobStor = newBlobStor(t, true)
|
||||
testGet(t, blobStor, 0) // get uncompressed object with compress enabled
|
||||
testPut(t, blobStor, 1)
|
||||
testGet(t, blobStor, 1)
|
||||
require.NoError(t, blobStor.Close())
|
||||
require.NoError(t, blobStor.Close(context.Background()))
|
||||
|
||||
blobStor = newBlobStor(t, false)
|
||||
testGet(t, blobStor, 0) // get old uncompressed object
|
||||
testGet(t, blobStor, 1) // get compressed object with compression disabled
|
||||
testPut(t, blobStor, 2)
|
||||
testGet(t, blobStor, 2)
|
||||
require.NoError(t, blobStor.Close())
|
||||
require.NoError(t, blobStor.Close(context.Background()))
|
||||
}
|
||||
|
||||
func TestBlobstor_needsCompression(t *testing.T) {
|
||||
|
@ -130,7 +130,7 @@ func TestBlobstor_needsCompression(t *testing.T) {
|
|||
},
|
||||
}))
|
||||
require.NoError(t, bs.Open(context.Background(), mode.ReadWrite))
|
||||
require.NoError(t, bs.Init())
|
||||
require.NoError(t, bs.Init(context.Background()))
|
||||
return bs
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ func TestConcurrentPut(t *testing.T) {
|
|||
blobStor := New(
|
||||
WithStorages(defaultStorages(dir, smallSizeLimit)))
|
||||
require.NoError(t, blobStor.Open(context.Background(), mode.ReadWrite))
|
||||
require.NoError(t, blobStor.Init())
|
||||
require.NoError(t, blobStor.Init(context.Background()))
|
||||
|
||||
testGet := func(t *testing.T, b *BlobStor, obj *objectSDK.Object) {
|
||||
res, err := b.Get(context.Background(), common.GetPrm{Address: object.AddressOf(obj)})
|
||||
|
@ -272,7 +272,7 @@ func TestConcurrentDelete(t *testing.T) {
|
|||
blobStor := New(
|
||||
WithStorages(defaultStorages(dir, smallSizeLimit)))
|
||||
require.NoError(t, blobStor.Open(context.Background(), mode.ReadWrite))
|
||||
require.NoError(t, blobStor.Init())
|
||||
require.NoError(t, blobStor.Init(context.Background()))
|
||||
|
||||
testPut := func(t *testing.T, b *BlobStor, obj *objectSDK.Object) {
|
||||
var prm common.PutPrm
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
type Storage interface {
|
||||
Open(mode mode.ComponentMode) error
|
||||
Init() error
|
||||
Close() error
|
||||
Close(context.Context) error
|
||||
|
||||
Type() string
|
||||
Path() string
|
||||
|
@ -23,7 +23,7 @@ type Storage interface {
|
|||
|
||||
// SetReportErrorFunc allows to provide a function to be called on disk errors.
|
||||
// This function MUST be called before Open.
|
||||
SetReportErrorFunc(f func(string, error))
|
||||
SetReportErrorFunc(f func(context.Context, string, error))
|
||||
SetParentID(parentID string)
|
||||
|
||||
Get(context.Context, GetPrm) (GetRes, error)
|
||||
|
|
|
@ -50,8 +50,8 @@ var ErrInitBlobovniczas = errors.New("failure on blobovnicza initialization stag
|
|||
// If BlobStor is already initialized, no action is taken.
|
||||
//
|
||||
// Returns wrapped ErrInitBlobovniczas on blobovnicza tree's initializaiton failure.
|
||||
func (b *BlobStor) Init() error {
|
||||
b.log.Debug(context.Background(), logs.BlobstorInitializing)
|
||||
func (b *BlobStor) Init(ctx context.Context) error {
|
||||
b.log.Debug(ctx, logs.BlobstorInitializing)
|
||||
|
||||
if err := b.compression.Init(); err != nil {
|
||||
return err
|
||||
|
@ -67,14 +67,14 @@ func (b *BlobStor) Init() error {
|
|||
}
|
||||
|
||||
// Close releases all internal resources of BlobStor.
|
||||
func (b *BlobStor) Close() error {
|
||||
b.log.Debug(context.Background(), logs.BlobstorClosing)
|
||||
func (b *BlobStor) Close(ctx context.Context) error {
|
||||
b.log.Debug(ctx, logs.BlobstorClosing)
|
||||
|
||||
var firstErr error
|
||||
for i := range b.storage {
|
||||
err := b.storage[i].Storage.Close()
|
||||
err := b.storage[i].Storage.Close(ctx)
|
||||
if err != nil {
|
||||
b.log.Info(context.Background(), logs.BlobstorCouldntCloseStorage, zap.String("error", err.Error()))
|
||||
b.log.Info(ctx, logs.BlobstorCouldntCloseStorage, zap.String("error", err.Error()))
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestExists(t *testing.T) {
|
|||
b := New(WithStorages(storages))
|
||||
|
||||
require.NoError(t, b.Open(context.Background(), mode.ReadWrite))
|
||||
require.NoError(t, b.Init())
|
||||
require.NoError(t, b.Init(context.Background()))
|
||||
|
||||
objects := []*objectSDK.Object{
|
||||
testObject(smallSizeLimit / 2),
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package fstree
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||
)
|
||||
|
@ -28,7 +30,7 @@ func (t *FSTree) Init() error {
|
|||
}
|
||||
|
||||
// Close implements common.Storage.
|
||||
func (t *FSTree) Close() error {
|
||||
func (t *FSTree) Close(_ context.Context) error {
|
||||
t.metrics.Close()
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -606,7 +606,7 @@ func (t *FSTree) Compressor() *compression.Config {
|
|||
}
|
||||
|
||||
// SetReportErrorFunc implements common.Storage.
|
||||
func (t *FSTree) SetReportErrorFunc(_ func(string, error)) {
|
||||
func (t *FSTree) SetReportErrorFunc(_ func(context.Context, string, error)) {
|
||||
// Do nothing, FSTree can encounter only one error which is returned.
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestObjectCounter(t *testing.T) {
|
|||
require.Equal(t, uint64(0), size)
|
||||
|
||||
defer func() {
|
||||
require.NoError(t, fst.Close())
|
||||
require.NoError(t, fst.Close(context.Background()))
|
||||
}()
|
||||
|
||||
addr := oidtest.Address()
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestControl(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
|||
require.NoError(t, s.Init())
|
||||
|
||||
objects := prepare(t, 10, s, minSize, maxSize)
|
||||
require.NoError(t, s.Close())
|
||||
require.NoError(t, s.Close(context.Background()))
|
||||
|
||||
require.NoError(t, s.Open(mode.ComponentReadOnly))
|
||||
for i := range objects {
|
||||
|
|
|
@ -15,7 +15,7 @@ func TestDelete(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
|||
s := cons(t)
|
||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, s.Init())
|
||||
defer func() { require.NoError(t, s.Close()) }()
|
||||
defer func() { require.NoError(t, s.Close(context.Background())) }()
|
||||
|
||||
objects := prepare(t, 4, s, minSize, maxSize)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestExists(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
|||
s := cons(t)
|
||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, s.Init())
|
||||
defer func() { require.NoError(t, s.Close()) }()
|
||||
defer func() { require.NoError(t, s.Close(context.Background())) }()
|
||||
|
||||
objects := prepare(t, 1, s, minSize, maxSize)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ func TestGet(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
|||
s := cons(t)
|
||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, s.Init())
|
||||
defer func() { require.NoError(t, s.Close()) }()
|
||||
defer func() { require.NoError(t, s.Close(context.Background())) }()
|
||||
|
||||
objects := prepare(t, 2, s, minSize, maxSize)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestGetRange(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
|||
s := cons(t)
|
||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, s.Init())
|
||||
defer func() { require.NoError(t, s.Close()) }()
|
||||
defer func() { require.NoError(t, s.Close(context.Background())) }()
|
||||
|
||||
objects := prepare(t, 1, s, minSize, maxSize)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestIterate(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
|||
s := cons(t)
|
||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, s.Init())
|
||||
defer func() { require.NoError(t, s.Close()) }()
|
||||
defer func() { require.NoError(t, s.Close(context.Background())) }()
|
||||
|
||||
objects := prepare(t, 10, s, minSize, maxSize)
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ func TestIterateObjects(t *testing.T) {
|
|||
require.NoError(t, blobStor.Open(context.Background(), mode.ReadWrite))
|
||||
|
||||
// initialize Blobstor
|
||||
require.NoError(t, blobStor.Init())
|
||||
require.NoError(t, blobStor.Init(context.Background()))
|
||||
|
||||
defer blobStor.Close()
|
||||
defer blobStor.Close(context.Background())
|
||||
|
||||
const objNum = 5
|
||||
|
||||
|
@ -118,7 +118,7 @@ func TestIterate_IgnoreErrors(t *testing.T) {
|
|||
})}
|
||||
bs := New(bsOpts...)
|
||||
require.NoError(t, bs.Open(ctx, mode.ReadWrite))
|
||||
require.NoError(t, bs.Init())
|
||||
require.NoError(t, bs.Init(ctx))
|
||||
|
||||
nopHandler := func(e common.IterationElement) error {
|
||||
return nil
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package memstore
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/compression"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
)
|
||||
|
@ -10,11 +12,11 @@ func (s *memstoreImpl) Open(mod mode.ComponentMode) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *memstoreImpl) Init() error { return nil }
|
||||
func (s *memstoreImpl) Close() error { return nil }
|
||||
func (s *memstoreImpl) Type() string { return Type }
|
||||
func (s *memstoreImpl) Path() string { return s.rootPath }
|
||||
func (s *memstoreImpl) SetCompressor(cc *compression.Config) { s.compression = cc }
|
||||
func (s *memstoreImpl) Compressor() *compression.Config { return s.compression }
|
||||
func (s *memstoreImpl) SetReportErrorFunc(func(string, error)) {}
|
||||
func (s *memstoreImpl) SetParentID(string) {}
|
||||
func (s *memstoreImpl) Init() error { return nil }
|
||||
func (s *memstoreImpl) Close(context.Context) error { return nil }
|
||||
func (s *memstoreImpl) Type() string { return Type }
|
||||
func (s *memstoreImpl) Path() string { return s.rootPath }
|
||||
func (s *memstoreImpl) SetCompressor(cc *compression.Config) { s.compression = cc }
|
||||
func (s *memstoreImpl) Compressor() *compression.Config { return s.compression }
|
||||
func (s *memstoreImpl) SetReportErrorFunc(func(context.Context, string, error)) {}
|
||||
func (s *memstoreImpl) SetParentID(string) {}
|
||||
|
|
|
@ -16,7 +16,7 @@ func TestSimpleLifecycle(t *testing.T) {
|
|||
s := New(
|
||||
WithRootPath("memstore"),
|
||||
)
|
||||
defer func() { require.NoError(t, s.Close()) }()
|
||||
defer func() { require.NoError(t, s.Close(context.Background())) }()
|
||||
require.NoError(t, s.Open(mode.ComponentReadWrite))
|
||||
require.NoError(t, s.Init())
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ func (b *BlobStor) SetMode(ctx context.Context, m mode.Mode) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
err := b.Close()
|
||||
err := b.Close(ctx)
|
||||
if err == nil {
|
||||
if err = b.openBlobStor(ctx, m); err == nil {
|
||||
err = b.Init()
|
||||
err = b.Init(ctx)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -106,7 +106,7 @@ func BenchmarkSubstorageReadPerf(b *testing.B) {
|
|||
b.Run(fmt.Sprintf("%s-%s", stEntry.desc, tt.desc), func(b *testing.B) {
|
||||
objGen := tt.objGen()
|
||||
st := stEntry.open(b)
|
||||
defer func() { require.NoError(b, st.Close()) }()
|
||||
defer func() { require.NoError(b, st.Close(context.Background())) }()
|
||||
|
||||
// Fill database
|
||||
var errG errgroup.Group
|
||||
|
@ -161,7 +161,7 @@ func BenchmarkSubstorageWritePerf(b *testing.B) {
|
|||
b.Run(fmt.Sprintf("%s-%s", stEntry.desc, genEntry.desc), func(b *testing.B) {
|
||||
gen := genEntry.create()
|
||||
st := stEntry.open(b)
|
||||
defer func() { require.NoError(b, st.Close()) }()
|
||||
defer func() { require.NoError(b, st.Close(context.Background())) }()
|
||||
|
||||
b.ResetTimer()
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
|
@ -200,7 +200,7 @@ func BenchmarkSubstorageIteratePerf(b *testing.B) {
|
|||
b.Run(fmt.Sprintf("%s-%s", stEntry.desc, tt.desc), func(b *testing.B) {
|
||||
objGen := tt.objGen()
|
||||
st := stEntry.open(b)
|
||||
defer func() { require.NoError(b, st.Close()) }()
|
||||
defer func() { require.NoError(b, st.Close(context.Background())) }()
|
||||
|
||||
// Fill database
|
||||
for range tt.size {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package teststore
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/compression"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
|
@ -17,7 +19,7 @@ type cfg struct {
|
|||
Path func() string
|
||||
SetCompressor func(cc *compression.Config)
|
||||
Compressor func() *compression.Config
|
||||
SetReportErrorFunc func(f func(string, error))
|
||||
SetReportErrorFunc func(f func(context.Context, string, error))
|
||||
|
||||
Get func(common.GetPrm) (common.GetRes, error)
|
||||
GetRange func(common.GetRangePrm) (common.GetRangeRes, error)
|
||||
|
@ -51,7 +53,7 @@ func WithCompressor(f func() *compression.Config) Option {
|
|||
return func(c *cfg) { c.overrides.Compressor = f }
|
||||
}
|
||||
|
||||
func WithReportErrorFunc(f func(func(string, error))) Option {
|
||||
func WithReportErrorFunc(f func(func(context.Context, string, error))) Option {
|
||||
return func(c *cfg) { c.overrides.SetReportErrorFunc = f }
|
||||
}
|
||||
|
||||
|
|
|
@ -77,14 +77,14 @@ func (s *TestStore) Init() error {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *TestStore) Close() error {
|
||||
func (s *TestStore) Close(ctx context.Context) error {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
switch {
|
||||
case s.overrides.Close != nil:
|
||||
return s.overrides.Close()
|
||||
case s.st != nil:
|
||||
return s.st.Close()
|
||||
return s.st.Close(ctx)
|
||||
default:
|
||||
panic("unexpected storage call: Close()")
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ func (s *TestStore) Compressor() *compression.Config {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *TestStore) SetReportErrorFunc(f func(string, error)) {
|
||||
func (s *TestStore) SetReportErrorFunc(f func(context.Context, string, error)) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
switch {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue