repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: methods namepace cleanup
[poolifier.git]
/
src
/
pools
/
selection-strategies
/
least-used-worker-choice-strategy.ts
diff --git
a/src/pools/selection-strategies/least-used-worker-choice-strategy.ts
b/src/pools/selection-strategies/least-used-worker-choice-strategy.ts
index 5c266f282d229fd5c5647e3305237ac1ee33c865..e8a7218e160879bcaa97399d78a3b39ff7857bc1 100644
(file)
--- a/
src/pools/selection-strategies/least-used-worker-choice-strategy.ts
+++ b/
src/pools/selection-strategies/least-used-worker-choice-strategy.ts
@@
-42,26
+42,33
@@
export class LeastUsedWorkerChoiceStrategy<
/** @inheritDoc */
public choose (): number {
/** @inheritDoc */
public choose (): number {
+ return this.leastUsedNextWorkerNodeKey()
+ }
+
+ /** @inheritDoc */
+ public remove (): boolean {
+ return true
+ }
+
+ private leastUsedNextWorkerNodeKey (): number {
let minNumberOfTasks = Infinity
for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
let minNumberOfTasks = Infinity
for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
- const workerTaskStatistics = workerNode.
workerU
sage.tasks
+ const workerTaskStatistics = workerNode.
u
sage.tasks
const workerTasks =
workerTaskStatistics.executed +
workerTaskStatistics.executing +
workerTaskStatistics.queued
const workerTasks =
workerTaskStatistics.executed +
workerTaskStatistics.executing +
workerTaskStatistics.queued
- if (workerTasks === 0) {
- this.nextWorkerNode
Id
= workerNodeKey
+ if (
this.isWorkerNodeReady(workerNodeKey) &&
workerTasks === 0) {
+ this.nextWorkerNode
Key
= workerNodeKey
break
break
- } else if (workerTasks < minNumberOfTasks) {
+ } else if (
+ this.isWorkerNodeReady(workerNodeKey) &&
+ workerTasks < minNumberOfTasks
+ ) {
minNumberOfTasks = workerTasks
minNumberOfTasks = workerTasks
- this.nextWorkerNode
Id
= workerNodeKey
+ this.nextWorkerNode
Key
= workerNodeKey
}
}
}
}
- return this.nextWorkerNodeId
- }
-
- /** @inheritDoc */
- public remove (): boolean {
- return true
+ return this.nextWorkerNodeKey
}
}
}
}