From 869d9e571c4598e2ffa224b315f9395b30beec01 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Sat, 5 Dec 2020 15:29:05 +0300 Subject: [PATCH] [#233] object/head: Remove getting the right child header With the update of the local storage engine, the headers of virtual objects are directly given. In this regard, the step with obtaining the the right child header is removed. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/object.go | 1 - pkg/services/object/delete/service.go | 5 ---- pkg/services/object/head/res.go | 6 +--- pkg/services/object/head/service.go | 38 +----------------------- pkg/services/object/range/service.go | 7 +---- pkg/services/object/rangehash/service.go | 7 +---- 6 files changed, 4 insertions(+), 60 deletions(-) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index c51c48e08..bad8f6199 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -343,7 +343,6 @@ func initObjectService(c *cfg) { headsvc.WithContainerSource(c.cfgObject.cnrStorage), headsvc.WithNetworkMapSource(c.cfgObject.netMapStorage), headsvc.WithLocalAddressSource(c), - headsvc.WithRightChildSearcher(searchsvc.NewRightChildSearcher(sSearch)), headsvc.WithWorkerPool(c.cfgObject.pool.head), headsvc.WithLogger(c.log), headsvc.WithClientOptions( diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index 5f812b29b..c45ce5047 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -133,11 +133,6 @@ func (s *Service) getRelations(ctx context.Context, prm *Prm) ([]*objectSDK.Addr id := hdr.ID() prev = hdr.PreviousID() - if rightChild := headResult.RightChild(); rightChild != nil { - id = rightChild.ID() - prev = rightChild.PreviousID() - } - addr.SetObjectID(id) res = append(res, addr) diff --git a/pkg/services/object/head/res.go b/pkg/services/object/head/res.go index cad3542ba..b64144f5e 100644 --- a/pkg/services/object/head/res.go +++ b/pkg/services/object/head/res.go @@ -5,13 +5,9 @@ import ( ) type Response struct { - hdr, rightChild *object.Object + hdr *object.Object } func (r *Response) Header() *object.Object { return r.hdr } - -func (r *Response) RightChild() *object.Object { - return r.rightChild -} diff --git a/pkg/services/object/head/service.go b/pkg/services/object/head/service.go index fc4a45c33..95ee00f68 100644 --- a/pkg/services/object/head/service.go +++ b/pkg/services/object/head/service.go @@ -36,8 +36,6 @@ type cfg struct { localAddrSrc network.LocalAddressSource - rightChildSearcher RelationSearcher - localHeader localHeader remoteHeader RemoteHeader @@ -67,37 +65,9 @@ func NewService(opts ...Option) *Service { } func (s *Service) Head(ctx context.Context, prm *Prm) (*Response, error) { - // try to receive header of physically stored - r, err := (&distributedHeader{ + return (&distributedHeader{ cfg: s.cfg, }).head(ctx, prm) - if err == nil || prm.common.LocalOnly() { - return r, err - } - - // try to find far right child that carries header of desired object - rightChildID, err := s.rightChildSearcher.SearchRelation(ctx, prm.addr, prm.common) - if err != nil { - return nil, errors.Wrapf(err, "(%T) could not find right child", s) - } - - addr := objectSDK.NewAddress() - addr.SetContainerID(prm.addr.ContainerID()) - addr.SetObjectID(rightChildID) - - r, err = s.Head(ctx, new(Prm).WithAddress(addr).WithCommonPrm(prm.common)) - if err != nil { - return nil, errors.Wrapf(err, "(%T) could not get right child header", s) - } - - rightChild := r.Header() - - // TODO: check if received parent has requested address - - return &Response{ - hdr: rightChild.GetParent(), - rightChild: rightChild, - }, nil } func WithKeyStorage(v *objutil.KeyStorage) Option { @@ -136,12 +106,6 @@ func WithLocalAddressSource(v network.LocalAddressSource) Option { } } -func WithRightChildSearcher(v RelationSearcher) Option { - return func(c *cfg) { - c.rightChildSearcher = v - } -} - func WithClientCache(v *cache.ClientCache) Option { return func(c *cfg) { c.remoteHeader.clientCache = v diff --git a/pkg/services/object/range/service.go b/pkg/services/object/range/service.go index 72f03118e..d6b991557 100644 --- a/pkg/services/object/range/service.go +++ b/pkg/services/object/range/service.go @@ -88,12 +88,7 @@ func (s *Service) GetRange(ctx context.Context, prm *Prm) (*Result, error) { return nil, errors.Errorf("(%T) requested payload range is out-of-bounds", s) } - right := headResult.RightChild() - if right == nil { - right = origin - } - - rngTraverser := objutil.NewRangeTraverser(originSize, right, prm.rng) + rngTraverser := objutil.NewRangeTraverser(originSize, origin, prm.rng) if err := s.fillTraverser(ctx, prm, rngTraverser); err != nil { return nil, errors.Wrapf(err, "(%T) could not fill range traverser", s) } diff --git a/pkg/services/object/rangehash/service.go b/pkg/services/object/rangehash/service.go index c2dd9ef5f..d600802e1 100644 --- a/pkg/services/object/rangehash/service.go +++ b/pkg/services/object/rangehash/service.go @@ -103,16 +103,11 @@ func (s *Service) GetRangeHash(ctx context.Context, prm *Prm) (*Response, error) } } - right := headResult.RightChild() - if right == nil { - right = origin - } - borderRng := new(object.Range) borderRng.SetOffset(minLeft) borderRng.SetLength(maxRight - minLeft) - return s.getHashes(ctx, prm, objutil.NewRangeTraverser(originSize, right, borderRng)) + return s.getHashes(ctx, prm, objutil.NewRangeTraverser(originSize, origin, borderRng)) } func (s *Service) getHashes(ctx context.Context, prm *Prm, traverser *objutil.RangeTraverser) (*Response, error) {