fix: ensure worker choice strategy internals are reset
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 19 Aug 2023 20:23:27 +0000 (22:23 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 19 Aug 2023 20:23:27 +0000 (22:23 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
src/pools/selection-strategies/interleaved-weighted-round-robin-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

index cc38d196941e4611af2235a84899cd82ab55c9f0..d017122113cce8c5ef62a8f0812522fba1a354ad 100644 (file)
@@ -93,6 +93,11 @@ export abstract class AbstractWorkerChoiceStrategy<
     }
   }
 
+  protected resetWorkerNodeKeyProperties (): void {
+    this.nextWorkerNodeKey = 0
+    this.previousWorkerNodeKey = 0
+  }
+
   /** @inheritDoc */
   public abstract reset (): boolean
 
index 4b59a55461e7e92596c5ead2f7fdaca6eabf9d71..0fc1e0da3da3e8319cb71e90308e324e64fa82bd 100644 (file)
@@ -48,7 +48,7 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public reset (): boolean {
-    this.nextWorkerNodeKey = 0
+    this.resetWorkerNodeKeyProperties()
     this.roundId = 0
     return true
   }
index 7968e621d49df510c06ad2bd4899b56770b3b163..7356a0bc2f4b376ef53eb205529cddeddbd0f434 100644 (file)
@@ -32,7 +32,7 @@ export class RoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public reset (): boolean {
-    this.nextWorkerNodeKey = 0
+    this.resetWorkerNodeKeyProperties()
     return true
   }
 
index 2c03271e329ea0981c3b898e96245aea3ff63669..46575b80d851ec719b783a370d20194b8ba72d58 100644 (file)
@@ -58,7 +58,7 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
 
   /** @inheritDoc */
   public reset (): boolean {
-    this.nextWorkerNodeKey = 0
+    this.resetWorkerNodeKeyProperties()
     this.workerVirtualTaskRunTime = 0
     return true
   }