return this.pool.workerNodes[workerNodeKey]?.info.ready ?? false
}
- /**
- * Whether the worker node has back pressure or not (i.e. its tasks queue is full).
- *
- * @param workerNodeKey - The worker node key.
- * @returns `true` if the worker node has back pressure, `false` otherwise.
- */
- protected hasWorkerNodeBackPressure (workerNodeKey: number): boolean {
- return this.pool.hasWorkerNodeBackPressure(workerNodeKey)
- }
-
/**
* Gets the worker node task runtime.
* If the task statistics require the average runtime, the average runtime is returned.
const workerWeight =
this.opts.weights?.[workerNodeKey] ?? this.defaultWorkerWeight
if (
+ this.isWorkerNodeReady(workerNodeKey) &&
workerWeight >= this.roundWeights[roundIndex] &&
this.workerNodeVirtualTaskRunTime < workerWeight
) {
}
private interleavedWeightedRoundRobinNextWorkerNodeId (): void {
- if (
- this.roundId === this.roundWeights.length - 1 &&
- this.workerNodeId === this.pool.workerNodes.length - 1
- ) {
- this.roundId = 0
- this.workerNodeId = 0
- } else if (this.workerNodeId === this.pool.workerNodes.length - 1) {
- this.roundId = this.roundId + 1
- this.workerNodeId = 0
- } else {
- this.workerNodeId = this.workerNodeId + 1
- }
+ do {
+ if (
+ this.roundId === this.roundWeights.length - 1 &&
+ this.workerNodeId === this.pool.workerNodes.length - 1
+ ) {
+ this.roundId = 0
+ this.workerNodeId = 0
+ } else if (this.workerNodeId === this.pool.workerNodes.length - 1) {
+ this.roundId = this.roundId + 1
+ this.workerNodeId = 0
+ } else {
+ this.workerNodeId = this.workerNodeId + 1
+ }
+ } while (!this.isWorkerNodeReady(this.workerNodeId))
}
/** @inheritDoc */