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