2022-01-25 11:54:35 +00:00
|
|
|
package engine
|
|
|
|
|
2023-04-12 14:01:29 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/pkg/tracing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
|
|
|
"go.opentelemetry.io/otel/attribute"
|
|
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
)
|
2022-01-25 11:54:35 +00:00
|
|
|
|
|
|
|
// RestoreShard restores objects from dump to the shard with provided identifier.
|
|
|
|
//
|
|
|
|
// Returns an error if shard is not read-only.
|
2023-04-12 14:01:29 +00:00
|
|
|
func (e *StorageEngine) RestoreShard(ctx context.Context, id *shard.ID, prm shard.RestorePrm) error {
|
|
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "StorageEngine.RestoreShard",
|
|
|
|
trace.WithAttributes(
|
|
|
|
attribute.String("shard_id", id.String()),
|
|
|
|
))
|
|
|
|
defer span.End()
|
|
|
|
|
2022-01-25 11:54:35 +00:00
|
|
|
e.mtx.RLock()
|
|
|
|
defer e.mtx.RUnlock()
|
|
|
|
|
|
|
|
sh, ok := e.shards[id.String()]
|
|
|
|
if !ok {
|
|
|
|
return errShardNotFound
|
|
|
|
}
|
|
|
|
|
2023-04-12 14:01:29 +00:00
|
|
|
_, err := sh.Restore(ctx, prm)
|
2022-01-25 11:54:35 +00:00
|
|
|
return err
|
|
|
|
}
|