From be6ae3c06698dbd586e20b368635aad428ba7044 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 29 Mar 2022 16:52:12 +0300 Subject: [PATCH] [#1278] neofs-node: Use global cached netmap source in services Signed-off-by: Alex Vanin --- cmd/neofs-node/config.go | 4 ++-- cmd/neofs-node/container.go | 2 +- cmd/neofs-node/control.go | 2 +- cmd/neofs-node/morph.go | 2 +- cmd/neofs-node/object.go | 14 +++++++------- cmd/neofs-node/reputation.go | 3 +-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 9090789e3..506810b8c 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -115,6 +115,8 @@ type cfg struct { clientCache *cache.ClientCache persistate *state.PersistentStorage + + netMapSource netmapCore.Source } type cfgGRPC struct { @@ -173,8 +175,6 @@ type cfgNodeInfo struct { } type cfgObject struct { - netMapSource netmapCore.Source - cnrSource container.Source eaclSource eacl.Source diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 920361a10..15890028e 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -105,7 +105,7 @@ func initContainerService(c *cfg) { loadPlacementBuilder := &loadPlacementBuilder{ log: c.log, - nmSrc: c.cfgNetmap.wrapper, + nmSrc: c.netMapSource, cnrSrc: cnrSrc, } diff --git a/cmd/neofs-node/control.go b/cmd/neofs-node/control.go index 20f4ce587..015b41b52 100644 --- a/cmd/neofs-node/control.go +++ b/cmd/neofs-node/control.go @@ -31,7 +31,7 @@ func initControlService(c *cfg) { controlSvc.WithKey(&c.key.PrivateKey), controlSvc.WithAuthorizedKeys(rawPubs), controlSvc.WithHealthChecker(c), - controlSvc.WithNetMapSource(c.cfgNetmap.wrapper), + controlSvc.WithNetMapSource(c.netMapSource), controlSvc.WithNodeState(c), controlSvc.WithDeletedObjectHandler(func(addrList []*addressSDK.Address) error { prm := new(engine.DeletePrm).WithAddresses(addrList...) diff --git a/cmd/neofs-node/morph.go b/cmd/neofs-node/morph.go index cc1c83a4d..cb32242fd 100644 --- a/cmd/neofs-node/morph.go +++ b/cmd/neofs-node/morph.go @@ -102,7 +102,7 @@ func initMorphComponents(c *cfg) { netmapSource = newCachedNetmapStorage(c.cfgNetmap.state, wrap) } - c.cfgObject.netMapSource = netmapSource + c.netMapSource = netmapSource c.cfgNetmap.wrapper = wrap } diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 4ad933ae8..97b5ea15f 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -181,7 +181,7 @@ func initObjectService(c *cfg) { clientConstructor := &reputationClientConstructor{ log: c.log, - nmSrc: c.cfgObject.netMapSource, + nmSrc: c.netMapSource, netState: c.cfgNetmap.state, trustStorage: c.cfgReputation.localTrustStorage, basicConstructor: c.clientCache, @@ -224,7 +224,7 @@ func initObjectService(c *cfg) { policer.WithLocalStorage(ls), policer.WithContainerSource(c.cfgObject.cnrSource), policer.WithPlacementBuilder( - placement.NewNetworkMapSourceBuilder(c.cfgObject.netMapSource), + placement.NewNetworkMapSourceBuilder(c.netMapSource), ), policer.WithRemoteHeader( headsvc.NewRemoteHeader(keyStorage, clientConstructor), @@ -247,7 +247,7 @@ func initObjectService(c *cfg) { policer.WithNodeLoader(c), ) - traverseGen := util.NewTraverserGenerator(c.cfgObject.netMapSource, c.cfgObject.cnrSource, c) + traverseGen := util.NewTraverserGenerator(c.netMapSource, c.cfgObject.cnrSource, c) c.workers = append(c.workers, pol) @@ -271,7 +271,7 @@ func initObjectService(c *cfg) { putsvc.WithMaxSizeSource(c), putsvc.WithObjectStorage(os), putsvc.WithContainerSource(c.cfgObject.cnrSource), - putsvc.WithNetworkMapSource(c.cfgObject.netMapSource), + putsvc.WithNetworkMapSource(c.netMapSource), putsvc.WithNetmapKeys(c), putsvc.WithFormatValidatorOpts( objectCore.WithDeleteHandler(objInhumer), @@ -296,7 +296,7 @@ func initObjectService(c *cfg) { placement.WithoutSuccessTracking(), ), ), - searchsvc.WithNetMapSource(c.cfgNetmap.wrapper), + searchsvc.WithNetMapSource(c.netMapSource), searchsvc.WithKeyStorage(keyStorage), ) @@ -314,7 +314,7 @@ func initObjectService(c *cfg) { placement.SuccessAfter(1), ), ), - getsvc.WithNetMapSource(c.cfgNetmap.wrapper), + getsvc.WithNetMapSource(c.netMapSource), getsvc.WithKeyStorage(keyStorage), ) @@ -358,7 +358,7 @@ func initObjectService(c *cfg) { aclSvc := v2.New( v2.WithLogger(c.log), v2.WithIRFetcher(irFetcher), - v2.WithNetmapSource(c.cfgNetmap.wrapper), + v2.WithNetmapSource(c.netMapSource), v2.WithContainerSource( c.cfgObject.cnrSource, ), diff --git a/cmd/neofs-node/reputation.go b/cmd/neofs-node/reputation.go index e4fb46390..7e57f6404 100644 --- a/cmd/neofs-node/reputation.go +++ b/cmd/neofs-node/reputation.go @@ -38,8 +38,7 @@ func initReputationService(c *cfg) { localKey := c.key.PublicKey().Bytes() - // consider sharing this between application components - nmSrc := newCachedNetmapStorage(c.cfgNetmap.state, c.cfgNetmap.wrapper) + nmSrc := c.netMapSource // storing calculated trusts as a daughter c.cfgReputation.localTrustStorage = truststorage.New(