opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.checkOptions(this.opts)
+ this.setRequiredStatistics(this.opts)
this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
}
if (workerVirtualTaskRunTime < workerWeight) {
this.workerVirtualTaskRunTime =
workerVirtualTaskRunTime +
- this.getWorkerVirtualTaskRunTime(chosenWorkerNodeKey)
+ this.getWorkerTaskRunTime(chosenWorkerNodeKey)
} else {
this.currentWorkerNodeId =
this.currentWorkerNodeId === this.pool.workerNodes.length - 1
if (this.currentWorkerNodeId === workerNodeKey) {
if (this.pool.workerNodes.length === 0) {
this.currentWorkerNodeId = 0
- } else {
- this.currentWorkerNodeId =
- this.currentWorkerNodeId > this.pool.workerNodes.length - 1
- ? this.pool.workerNodes.length - 1
- : this.currentWorkerNodeId
+ } else if (this.currentWorkerNodeId > this.pool.workerNodes.length - 1) {
+ this.currentWorkerNodeId = this.pool.workerNodes.length - 1
}
this.workerVirtualTaskRunTime = 0
}
return true
}
- private getWorkerVirtualTaskRunTime (workerNodeKey: number): number {
- return this.requiredStatistics.medRunTime
- ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime
- : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
- }
-
private computeDefaultWorkerWeight (): number {
let cpusCycleTimeWeight = 0
for (const cpu of cpus()) {