- const workerWeight =
- this.opts.weights?.[workerNodeKey] ?? this.defaultWorkerWeight
- if (workerWeight >= this.roundWeights[round]) {
- roundId = round
- workerNodeId = workerNodeKey
- break
+ this.workerNodeId = workerNodeKey
+ if (
+ this.workerNodeId !== this.nextWorkerNodeKey &&
+ this.workerNodeVirtualTaskExecutionTime !== 0
+ ) {
+ this.workerNodeVirtualTaskExecutionTime = 0
+ }
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ const workerWeight = this.opts!.weights![workerNodeKey]
+ if (
+ this.isWorkerNodeReady(workerNodeKey) &&
+ workerWeight >= this.roundWeights[roundIndex] &&
+ this.workerNodeVirtualTaskExecutionTime < workerWeight
+ ) {
+ this.workerNodeVirtualTaskExecutionTime +=
+ this.getWorkerNodeTaskWaitTime(workerNodeKey) +
+ this.getWorkerNodeTaskRunTime(workerNodeKey)
+ this.setPreviousWorkerNodeKey(this.nextWorkerNodeKey)
+ this.nextWorkerNodeKey = workerNodeKey
+ return this.nextWorkerNodeKey