import type { IWorker } from '../worker.js'
import type {
IWorkerChoiceStrategy,
- MeasurementStatisticsRequirements,
StrategyPolicy,
TaskStatisticsRequirements,
WorkerChoiceStrategyOptions
} from './selection-strategies-types.js'
-import { buildWorkerChoiceStrategyOptions } from './selection-strategies-utils.js'
+import {
+ buildWorkerChoiceStrategyOptions,
+ toggleMedianMeasurementStatisticsRequirements
+} from './selection-strategies-utils.js'
/**
* Worker choice strategy abstract base class.
protected setTaskStatisticsRequirements (
opts: WorkerChoiceStrategyOptions | undefined
): void {
- this.toggleMedianMeasurementStatisticsRequirements(
+ toggleMedianMeasurementStatisticsRequirements(
this.taskStatisticsRequirements.runTime,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
opts!.runTime!.median
)
- this.toggleMedianMeasurementStatisticsRequirements(
+ toggleMedianMeasurementStatisticsRequirements(
this.taskStatisticsRequirements.waitTime,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
opts!.waitTime!.median
)
- this.toggleMedianMeasurementStatisticsRequirements(
+ toggleMedianMeasurementStatisticsRequirements(
this.taskStatisticsRequirements.elu,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
opts!.elu!.median
)
}
- private toggleMedianMeasurementStatisticsRequirements (
- measurementStatisticsRequirements: MeasurementStatisticsRequirements,
- toggleMedian: boolean
- ): void {
- if (measurementStatisticsRequirements.average && toggleMedian) {
- measurementStatisticsRequirements.average = false
- measurementStatisticsRequirements.median = toggleMedian
- }
- if (measurementStatisticsRequirements.median && !toggleMedian) {
- measurementStatisticsRequirements.average = true
- measurementStatisticsRequirements.median = toggleMedian
- }
- }
-
protected resetWorkerNodeKeyProperties (): void {
this.nextWorkerNodeKey = 0
this.previousWorkerNodeKey = 0
import { RoundRobinWorkerChoiceStrategy } from './round-robin-worker-choice-strategy.js'
import {
type IWorkerChoiceStrategy,
+ type MeasurementStatisticsRequirements,
type StrategyPolicy,
type TaskStatisticsRequirements,
WorkerChoiceStrategies,
}
}
+export const toggleMedianMeasurementStatisticsRequirements = (
+ measurementStatisticsRequirements: MeasurementStatisticsRequirements,
+ toggleMedian: boolean
+): void => {
+ if (measurementStatisticsRequirements.average && toggleMedian) {
+ measurementStatisticsRequirements.average = false
+ measurementStatisticsRequirements.median = toggleMedian
+ }
+ if (measurementStatisticsRequirements.median && !toggleMedian) {
+ measurementStatisticsRequirements.average = true
+ measurementStatisticsRequirements.median = toggleMedian
+ }
+}
+
export const buildWorkerChoiceStrategiesPolicy = (
workerChoiceStrategies: Map<WorkerChoiceStrategy, IWorkerChoiceStrategy>
): StrategyPolicy => {