[#1147] node: Implement Lock\Delete requests for EC object

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-05-27 22:07:43 +03:00 committed by Evgenii Stratonikov
parent 88b8ddd902
commit 6130650bb6
20 changed files with 371 additions and 66 deletions

View file

@ -13,12 +13,14 @@ import (
// ExistsPrm groups the parameters of Exists operation.
type ExistsPrm struct {
addr oid.Address
addr oid.Address
paddr oid.Address
}
// ExistsRes groups the resulting values of Exists operation.
type ExistsRes struct {
ex bool
lc bool
}
// SetAddress is an Exists option to set object checked for existence.
@ -26,11 +28,21 @@ func (p *ExistsPrm) SetAddress(addr oid.Address) {
p.addr = addr
}
// SetParentAddress is an Exists option to set parent object checked for existence.
func (p *ExistsPrm) SetParentAddress(addr oid.Address) {
p.paddr = addr
}
// Exists returns the fact that the object is in the shard.
func (p ExistsRes) Exists() bool {
return p.ex
}
// Locked returns the fact that the object is locked.
func (p ExistsRes) Locked() bool {
return p.lc
}
// Exists checks if object is presented in shard.
//
// Returns any error encountered that does not allow to
@ -48,6 +60,7 @@ func (s *Shard) Exists(ctx context.Context, prm ExistsPrm) (ExistsRes, error) {
defer span.End()
var exists bool
var locked bool
var err error
s.m.RLock()
@ -65,13 +78,16 @@ func (s *Shard) Exists(ctx context.Context, prm ExistsPrm) (ExistsRes, error) {
} else {
var existsPrm meta.ExistsPrm
existsPrm.SetAddress(prm.addr)
existsPrm.SetParent(prm.paddr)
var res meta.ExistsRes
res, err = s.metaBase.Exists(ctx, existsPrm)
exists = res.Exists()
locked = res.Locked()
}
return ExistsRes{
ex: exists,
lc: locked,
}, err
}