From c9e3c9956ed9e5470438e76a8b41bde5f13467fa Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 23 Aug 2023 20:38:25 +0300 Subject: [PATCH] [#643] objsvc/put: Unify extraBroadcastEnabled usage Signed-off-by: Evgenii Stratonikov --- pkg/services/object/put/common.go | 5 +++++ pkg/services/object/put/distributed.go | 8 +------- pkg/services/object/put/single.go | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/services/object/put/common.go b/pkg/services/object/put/common.go index 97e127e19..6696a192b 100644 --- a/pkg/services/object/put/common.go +++ b/pkg/services/object/put/common.go @@ -9,6 +9,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" svcutil "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object_manager/placement" + objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" "go.uber.org/zap" ) @@ -112,3 +113,7 @@ func (n *nodeIterator) forEachAddress(ctx context.Context, traverser *placement. return false } + +func needAdditionalBroadcast(obj *objectSDK.Object, localOnly bool) bool { + return len(obj.Children()) > 0 || (!localOnly && (obj.Type() == objectSDK.TypeTombstone || obj.Type() == objectSDK.TypeLock)) +} diff --git a/pkg/services/object/put/distributed.go b/pkg/services/object/put/distributed.go index 577c5a15c..509f4aee0 100644 --- a/pkg/services/object/put/distributed.go +++ b/pkg/services/object/put/distributed.go @@ -130,12 +130,6 @@ func (t *distributedTarget) WriteObject(ctx context.Context, obj *objectSDK.Obje if t.objMeta, err = t.fmtValidator.ValidateContent(t.obj); err != nil { return fmt.Errorf("(%T) could not validate payload content: %w", t, err) } - - if len(t.obj.Children()) > 0 { - // enabling extra broadcast for linking objects - t.extraBroadcastEnabled = true - } - return t.iteratePlacement(ctx) } @@ -157,6 +151,6 @@ func (t *distributedTarget) iteratePlacement(ctx context.Context) error { id, _ := t.obj.ID() iter := t.cfg.newNodeIterator(append(t.placementOpts, placement.ForObject(id))) - iter.extraBroadcastEnabled = t.extraBroadcastEnabled + iter.extraBroadcastEnabled = needAdditionalBroadcast(t.obj, false /* Distributed target is for cluster-wide PUT */) return iter.forEachNode(ctx, t.sendObject) } diff --git a/pkg/services/object/put/single.go b/pkg/services/object/put/single.go index 8a7f192bb..adac194a0 100644 --- a/pkg/services/object/put/single.go +++ b/pkg/services/object/put/single.go @@ -151,7 +151,7 @@ func (s *Service) saveToNodes(ctx context.Context, obj *objectSDK.Object, req *o } iter := s.cfg.newNodeIterator(placementOptions) - iter.extraBroadcastEnabled = len(obj.Children()) > 0 || (!localOnly && (obj.Type() == objectSDK.TypeTombstone || obj.Type() == objectSDK.TypeLock)) + iter.extraBroadcastEnabled = needAdditionalBroadcast(obj, localOnly) signer := &putSingleRequestSigner{ req: req,