forked from TrueCloudLab/frostfs-node
[#661] blobstor: Add Rebuild implementation
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
c1667a11d2
commit
a531eaf8bc
8 changed files with 72 additions and 2 deletions
|
@ -529,4 +529,6 @@ const (
|
|||
BlobovniczaTreeFixingFileExtensionForFile = "fixing blobovnicza file extension..."
|
||||
BlobovniczaTreeFixingFileExtensionCompletedSuccessfully = "fixing blobovnicza file extension completed successfully"
|
||||
BlobovniczaTreeFixingFileExtensionFailed = "failed to fix blobovnicza file extension"
|
||||
BlobstorRebuildFailedToRebuildStorages = "failed to rebuild storages"
|
||||
BlobstorRebuildRebuildStoragesCompleted = "storages rebuild completed"
|
||||
)
|
||||
|
|
11
pkg/local_object_storage/blobstor/blobovniczatree/rebuild.go
Normal file
11
pkg/local_object_storage/blobstor/blobovniczatree/rebuild.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package blobovniczatree
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
)
|
||||
|
||||
func (b *Blobovniczas) Rebuild(_ context.Context, _ common.RebuildPrm) (common.RebuildRes, error) {
|
||||
return common.RebuildRes{}, nil
|
||||
}
|
20
pkg/local_object_storage/blobstor/common/rebuild.go
Normal file
20
pkg/local_object_storage/blobstor/common/rebuild.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
)
|
||||
|
||||
type RebuildRes struct {
|
||||
ObjectsMoved uint64
|
||||
FilesRemoved uint64
|
||||
}
|
||||
|
||||
type RebuildPrm struct {
|
||||
MetaStorage MetaStorage
|
||||
}
|
||||
|
||||
type MetaStorage interface {
|
||||
UpdateStorageID(ctx context.Context, obj *objectSDK.Object, storageID []byte) error
|
||||
}
|
|
@ -30,4 +30,5 @@ type Storage interface {
|
|||
Put(context.Context, PutPrm) (PutRes, error)
|
||||
Delete(context.Context, DeletePrm) (DeleteRes, error)
|
||||
Iterate(context.Context, IteratePrm) (IterateRes, error)
|
||||
Rebuild(context.Context, RebuildPrm) (RebuildRes, error)
|
||||
}
|
||||
|
|
|
@ -574,3 +574,7 @@ func (t *FSTree) SetReportErrorFunc(_ func(string, error)) {
|
|||
func (t *FSTree) SetParentID(parentID string) {
|
||||
t.metrics.SetParentID(parentID)
|
||||
}
|
||||
|
||||
func (t *FSTree) Rebuild(_ context.Context, _ common.RebuildPrm) (common.RebuildRes, error) {
|
||||
return common.RebuildRes{}, nil
|
||||
}
|
||||
|
|
|
@ -159,3 +159,7 @@ func (s *memstoreImpl) Iterate(_ context.Context, req common.IteratePrm) (common
|
|||
}
|
||||
return common.IterateRes{}, nil
|
||||
}
|
||||
|
||||
func (s *memstoreImpl) Rebuild(_ context.Context, _ common.RebuildPrm) (common.RebuildRes, error) {
|
||||
return common.RebuildRes{}, nil
|
||||
}
|
||||
|
|
|
@ -3,13 +3,37 @@ package blobstor
|
|||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type StorageIDUpdate interface {
|
||||
UpdateStorageID(ctx context.Context, obj *objectSDK.Object, storageID []byte) error
|
||||
}
|
||||
|
||||
func (b *BlobStor) Rebuild(_ context.Context, _ StorageIDUpdate) error {
|
||||
return nil
|
||||
func (b *BlobStor) Rebuild(ctx context.Context, upd StorageIDUpdate) error {
|
||||
var summary common.RebuildRes
|
||||
var rErr error
|
||||
for _, storage := range b.storage {
|
||||
res, err := storage.Storage.Rebuild(ctx, common.RebuildPrm{
|
||||
MetaStorage: upd,
|
||||
})
|
||||
summary.FilesRemoved += res.FilesRemoved
|
||||
summary.ObjectsMoved += res.ObjectsMoved
|
||||
if err != nil {
|
||||
b.log.Error(logs.BlobstorRebuildFailedToRebuildStorages,
|
||||
zap.String("failed_storage_path", storage.Storage.Path()),
|
||||
zap.String("failed_storage_type", storage.Storage.Type()),
|
||||
zap.Error(err))
|
||||
rErr = err
|
||||
break
|
||||
}
|
||||
}
|
||||
b.log.Info(logs.BlobstorRebuildRebuildStoragesCompleted,
|
||||
zap.Bool("success", rErr == nil),
|
||||
zap.Uint64("total_files_removed", summary.FilesRemoved),
|
||||
zap.Uint64("total_objects_moved", summary.ObjectsMoved))
|
||||
return rErr
|
||||
}
|
||||
|
|
|
@ -229,3 +229,7 @@ func (s *TestStore) Iterate(ctx context.Context, req common.IteratePrm) (common.
|
|||
}
|
||||
|
||||
func (s *TestStore) SetParentID(string) {}
|
||||
|
||||
func (s *TestStore) Rebuild(_ context.Context, _ common.RebuildPrm) (common.RebuildRes, error) {
|
||||
return common.RebuildRes{}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue