refactor: prepare worker choice strategies code for worker readiness
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 10 Jul 2023 11:12:43 +0000 (13:12 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 10 Jul 2023 11:12:43 +0000 (13:12 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
13 files changed:
src/pools/abstract-pool.ts
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/least-busy-worker-choice-strategy.ts
src/pools/selection-strategies/least-elu-worker-choice-strategy.ts
src/pools/selection-strategies/least-used-worker-choice-strategy.ts
src/pools/selection-strategies/round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
tests/pools/cluster/dynamic.test.js
tests/pools/selection-strategies/selection-strategies.test.js
tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.js
tests/pools/thread/dynamic.test.js

index cb5d4ce7f60d81129ed9015108e10b14c4cbef80..4bf7785d7eb4813dc9a56e63239db29f29de770b 100644 (file)
@@ -953,18 +953,21 @@ export abstract class AbstractPool<
     worker.on('message', this.opts.messageHandler ?? EMPTY_FUNCTION)
     worker.on('error', this.opts.errorHandler ?? EMPTY_FUNCTION)
     worker.on('error', error => {
+      const workerNodeKey = this.getWorkerNodeKey(worker)
+      const workerInfo = this.getWorkerInfo(workerNodeKey)
+      workerInfo.ready = false
       if (this.emitter != null) {
         this.emitter.emit(PoolEvents.error, error)
       }
       if (this.opts.restartWorkerOnError === true && !this.starting) {
-        if (this.getWorkerInfo(this.getWorkerNodeKey(worker)).dynamic) {
+        if (workerInfo.dynamic) {
           this.createAndSetupDynamicWorker()
         } else {
           this.createAndSetupWorker()
         }
       }
       if (this.opts.enableTasksQueue === true) {
-        this.redistributeQueuedTasks(worker)
+        this.redistributeQueuedTasks(workerNodeKey)
       }
     })
     worker.on('online', this.opts.onlineHandler ?? EMPTY_FUNCTION)
@@ -980,8 +983,7 @@ export abstract class AbstractPool<
     return worker
   }
 
-  private redistributeQueuedTasks (worker: Worker): void {
-    const workerNodeKey = this.getWorkerNodeKey(worker)
+  private redistributeQueuedTasks (workerNodeKey: number): void {
     while (this.tasksQueueSize(workerNodeKey) > 0) {
       let targetWorkerNodeKey: number = workerNodeKey
       let minQueuedTasks = Infinity
index a6589d09836dc5b48e4a1d7e9a52eb93327bdfb9..c4f1e2c65483ccceb1c3bb2f3343caac2c7530cf 100644 (file)
@@ -30,9 +30,9 @@ export abstract class AbstractWorkerChoiceStrategy<
   // private toggleFindLastFreeWorkerNodeKey: boolean = false
 
   /**
-   * Id of the next worker node.
+   * The next worker node key.
    */
-  protected nextWorkerNodeId: number = 0
+  protected nextWorkerNodeKey: number = 0
 
   /** @inheritDoc */
   public readonly strategyPolicy: StrategyPolicy = {
@@ -128,7 +128,7 @@ export abstract class AbstractWorkerChoiceStrategy<
     this.setTaskStatisticsRequirements(this.opts)
   }
 
-  protected workerNodeReady (workerNodeKey: number): boolean {
+  protected isWorkerNodeReady (workerNodeKey: number): boolean {
     return this.pool.workerNodes[workerNodeKey].info.ready
   }
 
index 351f3d91e10c1a05a60382b63af16de5d5a70d43..00c56dad8f555f64afc0a4d21a693d6a97b956f5 100644 (file)
@@ -70,6 +70,17 @@ export class FairShareWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public choose (): number {
+    this.fairShareNextWorkerNodeKey()
+    return this.nextWorkerNodeKey
+  }
+
+  /** @inheritDoc */
+  public remove (workerNodeKey: number): boolean {
+    this.workersVirtualTaskEndTimestamp.splice(workerNodeKey, 1)
+    return true
+  }
+
+  private fairShareNextWorkerNodeKey (): void {
     let minWorkerVirtualTaskEndTimestamp = Infinity
     for (const [workerNodeKey] of this.pool.workerNodes.entries()) {
       if (this.workersVirtualTaskEndTimestamp[workerNodeKey] == null) {
@@ -78,20 +89,13 @@ export class FairShareWorkerChoiceStrategy<
       const workerVirtualTaskEndTimestamp =
         this.workersVirtualTaskEndTimestamp[workerNodeKey]
       if (
-        this.workerNodeReady(workerNodeKey) &&
+        this.isWorkerNodeReady(workerNodeKey) &&
         workerVirtualTaskEndTimestamp < minWorkerVirtualTaskEndTimestamp
       ) {
         minWorkerVirtualTaskEndTimestamp = workerVirtualTaskEndTimestamp
-        this.nextWorkerNodeId = workerNodeKey
+        this.nextWorkerNodeKey = workerNodeKey
       }
     }
-    return this.nextWorkerNodeId
-  }
-
-  /** @inheritDoc */
-  public remove (workerNodeKey: number): boolean {
-    this.workersVirtualTaskEndTimestamp.splice(workerNodeKey, 1)
-    return true
   }
 
   /**
index 40522c72741e67fd6303874f80467e14748d718f..78960f1063c81f1c616d8fb9b868061cdc6598c5 100644 (file)
@@ -54,7 +54,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public reset (): boolean {
-    this.nextWorkerNodeId = 0
+    this.nextWorkerNodeKey = 0
     this.roundId = 0
     return true
   }
@@ -74,7 +74,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
       roundIndex++
     ) {
       for (
-        let workerNodeKey = this.nextWorkerNodeId;
+        let workerNodeKey = this.nextWorkerNodeKey;
         workerNodeKey < this.pool.workerNodes.length;
         workerNodeKey++
       ) {
@@ -88,25 +88,25 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
       }
     }
     this.roundId = roundId ?? 0
-    this.nextWorkerNodeId = workerNodeId ?? 0
-    const chosenWorkerNodeKey = this.nextWorkerNodeId
-    if (this.nextWorkerNodeId === this.pool.workerNodes.length - 1) {
-      this.nextWorkerNodeId = 0
+    this.nextWorkerNodeKey = workerNodeId ?? 0
+    const chosenWorkerNodeKey = this.nextWorkerNodeKey
+    if (this.nextWorkerNodeKey === this.pool.workerNodes.length - 1) {
+      this.nextWorkerNodeKey = 0
       this.roundId =
         this.roundId === this.roundWeights.length - 1 ? 0 : this.roundId + 1
     } else {
-      this.nextWorkerNodeId = this.nextWorkerNodeId + 1
+      this.nextWorkerNodeKey = this.nextWorkerNodeKey + 1
     }
     return chosenWorkerNodeKey
   }
 
   /** @inheritDoc */
   public remove (workerNodeKey: number): boolean {
-    if (this.nextWorkerNodeId === workerNodeKey) {
+    if (this.nextWorkerNodeKey === workerNodeKey) {
       if (this.pool.workerNodes.length === 0) {
-        this.nextWorkerNodeId = 0
-      } else if (this.nextWorkerNodeId > this.pool.workerNodes.length - 1) {
-        this.nextWorkerNodeId = this.pool.workerNodes.length - 1
+        this.nextWorkerNodeKey = 0
+      } else if (this.nextWorkerNodeKey > this.pool.workerNodes.length - 1) {
+        this.nextWorkerNodeKey = this.pool.workerNodes.length - 1
         this.roundId =
           this.roundId === this.roundWeights.length - 1 ? 0 : this.roundId + 1
       }
index b61bca1c8bdf450083474d8e2d8e78fef48ea2bc..dabad6826568c38621c73d8fa4f6ac4efb28418f 100644 (file)
@@ -61,24 +61,31 @@ export class LeastBusyWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public choose (): number {
+    this.leastBusyNextWorkerNodeKey()
+    return this.nextWorkerNodeKey
+  }
+
+  /** @inheritDoc */
+  public remove (): boolean {
+    return true
+  }
+
+  private leastBusyNextWorkerNodeKey (): void {
     let minTime = Infinity
     for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
       const workerTime =
         (workerNode.usage.runTime?.aggregate ?? 0) +
         (workerNode.usage.waitTime?.aggregate ?? 0)
-      if (this.workerNodeReady(workerNodeKey) && workerTime === 0) {
-        this.nextWorkerNodeId = workerNodeKey
+      if (this.isWorkerNodeReady(workerNodeKey) && workerTime === 0) {
+        this.nextWorkerNodeKey = workerNodeKey
         break
-      } else if (this.workerNodeReady(workerNodeKey) && workerTime < minTime) {
+      } else if (
+        this.isWorkerNodeReady(workerNodeKey) &&
+        workerTime < minTime
+      ) {
         minTime = workerTime
-        this.nextWorkerNodeId = workerNodeKey
+        this.nextWorkerNodeKey = workerNodeKey
       }
     }
-    return this.nextWorkerNodeId
-  }
-
-  /** @inheritDoc */
-  public remove (): boolean {
-    return true
   }
 }
index 57e805e18b5b5fb9f25e3b9170fb3baf9e84fa49..24c612e073806e1800bbe4113515354dfbdd0334 100644 (file)
@@ -57,26 +57,30 @@ export class LeastEluWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public choose (): number {
+    this.leastEluNextWorkerNodeKey()
+    return this.nextWorkerNodeKey
+  }
+
+  /** @inheritDoc */
+  public remove (): boolean {
+    return true
+  }
+
+  private leastEluNextWorkerNodeKey (): void {
     let minWorkerElu = Infinity
     for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
       const workerUsage = workerNode.usage
       const workerElu = workerUsage.elu?.active?.aggregate ?? 0
-      if (this.workerNodeReady(workerNodeKey) && workerElu === 0) {
-        this.nextWorkerNodeId = workerNodeKey
+      if (this.isWorkerNodeReady(workerNodeKey) && workerElu === 0) {
+        this.nextWorkerNodeKey = workerNodeKey
         break
       } else if (
-        this.workerNodeReady(workerNodeKey) &&
+        this.isWorkerNodeReady(workerNodeKey) &&
         workerElu < minWorkerElu
       ) {
         minWorkerElu = workerElu
-        this.nextWorkerNodeId = workerNodeKey
+        this.nextWorkerNodeKey = workerNodeKey
       }
     }
-    return this.nextWorkerNodeId
-  }
-
-  /** @inheritDoc */
-  public remove (): boolean {
-    return true
   }
 }
index 8c1384701de0c2d37b5c34a474394f8baa92141d..910d10a3ac320db8f3feac42eb43293181a806d1 100644 (file)
@@ -42,6 +42,16 @@ export class LeastUsedWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public choose (): number {
+    this.leastUsedNextWorkerNodeKey()
+    return this.nextWorkerNodeKey
+  }
+
+  /** @inheritDoc */
+  public remove (): boolean {
+    return true
+  }
+
+  private leastUsedNextWorkerNodeKey (): void {
     let minNumberOfTasks = Infinity
     for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
       const workerTaskStatistics = workerNode.usage.tasks
@@ -49,22 +59,16 @@ export class LeastUsedWorkerChoiceStrategy<
         workerTaskStatistics.executed +
         workerTaskStatistics.executing +
         workerTaskStatistics.queued
-      if (this.workerNodeReady(workerNodeKey) && workerTasks === 0) {
-        this.nextWorkerNodeId = workerNodeKey
+      if (this.isWorkerNodeReady(workerNodeKey) && workerTasks === 0) {
+        this.nextWorkerNodeKey = workerNodeKey
         break
       } else if (
-        this.workerNodeReady(workerNodeKey) &&
+        this.isWorkerNodeReady(workerNodeKey) &&
         workerTasks < minNumberOfTasks
       ) {
         minNumberOfTasks = workerTasks
-        this.nextWorkerNodeId = workerNodeKey
+        this.nextWorkerNodeKey = workerNodeKey
       }
     }
-    return this.nextWorkerNodeId
-  }
-
-  /** @inheritDoc */
-  public remove (): boolean {
-    return true
   }
 }
index 835860930b0d76f54c37d547b73274d9bf7fb175..fdf5ac84fddf87235b1d7732e81f2ccff3aae53b 100644 (file)
@@ -38,7 +38,7 @@ export class RoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public reset (): boolean {
-    this.nextWorkerNodeId = 0
+    this.nextWorkerNodeKey = 0
     return true
   }
 
@@ -49,23 +49,27 @@ export class RoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public choose (): number {
-    const chosenWorkerNodeKey = this.nextWorkerNodeId
-    this.nextWorkerNodeId =
-      this.nextWorkerNodeId === this.pool.workerNodes.length - 1
-        ? 0
-        : this.nextWorkerNodeId + 1
+    const chosenWorkerNodeKey = this.nextWorkerNodeKey
+    this.roundRobinNextWorkerNodeKey()
     return chosenWorkerNodeKey
   }
 
   /** @inheritDoc */
   public remove (workerNodeKey: number): boolean {
-    if (this.nextWorkerNodeId === workerNodeKey) {
+    if (this.nextWorkerNodeKey === workerNodeKey) {
       if (this.pool.workerNodes.length === 0) {
-        this.nextWorkerNodeId = 0
-      } else if (this.nextWorkerNodeId > this.pool.workerNodes.length - 1) {
-        this.nextWorkerNodeId = this.pool.workerNodes.length - 1
+        this.nextWorkerNodeKey = 0
+      } else if (this.nextWorkerNodeKey > this.pool.workerNodes.length - 1) {
+        this.nextWorkerNodeKey = this.pool.workerNodes.length - 1
       }
     }
     return true
   }
+
+  private roundRobinNextWorkerNodeKey (): void {
+    this.nextWorkerNodeKey =
+      this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
+        ? 0
+        : this.nextWorkerNodeKey + 1
+  }
 }
index 2805133092b651ec1efa9d71a5f2f209b0f260f8..ed38aa1497176ba88751e83a850e1794b3aaa9fd 100644 (file)
@@ -64,7 +64,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public reset (): boolean {
-    this.nextWorkerNodeId = 0
+    this.nextWorkerNodeKey = 0
     this.workerVirtualTaskRunTime = 0
     return true
   }
@@ -76,34 +76,38 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public choose (): number {
-    const chosenWorkerNodeKey = this.nextWorkerNodeId
-    const workerVirtualTaskRunTime = this.workerVirtualTaskRunTime
-    const workerWeight =
-      this.opts.weights?.[chosenWorkerNodeKey] ?? this.defaultWorkerWeight
-    if (workerVirtualTaskRunTime < workerWeight) {
-      this.workerVirtualTaskRunTime =
-        workerVirtualTaskRunTime +
-        this.getWorkerTaskRunTime(chosenWorkerNodeKey)
-    } else {
-      this.nextWorkerNodeId =
-        this.nextWorkerNodeId === this.pool.workerNodes.length - 1
-          ? 0
-          : this.nextWorkerNodeId + 1
-      this.workerVirtualTaskRunTime = 0
-    }
+    const chosenWorkerNodeKey = this.nextWorkerNodeKey
+    this.weightedRoundRobinNextWorkerNodeKey()
     return chosenWorkerNodeKey
   }
 
   /** @inheritDoc */
   public remove (workerNodeKey: number): boolean {
-    if (this.nextWorkerNodeId === workerNodeKey) {
+    if (this.nextWorkerNodeKey === workerNodeKey) {
       if (this.pool.workerNodes.length === 0) {
-        this.nextWorkerNodeId = 0
-      } else if (this.nextWorkerNodeId > this.pool.workerNodes.length - 1) {
-        this.nextWorkerNodeId = this.pool.workerNodes.length - 1
+        this.nextWorkerNodeKey = 0
+      } else if (this.nextWorkerNodeKey > this.pool.workerNodes.length - 1) {
+        this.nextWorkerNodeKey = this.pool.workerNodes.length - 1
       }
       this.workerVirtualTaskRunTime = 0
     }
     return true
   }
+
+  private weightedRoundRobinNextWorkerNodeKey (): void {
+    const workerVirtualTaskRunTime = this.workerVirtualTaskRunTime
+    const workerWeight =
+      this.opts.weights?.[this.nextWorkerNodeKey] ?? this.defaultWorkerWeight
+    if (workerVirtualTaskRunTime < workerWeight) {
+      this.workerVirtualTaskRunTime =
+        workerVirtualTaskRunTime +
+        this.getWorkerTaskRunTime(this.nextWorkerNodeKey)
+    } else {
+      this.nextWorkerNodeKey =
+        this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
+          ? 0
+          : this.nextWorkerNodeKey + 1
+      this.workerVirtualTaskRunTime = 0
+    }
+  }
 }
index bd405a771b1d85f64637d3117de45be7dfabeba8..a6d0b5942e00585e82e2b67e5c6cc87e027ac365 100644 (file)
@@ -103,7 +103,7 @@ describe('Dynamic cluster pool test suite', () => {
     expect(
       longRunningPool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         longRunningPool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeLessThan(longRunningPool.workerNodes.length)
     // We need to clean up the resources after our test
     await longRunningPool.destroy()
index 2e1a49b67e4db6f3a89347b1e81329151c4e4180..c3a01da6c19ff81c1aa4e60d46082772bd7cdcbc 100644 (file)
@@ -79,7 +79,7 @@ describe('Selection strategies test suite', () => {
         expect(
           pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
             workerChoiceStrategy
-          ).nextWorkerNodeId
+          ).nextWorkerNodeKey
         ).toBe(0)
       } else if (workerChoiceStrategy === WorkerChoiceStrategies.FAIR_SHARE) {
         expect(
@@ -98,7 +98,7 @@ describe('Selection strategies test suite', () => {
         expect(
           pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
             workerChoiceStrategy
-          ).nextWorkerNodeId
+          ).nextWorkerNodeKey
         ).toBe(0)
         expect(
           pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -236,7 +236,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         WorkerChoiceStrategies.ROUND_ROBIN
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     // We need to clean up the resources after our test
     await pool.destroy()
@@ -284,7 +284,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         WorkerChoiceStrategies.ROUND_ROBIN
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     // We need to clean up the resources after our test
     await pool.destroy()
@@ -326,13 +326,13 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeDefined()
     pool.setWorkerChoiceStrategy(workerChoiceStrategy)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     await pool.destroy()
     pool = new DynamicThreadPool(
@@ -344,13 +344,13 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeDefined()
     pool.setWorkerChoiceStrategy(workerChoiceStrategy)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     // We need to clean up the resources after our test
     await pool.destroy()
@@ -1555,7 +1555,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeDefined()
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1571,7 +1571,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1592,7 +1592,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeDefined()
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1608,7 +1608,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1760,7 +1760,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1830,7 +1830,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1860,7 +1860,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeDefined()
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1881,7 +1881,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1911,7 +1911,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeDefined()
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1927,7 +1927,7 @@ describe('Selection strategies test suite', () => {
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         pool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBe(0)
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
index 7cdd327b0f0d1ee0eb9195810a3d5f9f75a562cc..e9de670a8a67edcad5dd72118ab4c80de9af686d 100644 (file)
@@ -32,7 +32,7 @@ describe('Weighted round robin strategy worker choice strategy test suite', () =
     )
     const resetResult = strategy.reset()
     expect(resetResult).toBe(true)
-    expect(strategy.nextWorkerNodeId).toBe(0)
+    expect(strategy.nextWorkerNodeKey).toBe(0)
     expect(strategy.workerVirtualTaskRunTime).toBe(0)
   })
 })
index 56847302653d1ee6df62a1a9bc44499ce8256b9b..4f3dfb6d92f0a761a8cfbc766a91fde55b1c29b8 100644 (file)
@@ -103,7 +103,7 @@ describe('Dynamic thread pool test suite', () => {
     expect(
       longRunningPool.workerChoiceStrategyContext.workerChoiceStrategies.get(
         longRunningPool.workerChoiceStrategyContext.workerChoiceStrategy
-      ).nextWorkerNodeId
+      ).nextWorkerNodeKey
     ).toBeLessThan(longRunningPool.workerNodes.length)
     // We need to clean up the resources after our test
     await longRunningPool.destroy()