forked from TrueCloudLab/frostfs-node
[#956] policer: Remove WithMaxCapacity option
We already provide the pool and this argument is used only for preallocation. No functional changes. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
053a195ac2
commit
cbfeb72466
4 changed files with 9 additions and 12 deletions
|
@ -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.WithPool(c.cfgObject.pool.replication),
|
||||||
policer.WithMetrics(c.metricsCollector.PolicerMetrics()),
|
policer.WithMetrics(c.metricsCollector.PolicerMetrics()),
|
||||||
)
|
)
|
||||||
|
|
|
@ -64,8 +64,6 @@ type cfg struct {
|
||||||
|
|
||||||
taskPool *ants.Pool
|
taskPool *ants.Pool
|
||||||
|
|
||||||
maxCapacity int
|
|
||||||
|
|
||||||
batchSize, cacheSize uint32
|
batchSize, cacheSize uint32
|
||||||
|
|
||||||
rebalanceFreq, evictDuration, sleepDuration time.Duration
|
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
|
// WithPool returns option to set pool for
|
||||||
// policy and replication operations.
|
// policy and replication operations.
|
||||||
func WithPool(p *ants.Pool) Option {
|
func WithPool(p *ants.Pool) Option {
|
||||||
|
|
|
@ -66,7 +66,7 @@ func New(opts ...Option) *Policer {
|
||||||
cfg: c,
|
cfg: c,
|
||||||
cache: cache,
|
cache: cache,
|
||||||
objsInWork: &objectsInWork{
|
objsInWork: &objectsInWork{
|
||||||
objs: make(map[oid.Address]struct{}, c.maxCapacity),
|
objs: make(map[oid.Address]struct{}, c.taskPool.Cap()),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,6 +239,7 @@ func TestProcessObject(t *testing.T) {
|
||||||
gotReplicateTo = append(gotReplicateTo, int(node.PublicKey()[0]))
|
gotReplicateTo = append(gotReplicateTo, int(node.PublicKey()[0]))
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
|
WithPool(testPool(t)),
|
||||||
)
|
)
|
||||||
|
|
||||||
addrWithType := objectcore.AddressWithType{
|
addrWithType := objectcore.AddressWithType{
|
||||||
|
@ -276,6 +277,7 @@ func TestProcessObjectError(t *testing.T) {
|
||||||
p := New(
|
p := New(
|
||||||
WithContainerSource(source),
|
WithContainerSource(source),
|
||||||
WithBuryFunc(buryFn),
|
WithBuryFunc(buryFn),
|
||||||
|
WithPool(testPool(t)),
|
||||||
)
|
)
|
||||||
|
|
||||||
addrWithType := objectcore.AddressWithType{
|
addrWithType := objectcore.AddressWithType{
|
||||||
|
@ -348,6 +350,12 @@ func TestIteratorContract(t *testing.T) {
|
||||||
}, it.calls)
|
}, it.calls)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testPool(t *testing.T) *ants.Pool {
|
||||||
|
pool, err := ants.NewPool(4)
|
||||||
|
require.NoError(t, err)
|
||||||
|
return pool
|
||||||
|
}
|
||||||
|
|
||||||
type nextResult struct {
|
type nextResult struct {
|
||||||
objs []objectcore.AddressWithType
|
objs []objectcore.AddressWithType
|
||||||
err error
|
err error
|
||||||
|
|
Loading…
Reference in a new issue