X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Finterleaved-weighted-round-robin-worker-choice-strategy.ts;h=0f718e9817159bd6aedb5012e3246786d4696f50;hb=af7fe15acbe47c6b2236426034dd5cb08c271bbc;hp=8ccb5f7890db974d91cd24b2b247a2a04f2ce67c;hpb=26ce26ca8861318068427cc86697103e7a3ddbf4;p=poolifier.git diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 8ccb5f78..0f718e98 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -37,14 +37,10 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< * Round id. */ private roundId: number = 0 - /** - * Default worker weight. - */ - private readonly defaultWorkerWeight: number /** * Round weights. */ - private roundWeights: number[] + private roundWeights!: number[] /** * Worker node id. */ @@ -60,9 +56,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< opts: InternalWorkerChoiceStrategyOptions ) { super(pool, opts) - this.setTaskStatisticsRequirements(this.opts) - this.defaultWorkerWeight = this.computeDefaultWorkerWeight() - this.roundWeights = this.getRoundWeights() + this.setOptions(this.opts) } /** @inheritDoc */ @@ -99,8 +93,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< ) { this.workerNodeVirtualTaskRunTime = 0 } - const workerWeight = - this.opts.weights?.[workerNodeKey] ?? this.defaultWorkerWeight + const workerWeight = this.opts.weights?.[workerNodeKey] as number if ( this.isWorkerNodeReady(workerNodeKey) && workerWeight >= this.roundWeights[roundIndex] && @@ -160,12 +153,9 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< } private getRoundWeights (): number[] { - if (this.opts.weights == null) { - return [this.defaultWorkerWeight] - } return [ ...new Set( - Object.values(this.opts.weights) + Object.values(this.opts.weights as Record) .slice() .sort((a, b) => a - b) )