forked from TrueCloudLab/frostfs-node
Evgenii Stratonikov
0e31c12e63
Drop duplicate entities. Format entities. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com> Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package shard
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
|
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// ToMoveItPrm encapsulates parameters for ToMoveIt operation.
|
|
type ToMoveItPrm struct {
|
|
addr oid.Address
|
|
}
|
|
|
|
// ToMoveItRes encapsulates results of ToMoveIt operation.
|
|
type ToMoveItRes struct{}
|
|
|
|
// SetAddress sets object address that should be marked to move into another
|
|
// shard.
|
|
func (p *ToMoveItPrm) SetAddress(addr oid.Address) {
|
|
p.addr = addr
|
|
}
|
|
|
|
// ToMoveIt calls metabase.ToMoveIt method to mark object as relocatable to
|
|
// another shard.
|
|
func (s *Shard) ToMoveIt(prm ToMoveItPrm) (ToMoveItRes, error) {
|
|
s.m.RLock()
|
|
defer s.m.RUnlock()
|
|
|
|
m := s.info.Mode
|
|
if m.ReadOnly() {
|
|
return ToMoveItRes{}, ErrReadOnlyMode
|
|
} else if m.NoMetabase() {
|
|
return ToMoveItRes{}, ErrDegradedMode
|
|
}
|
|
|
|
var toMovePrm meta.ToMoveItPrm
|
|
toMovePrm.SetAddress(prm.addr)
|
|
|
|
_, err := s.metaBase.ToMoveIt(toMovePrm)
|
|
if err != nil {
|
|
s.log.Debug(logs.ShardCouldNotMarkObjectForShardRelocationInMetabase,
|
|
zap.String("error", err.Error()),
|
|
)
|
|
}
|
|
|
|
return ToMoveItRes{}, nil
|
|
}
|