Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ type shared struct {
privateTokenStore sessionStorage
persistate *state.PersistentStorage

clientCache *cache.Clients
bgClientCache *cache.Clients
putClientCache *cache.Clients
localAddr network.AddressGroup
clientCache *cache.Clients
localAddr network.AddressGroup

ownerIDFromKey user.ID // user ID calculated from key

Expand Down Expand Up @@ -425,9 +423,7 @@ func initCfg(appCfg *config.Config) *cfg {
c.shared = shared{
basics: basicSharedConfig,
localAddr: netAddr,
clientCache: newClientCache("read"),
bgClientCache: newClientCache("background"),
putClientCache: newClientCache("put"),
clientCache: newClientCache(""),
persistate: persistate,
privateTokenStore: persistate,
}
Expand Down Expand Up @@ -464,9 +460,7 @@ func initCfg(appCfg *config.Config) *cfg {

c.veryLastClosers = make(map[string]func())

c.onShutdown(c.clientCache.CloseAll) // clean up connections
c.onShutdown(c.bgClientCache.CloseAll) // clean up connections
c.onShutdown(c.putClientCache.CloseAll) // clean up connections
c.onShutdown(c.clientCache.CloseAll) // clean up connections
c.onShutdown(func() { _ = c.persistate.Close() })

initPaymentChecker(c)
Expand Down
11 changes: 2 additions & 9 deletions cmd/neofs-node/netmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"slices"
"sync"
"sync/atomic"
"time"

Expand All @@ -17,7 +16,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap"
"github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/network/cache"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
netmapService "github.com/nspcc-dev/neofs-node/pkg/services/netmap"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
Expand Down Expand Up @@ -236,14 +234,9 @@ func initNetmapService(c *cfg) {

nodes := nm.Nodes()
local := slices.IndexFunc(nodes, func(node netmap.NodeInfo) bool { return c.IsLocalKey(node.PublicKey()) })
var wg sync.WaitGroup

l.Info("syncing SN connection caches with the new network map...")
for _, cl := range []*cache.Clients{c.clientCache, c.putClientCache, c.bgClientCache} {
wg.Go(func() {
cl.SyncWithNewNetmap(c.ctx, nodes, local)
})
}
wg.Wait()
c.clientCache.SyncWithNewNetmap(c.ctx, nodes, local)
l.Info("finished syncing SN connection caches with the new network map")
})
}
Expand Down
20 changes: 6 additions & 14 deletions cmd/neofs-node/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ func initObjectService(c *cfg) {
ls := c.cfgObject.cfgLocalStorage.localStorage
keyStorage := util.NewKeyStorage(&c.key.PrivateKey, c.privateTokenStore, c.cfgNetmap.state)

clientConstructor := &reputationClientConstructor{
repClientConstructor := &reputationClientConstructor{
log: c.log,
nmSrc: c.netMapSource,
netState: c.cfgNetmap.state,
trustStorage: c.cfgReputation.localTrustStorage,
basicConstructor: c.bgClientCache,
basicConstructor: c.clientCache,
}

coreConstructor := &coreClientConstructor{
Expand All @@ -203,14 +203,6 @@ func initObjectService(c *cfg) {
basicConstructor: c.clientCache,
}

putConstructor := &coreClientConstructor{
log: c.log,
nmSrc: c.netMapSource,
netState: c.cfgNetmap.state,
trustStorage: c.cfgReputation.localTrustStorage,
basicConstructor: c.putClientCache,
}

irFetcher := &innerRingFetcherWithNotary{
cfg: c,
fschain: c.cfgMorph.client,
Expand All @@ -223,7 +215,7 @@ func initObjectService(c *cfg) {
),
replicator.WithLocalStorage(ls),
replicator.WithRemoteSender(
putsvc.NewRemoteSender(keyStorage, (*coreClientConstructor)(clientConstructor)),
putsvc.NewRemoteSender(keyStorage, (*coreClientConstructor)(repClientConstructor)),
),
replicator.WithLocalNodeKey(c),
)
Expand All @@ -233,7 +225,7 @@ func initObjectService(c *cfg) {
policer.WithLocalStorage(ls),
policer.WithMetrics(c),
policer.WithRemoteHeader(
headsvc.NewRemoteHeader(keyStorage, clientConstructor),
headsvc.NewRemoteHeader(keyStorage, repClientConstructor),
),
policer.WithHeadTimeout(c.appCfg.Policer.HeadTimeout),
policer.WithReplicator(c.replicator),
Expand Down Expand Up @@ -262,11 +254,11 @@ func initObjectService(c *cfg) {
c.cfgObject.placement = placementSvc

os := &objectSource{signer: neofsecdsa.SignerRFC6979(c.key.PrivateKey), get: sGet}
sPut := putsvc.NewService(&transport{clients: putConstructor}, c, c.metaService,
sPut := putsvc.NewService(&transport{clients: coreConstructor}, c, c.metaService,
initQuotas(c.cCli, c.cfgObject.quotasTTL),
c.containerPayments,
putsvc.WithKeyStorage(keyStorage),
putsvc.WithClientConstructor(putConstructor),
putsvc.WithClientConstructor(coreConstructor),
putsvc.WithContainerClient(c.cCli),
putsvc.WithMaxSizeSource(newCachedMaxObjectSizeSource(c.MaxObjectSize)),
putsvc.WithObjectStorage(ls),
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-node/reputation.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func initReputationService(c *cfg) {
common.RemoteProviderPrm{
NetmapKeys: c,
DeadEndProvider: daughterStorageWriterProvider,
ClientCache: c.bgClientCache,
ClientCache: c.clientCache,
WriterProvider: localreputation.NewRemoteProvider(
localreputation.RemoteProviderPrm{
Key: &c.key.PrivateKey,
Expand All @@ -111,7 +111,7 @@ func initReputationService(c *cfg) {
common.RemoteProviderPrm{
NetmapKeys: c,
DeadEndProvider: consumerStorageWriterProvider,
ClientCache: c.bgClientCache,
ClientCache: c.clientCache,
WriterProvider: intermediatereputation.NewRemoteProvider(
intermediatereputation.RemoteProviderPrm{
Key: &c.key.PrivateKey,
Expand Down
Loading