fix: get wait time statistics
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 23 Jun 2023 19:31:35 +0000 (21:31 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 23 Jun 2023 19:31:35 +0000 (21:31 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
src/worker/abstract-worker.ts

index b9f6e721dca46a192d86aa006eef6df0ef834e8f..476c58bc8bcf45f69450adb196e8886abe6f3b88 100644 (file)
@@ -176,8 +176,8 @@ export abstract class AbstractWorkerChoiceStrategy<
    */
   protected getWorkerTaskWaitTime (workerNodeKey: number): number {
     return this.taskStatisticsRequirements.waitTime.median
-      ? this.pool.workerNodes[workerNodeKey].workerUsage.runTime.median
-      : this.pool.workerNodes[workerNodeKey].workerUsage.runTime.average
+      ? this.pool.workerNodes[workerNodeKey].workerUsage.waitTime.median
+      : this.pool.workerNodes[workerNodeKey].workerUsage.waitTime.average
   }
 
   /**
index a84bb0691fc588d3a8e51b0fe1696d7c85bb7dc9..b0da7b3e8526d2271bc18204c8b4ba6fc961ed21 100644 (file)
@@ -160,13 +160,13 @@ export abstract class AbstractWorker<
     } else if (message.parent != null) {
       // Main worker reference message received
       this.mainWorker = message.parent
+    } else if (message.statistics != null) {
+      // Statistics message received
+      this.statistics = message.statistics
     } else if (message.kill != null) {
       // Kill message received
       this.aliveInterval != null && clearInterval(this.aliveInterval)
       this.emitDestroy()
-    } else if (message.statistics != null) {
-      // Statistics message received
-      this.statistics = message.statistics
     }
   }