X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fleast-busy-worker-choice-strategy.ts;h=a37f91d44fa67276542b8d70b3969a04046f4e72;hb=8b3fccaac505706915540210b9d123e1a12e79ab;hp=91fbfc782579f83950482ba71019c9197e5e6348;hpb=f3a91bac2d5c34013f6394ebbe3576569b0cfcc0;p=poolifier.git diff --git a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts index 91fbfc78..a37f91d4 100644 --- a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts @@ -1,14 +1,11 @@ -import { - DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, - DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS -} from '../../utils' +import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils' import type { IPool } from '../pool' import type { IWorker } from '../worker' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy' import type { IWorkerChoiceStrategy, - TaskStatisticsRequirements, - WorkerChoiceStrategyOptions + InternalWorkerChoiceStrategyOptions, + TaskStatisticsRequirements } from './selection-strategies-types' /** @@ -43,7 +40,7 @@ export class LeastBusyWorkerChoiceStrategy< /** @inheritDoc */ public constructor ( pool: IPool, - opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS + opts: InternalWorkerChoiceStrategyOptions ) { super(pool, opts) this.setTaskStatisticsRequirements(this.opts) @@ -74,10 +71,11 @@ export class LeastBusyWorkerChoiceStrategy< private leastBusyNextWorkerNodeKey (): number | undefined { return this.pool.workerNodes.reduce( (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => { - return (workerNode.usage.runTime?.aggregate ?? 0) + - (workerNode.usage.waitTime?.aggregate ?? 0) < - (workerNodes[minWorkerNodeKey].usage.runTime?.aggregate ?? 0) + - (workerNodes[minWorkerNodeKey].usage.waitTime?.aggregate ?? 0) + return this.isWorkerNodeReady(workerNodeKey) && + (workerNode.usage.runTime.aggregate ?? 0) + + (workerNode.usage.waitTime.aggregate ?? 0) < + (workerNodes[minWorkerNodeKey].usage.runTime.aggregate ?? 0) + + (workerNodes[minWorkerNodeKey].usage.waitTime.aggregate ?? 0) ? workerNodeKey : minWorkerNodeKey },