2020-12-01 08:40:32 +00:00
|
|
|
package shard
|
|
|
|
|
|
|
|
import (
|
2020-12-08 09:56:14 +00:00
|
|
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
2022-01-26 12:11:13 +00:00
|
|
|
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
2020-12-01 08:40:32 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ToMoveItPrm encapsulates parameters for ToMoveIt operation.
|
|
|
|
type ToMoveItPrm struct {
|
2022-01-26 12:11:13 +00:00
|
|
|
addr *addressSDK.Address
|
2020-12-01 08:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ToMoveItRes encapsulates results of ToMoveIt operation.
|
|
|
|
type ToMoveItRes struct{}
|
|
|
|
|
2021-06-23 13:29:46 +00:00
|
|
|
// WithAddress sets object address that should be marked to move into another
|
2020-12-01 08:40:32 +00:00
|
|
|
// shard.
|
2022-01-26 12:11:13 +00:00
|
|
|
func (p *ToMoveItPrm) WithAddress(addr *addressSDK.Address) *ToMoveItPrm {
|
2020-12-01 08:40:32 +00:00
|
|
|
if p != nil {
|
|
|
|
p.addr = addr
|
|
|
|
}
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToMoveIt calls metabase.ToMoveIt method to mark object as relocatable to
|
|
|
|
// another shard.
|
|
|
|
func (s *Shard) ToMoveIt(prm *ToMoveItPrm) (*ToMoveItRes, error) {
|
2022-03-17 11:55:25 +00:00
|
|
|
if s.GetMode() != ModeReadWrite {
|
2021-12-27 11:04:07 +00:00
|
|
|
return nil, ErrReadOnlyMode
|
|
|
|
}
|
|
|
|
|
2020-12-08 09:56:14 +00:00
|
|
|
err := meta.ToMoveIt(s.metaBase, prm.addr)
|
2020-12-01 08:40:32 +00:00
|
|
|
if err != nil {
|
|
|
|
s.log.Debug("could not mark object for shard relocation in metabase",
|
|
|
|
zap.String("error", err.Error()),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return new(ToMoveItRes), nil
|
|
|
|
}
|