diff --git a/cmd/frostfs-node/object.go b/cmd/frostfs-node/object.go index 5c82f0dc..7f1d094f 100644 --- a/cmd/frostfs-node/object.go +++ b/cmd/frostfs-node/object.go @@ -263,7 +263,6 @@ func addPolicer(c *cfg, keyStorage *util.KeyStorage, clientConstructor *cache.Cl ) } }), - policer.WithMaxCapacity(c.cfgObject.pool.replicatorPoolSize), policer.WithPool(c.cfgObject.pool.replication), policer.WithMetrics(c.metricsCollector.PolicerMetrics()), ) diff --git a/pkg/services/policer/option.go b/pkg/services/policer/option.go index fe47555c..92cf83a8 100644 --- a/pkg/services/policer/option.go +++ b/pkg/services/policer/option.go @@ -64,8 +64,6 @@ type cfg struct { taskPool *ants.Pool - maxCapacity int - batchSize, cacheSize uint32 rebalanceFreq, evictDuration, sleepDuration time.Duration @@ -158,14 +156,6 @@ func WithRedundantCopyCallback(cb RedundantCopyCallback) Option { } } -// WithMaxCapacity returns option to set max capacity -// that can be set to the pool. -func WithMaxCapacity(capacity int) Option { - return func(c *cfg) { - c.maxCapacity = capacity - } -} - // WithPool returns option to set pool for // policy and replication operations. func WithPool(p *ants.Pool) Option { diff --git a/pkg/services/policer/policer.go b/pkg/services/policer/policer.go index a68b194d..363c0b92 100644 --- a/pkg/services/policer/policer.go +++ b/pkg/services/policer/policer.go @@ -66,7 +66,7 @@ func New(opts ...Option) *Policer { cfg: c, cache: cache, objsInWork: &objectsInWork{ - objs: make(map[oid.Address]struct{}, c.maxCapacity), + objs: make(map[oid.Address]struct{}, c.taskPool.Cap()), }, } } diff --git a/pkg/services/policer/policer_test.go b/pkg/services/policer/policer_test.go index c73d3362..41abeb38 100644 --- a/pkg/services/policer/policer_test.go +++ b/pkg/services/policer/policer_test.go @@ -239,6 +239,7 @@ func TestProcessObject(t *testing.T) { gotReplicateTo = append(gotReplicateTo, int(node.PublicKey()[0])) } })), + WithPool(testPool(t)), ) addrWithType := objectcore.AddressWithType{ @@ -276,6 +277,7 @@ func TestProcessObjectError(t *testing.T) { p := New( WithContainerSource(source), WithBuryFunc(buryFn), + WithPool(testPool(t)), ) addrWithType := objectcore.AddressWithType{ @@ -348,6 +350,12 @@ func TestIteratorContract(t *testing.T) { }, it.calls) } +func testPool(t *testing.T) *ants.Pool { + pool, err := ants.NewPool(4) + require.NoError(t, err) + return pool +} + type nextResult struct { objs []objectcore.AddressWithType err error