diff --git a/pkg/services/object/delete/exec.go b/pkg/services/object/delete/exec.go index d3fc3db97..31666f2e7 100644 --- a/pkg/services/object/delete/exec.go +++ b/pkg/services/object/delete/exec.go @@ -5,9 +5,7 @@ import ( "strconv" objectV2 "github.com/TrueCloudLab/frostfs-api-go/v2/object" - "github.com/TrueCloudLab/frostfs-node/pkg/services/object/util" "github.com/TrueCloudLab/frostfs-node/pkg/util/logger" - cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id" "github.com/TrueCloudLab/frostfs-sdk-go/object" oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id" "go.uber.org/zap" @@ -44,37 +42,17 @@ const ( func (exec *execCtx) setLogger(l *logger.Logger) { exec.log = &logger.Logger{Logger: l.With( zap.String("request", "DELETE"), - zap.Stringer("address", exec.address()), - zap.Bool("local", exec.isLocal()), + zap.Stringer("address", exec.prm.addr), + zap.Bool("local", exec.prm.common.LocalOnly()), zap.Bool("with session", exec.prm.common.SessionToken() != nil), zap.Bool("with bearer", exec.prm.common.BearerToken() != nil), )} } -func (exec execCtx) context() context.Context { - return exec.ctx -} - -func (exec execCtx) isLocal() bool { - return exec.prm.common.LocalOnly() -} - -func (exec *execCtx) address() oid.Address { - return exec.prm.addr -} - -func (exec *execCtx) containerID() cid.ID { - return exec.prm.addr.Container() -} - -func (exec *execCtx) commonParameters() *util.CommonPrm { - return exec.prm.common -} - func (exec *execCtx) newAddress(id oid.ID) oid.Address { var a oid.Address a.SetObject(id) - a.SetContainer(exec.containerID()) + a.SetContainer(exec.prm.addr.Container()) return a } @@ -240,11 +218,11 @@ func (exec *execCtx) initTombstoneObject() bool { } exec.tombstoneObj = object.New() - exec.tombstoneObj.SetContainerID(exec.containerID()) + exec.tombstoneObj.SetContainerID(exec.prm.addr.Container()) exec.tombstoneObj.SetType(object.TypeTombstone) exec.tombstoneObj.SetPayload(payload) - tokenSession := exec.commonParameters().SessionToken() + tokenSession := exec.prm.common.SessionToken() if tokenSession != nil { issuer := tokenSession.Issuer() exec.tombstoneObj.SetOwnerID(&issuer) diff --git a/pkg/services/object/delete/local.go b/pkg/services/object/delete/local.go index 225ef2d74..3b17909dc 100644 --- a/pkg/services/object/delete/local.go +++ b/pkg/services/object/delete/local.go @@ -36,7 +36,7 @@ func (exec *execCtx) formTombstone() (ok bool) { exec.tombstone.SetExpirationEpoch( exec.svc.netInfo.CurrentEpoch() + tsLifetime, ) - exec.addMembers([]oid.ID{exec.address().Object()}) + exec.addMembers([]oid.ID{exec.prm.addr.Object()}) exec.log.Debug("forming split info...") diff --git a/pkg/services/object/delete/util.go b/pkg/services/object/delete/util.go index 765c5a2f1..e608b3b4e 100644 --- a/pkg/services/object/delete/util.go +++ b/pkg/services/object/delete/util.go @@ -24,12 +24,12 @@ func (w *headSvcWrapper) headAddress(exec *execCtx, addr oid.Address) (*object.O wr := getsvc.NewSimpleObjectWriter() p := getsvc.HeadPrm{} - p.SetCommonParameters(exec.commonParameters()) + p.SetCommonParameters(exec.prm.common) p.SetHeaderWriter(wr) p.WithRawFlag(true) p.WithAddress(addr) - err := (*getsvc.Service)(w).Head(exec.context(), p) + err := (*getsvc.Service)(w).Head(exec.ctx, p) if err != nil { return nil, err } @@ -38,7 +38,7 @@ func (w *headSvcWrapper) headAddress(exec *execCtx, addr oid.Address) (*object.O } func (w *headSvcWrapper) splitInfo(exec *execCtx) (*object.SplitInfo, error) { - _, err := w.headAddress(exec, exec.address()) + _, err := w.headAddress(exec, exec.prm.addr) var errSplitInfo *object.SplitInfoError @@ -89,11 +89,11 @@ func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]oid.ID, error) { p := searchsvc.Prm{} p.SetWriter(wr) - p.SetCommonParameters(exec.commonParameters()) - p.WithContainerID(exec.containerID()) + p.SetCommonParameters(exec.prm.common) + p.WithContainerID(exec.prm.addr.Container()) p.WithSearchFilters(fs) - err := (*searchsvc.Service)(w).Search(exec.context(), p) + err := (*searchsvc.Service)(w).Search(exec.ctx, p) if err != nil { return nil, err } @@ -108,7 +108,7 @@ func (s *simpleIDWriter) WriteIDs(ids []oid.ID) error { } func (w *putSvcWrapper) put(exec *execCtx) (*oid.ID, error) { - streamer, err := (*putsvc.Service)(w).Put(exec.context()) + streamer, err := (*putsvc.Service)(w).Put(exec.ctx) if err != nil { return nil, err } @@ -116,7 +116,7 @@ func (w *putSvcWrapper) put(exec *execCtx) (*oid.ID, error) { payload := exec.tombstoneObj.Payload() initPrm := new(putsvc.PutInitPrm). - WithCommonPrm(exec.commonParameters()). + WithCommonPrm(exec.prm.common). WithObject(exec.tombstoneObj.CutPayload()) err = streamer.Init(initPrm) diff --git a/pkg/services/object/get/assemble.go b/pkg/services/object/get/assemble.go index 89d400087..fd02863d0 100644 --- a/pkg/services/object/get/assemble.go +++ b/pkg/services/object/get/assemble.go @@ -33,7 +33,7 @@ func (exec *execCtx) assemble() { exec.log.Debug("trying to assemble the object...") - splitInfo := exec.splitInfo() + splitInfo := exec.splitInfo childID, ok := splitInfo.Link() if !ok { @@ -47,7 +47,7 @@ func (exec *execCtx) assemble() { prev, children := exec.initFromChild(childID) if len(children) > 0 { - if exec.ctxRange() == nil { + if exec.prm.rng == nil { if ok := exec.writeCollectedHeader(); ok { exec.overtakePayloadDirectly(children, nil, true) } @@ -100,7 +100,7 @@ func (exec *execCtx) initFromChild(obj oid.ID) (prev *oid.ID, children []oid.ID) var payload []byte - if rng := exec.ctxRange(); rng != nil { + if rng := exec.prm.rng; rng != nil { seekOff := rng.GetOffset() seekLen := rng.GetLength() seekTo := seekOff + seekLen @@ -146,7 +146,7 @@ func (exec *execCtx) initFromChild(obj oid.ID) (prev *oid.ID, children []oid.ID) } func (exec *execCtx) overtakePayloadDirectly(children []oid.ID, rngs []objectSDK.Range, checkRight bool) { - withRng := len(rngs) > 0 && exec.ctxRange() != nil + withRng := len(rngs) > 0 && exec.prm.rng != nil for i := range children { var r *objectSDK.Range @@ -194,7 +194,7 @@ func (exec *execCtx) buildChainInReverse(prev oid.ID) ([]oid.ID, []objectSDK.Ran var ( chain = make([]oid.ID, 0) rngs = make([]objectSDK.Range, 0) - seekRng = exec.ctxRange() + seekRng = exec.prm.rng from = seekRng.GetOffset() to = from + seekRng.GetLength() diff --git a/pkg/services/object/get/container.go b/pkg/services/object/get/container.go index f892ab1b7..88dae275c 100644 --- a/pkg/services/object/get/container.go +++ b/pkg/services/object/get/container.go @@ -8,12 +8,12 @@ import ( ) func (exec *execCtx) executeOnContainer() { - if exec.isLocal() { + if exec.prm.common.LocalOnly() { exec.log.Debug("return result directly") return } - lookupDepth := exec.netmapLookupDepth() + lookupDepth := exec.prm.common.NetmapLookupDepth() exec.log.Debug("trying to execute in container...", zap.Uint64("netmap lookup depth", lookupDepth), @@ -47,12 +47,12 @@ func (exec *execCtx) processCurrentEpoch() bool { zap.Uint64("number", exec.curProcEpoch), ) - traverser, ok := exec.generateTraverser(exec.address()) + traverser, ok := exec.generateTraverser(exec.prm.addr) if !ok { return true } - ctx, cancel := context.WithCancel(exec.context()) + ctx, cancel := context.WithCancel(exec.ctx) defer cancel() exec.status = statusUndefined diff --git a/pkg/services/object/get/exec.go b/pkg/services/object/get/exec.go index 5755973f7..ea2677f35 100644 --- a/pkg/services/object/get/exec.go +++ b/pkg/services/object/get/exec.go @@ -10,7 +10,6 @@ import ( "github.com/TrueCloudLab/frostfs-node/pkg/services/object/util" "github.com/TrueCloudLab/frostfs-node/pkg/services/object_manager/placement" "github.com/TrueCloudLab/frostfs-node/pkg/util/logger" - cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id" objectSDK "github.com/TrueCloudLab/frostfs-sdk-go/object" oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id" "go.uber.org/zap" @@ -30,7 +29,7 @@ type execCtx struct { statusError - infoSplit *objectSDK.SplitInfo + splitInfo *objectSDK.SplitInfo log *logger.Logger @@ -38,7 +37,7 @@ type execCtx struct { curOff uint64 - head bool + headOnly bool curProcEpoch uint64 } @@ -55,7 +54,7 @@ const ( func headOnly() execOption { return func(c *execCtx) { - c.head = true + c.headOnly = true } } @@ -67,45 +66,29 @@ func withPayloadRange(r *objectSDK.Range) execOption { func (exec *execCtx) setLogger(l *logger.Logger) { req := "GET" - if exec.headOnly() { + if exec.headOnly { req = "HEAD" - } else if exec.ctxRange() != nil { + } else if exec.prm.rng != nil { req = "GET_RANGE" } exec.log = &logger.Logger{Logger: l.With( zap.String("request", req), - zap.Stringer("address", exec.address()), - zap.Bool("raw", exec.isRaw()), - zap.Bool("local", exec.isLocal()), + zap.Stringer("address", exec.prm.addr), + zap.Bool("raw", exec.prm.raw), + zap.Bool("local", exec.prm.common.LocalOnly()), zap.Bool("with session", exec.prm.common.SessionToken() != nil), zap.Bool("with bearer", exec.prm.common.BearerToken() != nil), )} } -func (exec execCtx) context() context.Context { - return exec.ctx -} - -func (exec execCtx) isLocal() bool { - return exec.prm.common.LocalOnly() -} - -func (exec execCtx) isRaw() bool { - return exec.prm.raw -} - -func (exec execCtx) address() oid.Address { - return exec.prm.addr -} - // isChild checks if reading object is a parent of the given object. // Object without reference to the parent (only children with the parent header // have it) is automatically considered as child: this should be guaranteed by // upper level logic. func (exec execCtx) isChild(obj *objectSDK.Object) bool { par := obj.Parent() - return par == nil || equalAddresses(exec.address(), object.AddressOf(par)) + return par == nil || equalAddresses(exec.prm.addr, object.AddressOf(par)) } func (exec execCtx) key() (*ecdsa.PrivateKey, error) { @@ -128,35 +111,11 @@ func (exec execCtx) key() (*ecdsa.PrivateKey, error) { } func (exec *execCtx) canAssemble() bool { - return exec.svc.assembly && !exec.isRaw() && !exec.headOnly() && !exec.isLocal() -} - -func (exec *execCtx) splitInfo() *objectSDK.SplitInfo { - return exec.infoSplit -} - -func (exec *execCtx) containerID() cid.ID { - return exec.address().Container() -} - -func (exec *execCtx) ctxRange() *objectSDK.Range { - return exec.prm.rng -} - -func (exec *execCtx) headOnly() bool { - return exec.head -} - -func (exec *execCtx) netmapEpoch() uint64 { - return exec.prm.common.NetmapEpoch() -} - -func (exec *execCtx) netmapLookupDepth() uint64 { - return exec.prm.common.NetmapLookupDepth() + return exec.svc.assembly && !exec.prm.raw && !exec.headOnly && !exec.prm.common.LocalOnly() } func (exec *execCtx) initEpoch() bool { - exec.curProcEpoch = exec.netmapEpoch() + exec.curProcEpoch = exec.prm.common.NetmapEpoch() if exec.curProcEpoch > 0 { return true } @@ -207,10 +166,10 @@ func (exec *execCtx) getChild(id oid.ID, rng *objectSDK.Range, withHdr bool) (*o p.objWriter = w p.SetRange(rng) - p.addr.SetContainer(exec.containerID()) + p.addr.SetContainer(exec.prm.addr.Container()) p.addr.SetObject(id) - exec.statusError = exec.svc.get(exec.context(), p.commonPrm, withPayloadRange(rng)) + exec.statusError = exec.svc.get(exec.ctx, p.commonPrm, withPayloadRange(rng)) child := w.Object() ok := exec.status == statusOK @@ -228,7 +187,7 @@ func (exec *execCtx) getChild(id oid.ID, rng *objectSDK.Range, withHdr bool) (*o func (exec *execCtx) headChild(id oid.ID) (*objectSDK.Object, bool) { p := exec.prm p.common = p.common.WithLocalOnly(false) - p.addr.SetContainer(exec.containerID()) + p.addr.SetContainer(exec.prm.addr.Container()) p.addr.SetObject(id) prm := HeadPrm{ @@ -238,7 +197,7 @@ func (exec *execCtx) headChild(id oid.ID) (*objectSDK.Object, bool) { w := NewSimpleObjectWriter() prm.SetHeaderWriter(w) - err := exec.svc.Head(exec.context(), prm) + err := exec.svc.Head(exec.ctx, prm) switch { default: @@ -298,7 +257,7 @@ func mergeSplitInfo(dst, src *objectSDK.SplitInfo) { } func (exec *execCtx) writeCollectedHeader() bool { - if exec.ctxRange() != nil { + if exec.prm.rng != nil { return true } @@ -323,7 +282,7 @@ func (exec *execCtx) writeCollectedHeader() bool { } func (exec *execCtx) writeObjectPayload(obj *objectSDK.Object) bool { - if exec.headOnly() { + if exec.headOnly { return true } @@ -351,12 +310,6 @@ func (exec *execCtx) writeCollectedObject() { } } -// isForwardingEnabled returns true if common execution -// parameters has request forwarding closure set. -func (exec execCtx) isForwardingEnabled() bool { - return exec.prm.forwarder != nil -} - // disableForwarding removes request forwarding closure from common // parameters, so it won't be inherited in new execution contexts. func (exec *execCtx) disableForwarding() { diff --git a/pkg/services/object/get/get.go b/pkg/services/object/get/get.go index 829deaffa..24333f2df 100644 --- a/pkg/services/object/get/get.go +++ b/pkg/services/object/get/get.go @@ -69,7 +69,7 @@ func (s *Service) get(ctx context.Context, prm commonPrm, opts ...execOption) st prm: RangePrm{ commonPrm: prm, }, - infoSplit: object.NewSplitInfo(), + splitInfo: object.NewSplitInfo(), } for i := range opts { diff --git a/pkg/services/object/get/get_test.go b/pkg/services/object/get/get_test.go index 6167ad180..93abb161f 100644 --- a/pkg/services/object/get/get_test.go +++ b/pkg/services/object/get/get_test.go @@ -118,7 +118,7 @@ func newTestClient() *testClient { } func (c *testClient) getObject(exec *execCtx, _ client.NodeInfo) (*objectSDK.Object, error) { - v, ok := c.results[exec.address().EncodeToString()] + v, ok := c.results[exec.prm.addr.EncodeToString()] if !ok { var errNotFound apistatus.ObjectNotFound @@ -129,7 +129,7 @@ func (c *testClient) getObject(exec *execCtx, _ client.NodeInfo) (*objectSDK.Obj return nil, v.err } - return cutToRange(v.obj, exec.ctxRange()), nil + return cutToRange(v.obj, exec.prm.rng), nil } func (c *testClient) addResult(addr oid.Address, obj *objectSDK.Object, err error) { @@ -143,7 +143,7 @@ func (s *testStorage) get(exec *execCtx) (*objectSDK.Object, error) { var ( ok bool obj *objectSDK.Object - sAddr = exec.address().EncodeToString() + sAddr = exec.prm.addr.EncodeToString() ) if _, ok = s.inhumed[sAddr]; ok { @@ -157,7 +157,7 @@ func (s *testStorage) get(exec *execCtx) (*objectSDK.Object, error) { } if obj, ok = s.phy[sAddr]; ok { - return cutToRange(obj, exec.ctxRange()), nil + return cutToRange(obj, exec.prm.rng), nil } var errNotFound apistatus.ObjectNotFound diff --git a/pkg/services/object/get/local.go b/pkg/services/object/get/local.go index c0ad1b2a1..d2533661d 100644 --- a/pkg/services/object/get/local.go +++ b/pkg/services/object/get/local.go @@ -34,8 +34,8 @@ func (exec *execCtx) executeLocal() { exec.err = errRemoved case errors.As(err, &errSplitInfo): exec.status = statusVIRTUAL - mergeSplitInfo(exec.splitInfo(), errSplitInfo.SplitInfo()) - exec.err = objectSDK.NewSplitInfoError(exec.infoSplit) + mergeSplitInfo(exec.splitInfo, errSplitInfo.SplitInfo()) + exec.err = objectSDK.NewSplitInfoError(exec.splitInfo) case errors.As(err, &errOutOfRange): exec.status = statusOutOfRange exec.err = errOutOfRange diff --git a/pkg/services/object/get/remote.go b/pkg/services/object/get/remote.go index ea7bf2393..5470bd69a 100644 --- a/pkg/services/object/get/remote.go +++ b/pkg/services/object/get/remote.go @@ -53,8 +53,8 @@ func (exec *execCtx) processNode(ctx context.Context, info client.NodeInfo) bool exec.err = errOutOfRange case errors.As(err, &errSplitInfo): exec.status = statusVIRTUAL - mergeSplitInfo(exec.splitInfo(), errSplitInfo.SplitInfo()) - exec.err = objectSDK.NewSplitInfoError(exec.infoSplit) + mergeSplitInfo(exec.splitInfo, errSplitInfo.SplitInfo()) + exec.err = objectSDK.NewSplitInfoError(exec.splitInfo) } return exec.status != statusUndefined diff --git a/pkg/services/object/get/util.go b/pkg/services/object/get/util.go index abda3d0bf..927cd80eb 100644 --- a/pkg/services/object/get/util.go +++ b/pkg/services/object/get/util.go @@ -87,7 +87,7 @@ func (c *clientCacheWrapper) get(info coreclient.NodeInfo) (getClient, error) { } func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*object.Object, error) { - if exec.isForwardingEnabled() { + if exec.prm.forwarder != nil { return exec.prm.forwarder(info, c.client) } @@ -96,20 +96,20 @@ func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*obj return nil, err } - if exec.headOnly() { + if exec.headOnly { var prm internalclient.HeadObjectPrm - prm.SetContext(exec.context()) + prm.SetContext(exec.ctx) prm.SetClient(c.client) prm.SetTTL(exec.prm.common.TTL()) prm.SetNetmapEpoch(exec.curProcEpoch) - prm.SetAddress(exec.address()) + prm.SetAddress(exec.prm.addr) prm.SetPrivateKey(key) prm.SetSessionToken(exec.prm.common.SessionToken()) prm.SetBearerToken(exec.prm.common.BearerToken()) prm.SetXHeaders(exec.prm.common.XHeaders()) - if exec.isRaw() { + if exec.prm.raw { prm.SetRawFlag() } @@ -122,21 +122,21 @@ func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*obj } // we don't specify payload writer because we accumulate // the object locally (even huge). - if rng := exec.ctxRange(); rng != nil { + if rng := exec.prm.rng; rng != nil { var prm internalclient.PayloadRangePrm - prm.SetContext(exec.context()) + prm.SetContext(exec.ctx) prm.SetClient(c.client) prm.SetTTL(exec.prm.common.TTL()) prm.SetNetmapEpoch(exec.curProcEpoch) - prm.SetAddress(exec.address()) + prm.SetAddress(exec.prm.addr) prm.SetPrivateKey(key) prm.SetSessionToken(exec.prm.common.SessionToken()) prm.SetBearerToken(exec.prm.common.BearerToken()) prm.SetXHeaders(exec.prm.common.XHeaders()) prm.SetRange(rng) - if exec.isRaw() { + if exec.prm.raw { prm.SetRawFlag() } @@ -173,17 +173,17 @@ func (c *clientWrapper) getObject(exec *execCtx, info coreclient.NodeInfo) (*obj func (c *clientWrapper) get(exec *execCtx, key *ecdsa.PrivateKey) (*object.Object, error) { var prm internalclient.GetObjectPrm - prm.SetContext(exec.context()) + prm.SetContext(exec.ctx) prm.SetClient(c.client) prm.SetTTL(exec.prm.common.TTL()) prm.SetNetmapEpoch(exec.curProcEpoch) - prm.SetAddress(exec.address()) + prm.SetAddress(exec.prm.addr) prm.SetPrivateKey(key) prm.SetSessionToken(exec.prm.common.SessionToken()) prm.SetBearerToken(exec.prm.common.BearerToken()) prm.SetXHeaders(exec.prm.common.XHeaders()) - if exec.isRaw() { + if exec.prm.raw { prm.SetRawFlag() } @@ -196,10 +196,10 @@ func (c *clientWrapper) get(exec *execCtx, key *ecdsa.PrivateKey) (*object.Objec } func (e *storageEngineWrapper) get(exec *execCtx) (*object.Object, error) { - if exec.headOnly() { + if exec.headOnly { var headPrm engine.HeadPrm - headPrm.WithAddress(exec.address()) - headPrm.WithRaw(exec.isRaw()) + headPrm.WithAddress(exec.prm.addr) + headPrm.WithRaw(exec.prm.raw) r, err := e.engine.Head(headPrm) if err != nil { @@ -207,9 +207,9 @@ func (e *storageEngineWrapper) get(exec *execCtx) (*object.Object, error) { } return r.Header(), nil - } else if rng := exec.ctxRange(); rng != nil { + } else if rng := exec.prm.rng; rng != nil { var getRange engine.RngPrm - getRange.WithAddress(exec.address()) + getRange.WithAddress(exec.prm.addr) getRange.WithPayloadRange(rng) r, err := e.engine.GetRange(getRange) @@ -220,7 +220,7 @@ func (e *storageEngineWrapper) get(exec *execCtx) (*object.Object, error) { return r.Object(), nil } else { var getPrm engine.GetPrm - getPrm.WithAddress(exec.address()) + getPrm.WithAddress(exec.prm.addr) r, err := e.engine.Get(getPrm) if err != nil { diff --git a/pkg/services/object/search/container.go b/pkg/services/object/search/container.go index b9db02827..c4c54d011 100644 --- a/pkg/services/object/search/container.go +++ b/pkg/services/object/search/container.go @@ -10,12 +10,12 @@ import ( ) func (exec *execCtx) executeOnContainer() { - if exec.isLocal() { + if exec.prm.common.LocalOnly() { exec.log.Debug("return result directly") return } - lookupDepth := exec.netmapLookupDepth() + lookupDepth := exec.prm.common.NetmapLookupDepth() exec.log.Debug("trying to execute in container...", zap.Uint64("netmap lookup depth", lookupDepth), @@ -52,12 +52,12 @@ func (exec *execCtx) processCurrentEpoch() bool { zap.Uint64("number", exec.curProcEpoch), ) - traverser, ok := exec.generateTraverser(exec.containerID()) + traverser, ok := exec.generateTraverser(exec.prm.cnr) if !ok { return true } - ctx, cancel := context.WithCancel(exec.context()) + ctx, cancel := context.WithCancel(exec.ctx) defer cancel() for { diff --git a/pkg/services/object/search/exec.go b/pkg/services/object/search/exec.go index 92f1edd18..7ba3d1466 100644 --- a/pkg/services/object/search/exec.go +++ b/pkg/services/object/search/exec.go @@ -6,7 +6,6 @@ import ( "github.com/TrueCloudLab/frostfs-node/pkg/services/object_manager/placement" "github.com/TrueCloudLab/frostfs-node/pkg/util/logger" cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id" - "github.com/TrueCloudLab/frostfs-sdk-go/object" oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id" "go.uber.org/zap" ) @@ -44,39 +43,15 @@ func (exec *execCtx) prepare() { func (exec *execCtx) setLogger(l *logger.Logger) { exec.log = &logger.Logger{Logger: l.With( zap.String("request", "SEARCH"), - zap.Stringer("container", exec.containerID()), - zap.Bool("local", exec.isLocal()), + zap.Stringer("container", exec.prm.cnr), + zap.Bool("local", exec.prm.common.LocalOnly()), zap.Bool("with session", exec.prm.common.SessionToken() != nil), zap.Bool("with bearer", exec.prm.common.BearerToken() != nil), )} } -func (exec execCtx) context() context.Context { - return exec.ctx -} - -func (exec execCtx) isLocal() bool { - return exec.prm.common.LocalOnly() -} - -func (exec *execCtx) containerID() cid.ID { - return exec.prm.cnr -} - -func (exec *execCtx) searchFilters() object.SearchFilters { - return exec.prm.filters -} - -func (exec *execCtx) netmapEpoch() uint64 { - return exec.prm.common.NetmapEpoch() -} - -func (exec *execCtx) netmapLookupDepth() uint64 { - return exec.prm.common.NetmapLookupDepth() -} - func (exec *execCtx) initEpoch() bool { - exec.curProcEpoch = exec.netmapEpoch() + exec.curProcEpoch = exec.prm.common.NetmapEpoch() if exec.curProcEpoch > 0 { return true } diff --git a/pkg/services/object/search/search_test.go b/pkg/services/object/search/search_test.go index c4eb49fec..3749d0d98 100644 --- a/pkg/services/object/search/search_test.go +++ b/pkg/services/object/search/search_test.go @@ -103,7 +103,7 @@ func (c *testClientCache) get(info clientcore.NodeInfo) (searchClient, error) { } func (s *testStorage) search(exec *execCtx) ([]oid.ID, error) { - v, ok := s.items[exec.containerID().EncodeToString()] + v, ok := s.items[exec.prm.cnr.EncodeToString()] if !ok { return nil, nil } @@ -112,7 +112,7 @@ func (s *testStorage) search(exec *execCtx) ([]oid.ID, error) { } func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]oid.ID, error) { - v, ok := c.items[exec.containerID().EncodeToString()] + v, ok := c.items[exec.prm.cnr.EncodeToString()] if !ok { return nil, nil } diff --git a/pkg/services/object/search/util.go b/pkg/services/object/search/util.go index f1e890214..192a8dee5 100644 --- a/pkg/services/object/search/util.go +++ b/pkg/services/object/search/util.go @@ -98,7 +98,7 @@ func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]oi var prm internalclient.SearchObjectsPrm - prm.SetContext(exec.context()) + prm.SetContext(exec.ctx) prm.SetClient(c.client) prm.SetPrivateKey(key) prm.SetSessionToken(exec.prm.common.SessionToken()) @@ -106,8 +106,8 @@ func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]oi prm.SetTTL(exec.prm.common.TTL()) prm.SetXHeaders(exec.prm.common.XHeaders()) prm.SetNetmapEpoch(exec.curProcEpoch) - prm.SetContainerID(exec.containerID()) - prm.SetFilters(exec.searchFilters()) + prm.SetContainerID(exec.prm.cnr) + prm.SetFilters(exec.prm.filters) res, err := internalclient.SearchObjects(prm) if err != nil { @@ -119,8 +119,8 @@ func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]oi func (e *storageEngineWrapper) search(exec *execCtx) ([]oid.ID, error) { var selectPrm engine.SelectPrm - selectPrm.WithFilters(exec.searchFilters()) - selectPrm.WithContainerID(exec.containerID()) + selectPrm.WithFilters(exec.prm.filters) + selectPrm.WithContainerID(exec.prm.cnr) r, err := e.storage.Select(selectPrm) if err != nil {