* Round id.
*/
private roundId: number = 0
- /**
- * Default worker weight.
- */
- private readonly defaultWorkerWeight: number
/**
* Round weights.
*/
- private roundWeights: number[]
+ private roundWeights!: number[]
/**
* Worker node id.
*/
opts: InternalWorkerChoiceStrategyOptions
) {
super(pool, opts)
- this.setTaskStatisticsRequirements(this.opts)
- this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
- this.roundWeights = this.getRoundWeights()
+ this.setOptions(this.opts)
}
/** @inheritDoc */
) {
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] &&
}
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<number, number>)
.slice()
.sort((a, b) => a - b)
)