[#2003] neofs-node: Allow to configure replicator pool size
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
8212020165
commit
cdbfd05704
9 changed files with 30 additions and 5 deletions
|
@ -29,6 +29,7 @@ import (
|
|||
metricsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/metrics"
|
||||
nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node"
|
||||
objectconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/object"
|
||||
replicatorconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/replicator"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
|
||||
|
@ -488,6 +489,8 @@ type cfgObjectRoutines struct {
|
|||
|
||||
putRemoteCapacity int
|
||||
|
||||
replicatorPoolSize int
|
||||
|
||||
replication *ants.Pool
|
||||
}
|
||||
|
||||
|
@ -821,7 +824,12 @@ func initObjectPool(cfg *config.Config) (pool cfgObjectRoutines) {
|
|||
pool.putRemote, err = ants.NewPool(pool.putRemoteCapacity, optNonBlocking)
|
||||
fatalOnErr(err)
|
||||
|
||||
pool.replication, err = ants.NewPool(pool.putRemoteCapacity)
|
||||
pool.replicatorPoolSize = replicatorconfig.PoolSize(cfg)
|
||||
if pool.replicatorPoolSize <= 0 {
|
||||
pool.replicatorPoolSize = pool.putRemoteCapacity
|
||||
}
|
||||
|
||||
pool.replication, err = ants.NewPool(pool.replicatorPoolSize)
|
||||
fatalOnErr(err)
|
||||
|
||||
return pool
|
||||
|
|
|
@ -25,3 +25,9 @@ func PutTimeout(c *config.Config) time.Duration {
|
|||
|
||||
return PutTimeoutDefault
|
||||
}
|
||||
|
||||
// PoolSize returns the value of "pool_size" config parameter
|
||||
// from "replicator" section.
|
||||
func PoolSize(c *config.Config) int {
|
||||
return int(config.IntSafe(c.Sub(subsection), "pool_size"))
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@ func TestReplicatorSection(t *testing.T) {
|
|||
empty := configtest.EmptyConfig()
|
||||
|
||||
require.Equal(t, replicatorconfig.PutTimeoutDefault, replicatorconfig.PutTimeout(empty))
|
||||
require.Equal(t, 0, replicatorconfig.PoolSize(empty))
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
||||
var fileConfigTest = func(c *config.Config) {
|
||||
require.Equal(t, 15*time.Second, replicatorconfig.PutTimeout(c))
|
||||
require.Equal(t, 10, replicatorconfig.PoolSize(c))
|
||||
}
|
||||
|
||||
configtest.ForEachFileType(path, fileConfigTest)
|
||||
|
|
|
@ -231,7 +231,7 @@ func initObjectService(c *cfg) {
|
|||
)
|
||||
}
|
||||
}),
|
||||
policer.WithMaxCapacity(c.cfgObject.pool.putRemoteCapacity),
|
||||
policer.WithMaxCapacity(c.cfgObject.pool.replicatorPoolSize),
|
||||
policer.WithPool(c.cfgObject.pool.replication),
|
||||
policer.WithNodeLoader(c),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue