From 0e3e8db5c0bcf04d970c8bea65d4c3b9b8fcf72e Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 24 Sep 2021 13:50:25 +0300 Subject: [PATCH] [#845] node: Configure Object PUT remote and local pools separately Signed-off-by: Leonard Lyubich --- cmd/neofs-node/config.go | 4 ++-- cmd/neofs-node/config/object/config.go | 18 +++++++++++++++--- cmd/neofs-node/config/object/config_test.go | 6 ++++-- config/example/node.env | 3 ++- config/example/node.json | 3 ++- config/example/node.yaml | 3 ++- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 1eaad1456..d407f0dd0 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -435,12 +435,12 @@ func initObjectPool(cfg *config.Config) (pool cfgObjectRoutines) { optNonBlocking := ants.WithNonblocking(true) - pool.putRemote, err = ants.NewPool(objectconfig.Put(cfg).PoolSize(), optNonBlocking) + pool.putRemote, err = ants.NewPool(objectconfig.Put(cfg).PoolSizeRemote(), optNonBlocking) if err != nil { fatalOnErr(err) } - pool.putLocal, err = ants.NewPool(objectconfig.Put(cfg).PoolSize(), optNonBlocking) + pool.putLocal, err = ants.NewPool(objectconfig.Put(cfg).PoolSizeLocal(), optNonBlocking) if err != nil { fatalOnErr(err) } diff --git a/cmd/neofs-node/config/object/config.go b/cmd/neofs-node/config/object/config.go index 79f3df75b..3432f9b85 100644 --- a/cmd/neofs-node/config/object/config.go +++ b/cmd/neofs-node/config/object/config.go @@ -28,11 +28,23 @@ func Put(c *config.Config) PutConfig { } } -// PoolSize returns value of "pool_size" config parameter. +// PoolSizeRemote returns value of "pool_size_remote" config parameter. // // Returns PutPoolSizeDefault if value is not positive number. -func (g PutConfig) PoolSize() int { - v := config.Int(g.cfg, "pool_size") +func (g PutConfig) PoolSizeRemote() int { + v := config.Int(g.cfg, "pool_size_remote") + if v > 0 { + return int(v) + } + + return PutPoolSizeDefault +} + +// PoolSizeLocal returns value of "pool_size_local" config parameter. +// +// Returns PutPoolSizeDefault if value is not positive number. +func (g PutConfig) PoolSizeLocal() int { + v := config.Int(g.cfg, "pool_size_local") if v > 0 { return int(v) } diff --git a/cmd/neofs-node/config/object/config_test.go b/cmd/neofs-node/config/object/config_test.go index a2d6b619d..31c85f158 100644 --- a/cmd/neofs-node/config/object/config_test.go +++ b/cmd/neofs-node/config/object/config_test.go @@ -13,13 +13,15 @@ func TestObjectSection(t *testing.T) { t.Run("defaults", func(t *testing.T) { empty := configtest.EmptyConfig() - require.Equal(t, objectconfig.PutPoolSizeDefault, objectconfig.Put(empty).PoolSize()) + require.Equal(t, objectconfig.PutPoolSizeDefault, objectconfig.Put(empty).PoolSizeRemote()) + require.Equal(t, objectconfig.PutPoolSizeDefault, objectconfig.Put(empty).PoolSizeLocal()) }) const path = "../../../../config/example/node" var fileConfigTest = func(c *config.Config) { - require.Equal(t, 100, objectconfig.Put(c).PoolSize()) + require.Equal(t, 100, objectconfig.Put(c).PoolSizeRemote()) + require.Equal(t, 101, objectconfig.Put(c).PoolSizeLocal()) } configtest.ForEachFileType(path, fileConfigTest) diff --git a/config/example/node.env b/config/example/node.env index bf8945492..54dfa2984 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -64,7 +64,8 @@ NEOFS_POLICER_HEAD_TIMEOUT=15s NEOFS_REPLICATOR_PUT_TIMEOUT=15s # Object service section -NEOFS_OBJECT_PUT_POOL_SIZE=100 +NEOFS_OBJECT_PUT_POOL_SIZE_REMOTE=100 +NEOFS_OBJECT_PUT_POOL_SIZE_LOCAL=101 # Storage engine section NEOFS_STORAGE_SHARD_NUM=2 diff --git a/config/example/node.json b/config/example/node.json index a6396ce68..31e7403b7 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -97,7 +97,8 @@ }, "object": { "put": { - "pool_size": 100 + "pool_size_remote": 100, + "pool_size_local": 101 } }, "storage": { diff --git a/config/example/node.yaml b/config/example/node.yaml index 5feb5e664..352dab1ab 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -84,7 +84,8 @@ replicator: object: put: - pool_size: 100 + pool_size_remote: 100 + pool_size_local: 101 storage: shard_num: 2