### Changed
- Refactor pool worker node usage internals.
+- Refactor worker choice strategy statistics requirements.
### Fixed
- `workerChoiceStrategyOptions` (optional) - The worker choice strategy options object to use in this pool.
Properties:
- - `medRunTime` (optional) - Use the tasks median runtime instead of the tasks average runtime in worker choice strategies.
+ - `runTime` (optional) - Use the tasks median runtime instead of the tasks average runtime in worker choice strategies.
+ - `waitTime` (optional) - Use the tasks median wait time instead of the tasks average wait time in worker choice strategies.
- `weights` (optional) - The worker weights to use in the weighted round robin worker choice strategy: `{ 0: 200, 1: 300, ..., n: 100 }`
- Default: `{ medRunTime: false }`
+ Default: `{ runTime: { median: false }, waitTime: { median: false } }`
- `restartWorkerOnError` (optional) - Restart worker on uncaught error in this pool.
Default: `true`
): void {
if (
this.workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime
+ .aggregate
) {
- workerUsage.runTime.aggregation += message.taskPerformance?.runTime ?? 0
+ workerUsage.runTime.aggregate += message.taskPerformance?.runTime ?? 0
if (
- this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
- .avgRunTime &&
+ this.workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime
+ .average &&
workerUsage.tasks.executed !== 0
) {
workerUsage.runTime.average =
- workerUsage.runTime.aggregation / workerUsage.tasks.executed
+ workerUsage.runTime.aggregate / workerUsage.tasks.executed
}
if (
- this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
- .medRunTime &&
+ this.workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime
+ .median &&
message.taskPerformance?.runTime != null
) {
workerUsage.runTime.history.push(message.taskPerformance.runTime)
const taskWaitTime = timestamp - (task.timestamp ?? timestamp)
if (
this.workerChoiceStrategyContext.getTaskStatisticsRequirements().waitTime
+ .aggregate
) {
- workerUsage.waitTime.aggregation += taskWaitTime ?? 0
+ workerUsage.waitTime.aggregate += taskWaitTime ?? 0
if (
this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
- .avgWaitTime &&
+ .waitTime.average &&
workerUsage.tasks.executed !== 0
) {
workerUsage.waitTime.average =
- workerUsage.waitTime.aggregation / workerUsage.tasks.executed
+ workerUsage.waitTime.aggregate / workerUsage.tasks.executed
}
if (
this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
- .medWaitTime &&
+ .waitTime.median &&
taskWaitTime != null
) {
workerUsage.waitTime.history.push(taskWaitTime)
statistics: {
runTime:
this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
- .runTime,
+ .runTime.aggregate,
elu: this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
.elu
}
return {
tasks: this.getTaskStatistics(worker),
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: new CircularArray()
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: new CircularArray()
private toggleFindLastFreeWorkerNodeKey: boolean = false
/** @inheritDoc */
public readonly taskStatisticsRequirements: TaskStatisticsRequirements = {
- runTime: false,
- avgRunTime: false,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
}
this.choose = this.choose.bind(this)
}
- protected setTaskStatistics (opts: WorkerChoiceStrategyOptions): void {
+ protected setTaskStatisticsRequirements (
+ opts: WorkerChoiceStrategyOptions
+ ): void {
if (
- this.taskStatisticsRequirements.avgRunTime &&
- opts.medRunTime === true
+ this.taskStatisticsRequirements.runTime.average &&
+ opts.runTime?.median === true
) {
- this.taskStatisticsRequirements.avgRunTime = false
- this.taskStatisticsRequirements.medRunTime = opts.medRunTime as boolean
+ this.taskStatisticsRequirements.runTime.average = false
+ this.taskStatisticsRequirements.runTime.median = opts.runTime
+ .median as boolean
}
if (
- this.taskStatisticsRequirements.medRunTime &&
- opts.medRunTime === false
+ this.taskStatisticsRequirements.runTime.median &&
+ opts.runTime?.median === false
) {
- this.taskStatisticsRequirements.avgRunTime = true
- this.taskStatisticsRequirements.medRunTime = opts.medRunTime as boolean
+ this.taskStatisticsRequirements.runTime.average = true
+ this.taskStatisticsRequirements.runTime.median = opts.runTime
+ .median as boolean
}
if (
- this.taskStatisticsRequirements.avgWaitTime &&
- opts.medWaitTime === true
+ this.taskStatisticsRequirements.waitTime.average &&
+ opts.waitTime?.median === true
) {
- this.taskStatisticsRequirements.avgWaitTime = false
- this.taskStatisticsRequirements.medWaitTime = opts.medWaitTime as boolean
+ this.taskStatisticsRequirements.waitTime.average = false
+ this.taskStatisticsRequirements.waitTime.median = opts.waitTime
+ .median as boolean
}
if (
- this.taskStatisticsRequirements.medWaitTime &&
- opts.medWaitTime === false
+ this.taskStatisticsRequirements.waitTime.median &&
+ opts.waitTime?.median === false
) {
- this.taskStatisticsRequirements.avgWaitTime = true
- this.taskStatisticsRequirements.medWaitTime = opts.medWaitTime as boolean
+ this.taskStatisticsRequirements.waitTime.average = true
+ this.taskStatisticsRequirements.waitTime.median = opts.waitTime
+ .median as boolean
}
}
/** @inheritDoc */
public setOptions (opts: WorkerChoiceStrategyOptions): void {
opts = opts ?? DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
- this.setTaskStatistics(opts)
+ this.setTaskStatisticsRequirements(opts)
this.opts = opts
}
/**
* Gets the worker task runtime.
- * If the task statistics require `avgRunTime`, the average runtime is returned.
- * If the task statistics require `medRunTime`, the median runtime is returned.
+ * If the task statistics require the average runtime, the average runtime is returned.
+ * If the task statistics require the median runtime , the median runtime is returned.
*
* @param workerNodeKey - The worker node key.
* @returns The worker task runtime.
*/
protected getWorkerTaskRunTime (workerNodeKey: number): number {
- return this.taskStatisticsRequirements.medRunTime
+ return this.taskStatisticsRequirements.runTime.median
? this.pool.workerNodes[workerNodeKey].workerUsage.runTime.median
: this.pool.workerNodes[workerNodeKey].workerUsage.runTime.average
}
/**
* Gets the worker task wait time.
- * If the task statistics require `avgWaitTime`, the average wait time is returned.
- * If the task statistics require `medWaitTime`, the median wait time is returned.
+ * If the task statistics require the average wait time, the average wait time is returned.
+ * If the task statistics require the median wait time, the median wait time is returned.
*
* @param workerNodeKey - The worker node key.
* @returns The worker task wait time.
*/
protected getWorkerWaitTime (workerNodeKey: number): number {
- return this.taskStatisticsRequirements.medWaitTime
+ return this.taskStatisticsRequirements.waitTime.median
? this.pool.workerNodes[workerNodeKey].workerUsage.runTime.median
: this.pool.workerNodes[workerNodeKey].workerUsage.runTime.average
}
implements IWorkerChoiceStrategy {
/** @inheritDoc */
public readonly taskStatisticsRequirements: TaskStatisticsRequirements = {
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
}
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setTaskStatistics(this.opts)
+ this.setTaskStatisticsRequirements(this.opts)
}
/** @inheritDoc */
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setTaskStatistics(this.opts)
+ this.setTaskStatisticsRequirements(this.opts)
this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
this.roundWeights = this.getRoundWeights()
}
implements IWorkerChoiceStrategy {
/** @inheritDoc */
public readonly taskStatisticsRequirements: TaskStatisticsRequirements = {
- runTime: true,
- avgRunTime: false,
- medRunTime: false,
- waitTime: true,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: true,
+ average: false,
+ median: false
+ },
elu: false
}
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setTaskStatistics(this.opts)
+ this.setTaskStatisticsRequirements(this.opts)
}
/** @inheritDoc */
let leastBusyWorkerNodeKey!: number
for (const [workerNodeKey, workerNode] of this.pool.workerNodes.entries()) {
const workerTime =
- workerNode.workerUsage.runTime.aggregation +
- workerNode.workerUsage.waitTime.aggregation
+ workerNode.workerUsage.runTime.aggregate +
+ workerNode.workerUsage.waitTime.aggregate
if (workerTime === 0) {
return workerNodeKey
} else if (workerTime < minTime) {
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setTaskStatistics(this.opts)
+ this.setTaskStatisticsRequirements(this.opts)
}
/** @inheritDoc */
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setTaskStatistics(this.opts)
+ this.setTaskStatisticsRequirements(this.opts)
}
/** @inheritDoc */
*/
export type WorkerChoiceStrategy = keyof typeof WorkerChoiceStrategies
+/**
+ * Measurement options.
+ */
+interface MeasurementOptions {
+ /**
+ * Set measurement median.
+ */
+ median: boolean
+}
+
/**
* Worker choice strategy options.
*/
export interface WorkerChoiceStrategyOptions {
/**
- * Use tasks median runtime instead of average runtime.
+ * Runtime options.
*
- * @defaultValue false
+ * @defaultValue \{ median: false \}
*/
- medRunTime?: boolean
+ runTime?: MeasurementOptions
/**
- * Use tasks median wait time instead of average runtime.
+ * Wait time options.
*
- * @defaultValue false
+ * @defaultValue \{ median: false \}
*/
- medWaitTime?: boolean
+ waitTime?: MeasurementOptions
/**
* Worker weights to use for weighted round robin worker selection strategy.
* Weight is the tasks maximum average or median runtime in milliseconds.
}
/**
- * Pool worker node worker usage statistics requirements.
+ * Measurement statistics requirements.
*
* @internal
*/
-export interface TaskStatisticsRequirements {
- /**
- * Require tasks runtime.
- */
- runTime: boolean
+interface MeasurementStatisticsRequirements {
/**
- * Require tasks average runtime.
+ * Require measurement aggregate.
*/
- avgRunTime: boolean
+ aggregate: boolean
/**
- * Require tasks median runtime.
+ * Require measurement average.
*/
- medRunTime: boolean
+ average: boolean
/**
- * Require tasks wait time.
+ * Require measurement median.
*/
- waitTime: boolean
+ median: boolean
+}
+
+/**
+ * Pool worker node worker usage statistics requirements.
+ *
+ * @internal
+ */
+export interface TaskStatisticsRequirements {
/**
- * Require tasks average wait time.
+ * Tasks runtime requirements.
*/
- avgWaitTime: boolean
+ runTime: MeasurementStatisticsRequirements
/**
- * Require tasks median wait time.
+ * Tasks wait time requirements.
*/
- medWaitTime: boolean
+ waitTime: MeasurementStatisticsRequirements
/**
* Event loop utilization.
*/
implements IWorkerChoiceStrategy {
/** @inheritDoc */
public readonly taskStatisticsRequirements: TaskStatisticsRequirements = {
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
}
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setTaskStatistics(this.opts)
+ this.setTaskStatisticsRequirements(this.opts)
this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
}
*/
export interface MeasurementStatistics {
/**
- * Measurement aggregation.
+ * Measurement aggregate.
*/
- aggregation: number
+ aggregate: number
/**
* Measurement average.
*/
*/
export const DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS: WorkerChoiceStrategyOptions =
{
- medRunTime: false,
- medWaitTime: false
+ runTime: { median: false },
+ waitTime: { median: false }
}
/**
WorkerChoiceStrategies.ROUND_ROBIN
)
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- medRunTime: false,
- medWaitTime: false
+ runTime: { median: false },
+ waitTime: { median: false }
})
expect(pool.opts.messageHandler).toBeUndefined()
expect(pool.opts.errorHandler).toBeUndefined()
{
workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED,
workerChoiceStrategyOptions: {
- medRunTime: true,
+ runTime: { median: true },
weights: { 0: 300, 1: 200 }
},
enableEvents: false,
WorkerChoiceStrategies.LEAST_USED
)
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- medRunTime: true,
+ runTime: { median: true },
weights: { 0: 300, 1: 200 }
})
expect(pool.opts.messageHandler).toStrictEqual(testHandler)
{ workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
)
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- medRunTime: false,
- medWaitTime: false
+ runTime: { median: false },
+ waitTime: { median: false }
})
for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
.workerChoiceStrategies) {
expect(workerChoiceStrategy.opts).toStrictEqual({
- medRunTime: false,
- medWaitTime: false
+ runTime: { median: false },
+ waitTime: { median: false }
})
}
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
- pool.setWorkerChoiceStrategyOptions({ medRunTime: true })
+ pool.setWorkerChoiceStrategyOptions({ runTime: { median: true } })
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- medRunTime: true
+ runTime: { median: true }
})
for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
.workerChoiceStrategies) {
- expect(workerChoiceStrategy.opts).toStrictEqual({ medRunTime: true })
+ expect(workerChoiceStrategy.opts).toStrictEqual({
+ runTime: { median: true }
+ })
}
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: false,
- medRunTime: true,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: false,
+ median: true
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
- pool.setWorkerChoiceStrategyOptions({ medRunTime: false })
+ pool.setWorkerChoiceStrategyOptions({ runTime: { median: false } })
expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
- medRunTime: false
+ runTime: { median: false }
})
for (const [, workerChoiceStrategy] of pool.workerChoiceStrategyContext
.workerChoiceStrategies) {
- expect(workerChoiceStrategy.opts).toStrictEqual({ medRunTime: false })
+ expect(workerChoiceStrategy.opts).toStrictEqual({
+ runTime: { median: false }
+ })
}
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
await pool.destroy()
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: false,
- avgRunTime: false,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: false,
- avgRunTime: false,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
// We need to clean up the resources after our test
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: false,
- avgRunTime: false,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: false,
- avgRunTime: false,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
// We need to clean up the resources after our test
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: false,
- medRunTime: false,
- waitTime: true,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: true,
+ average: false,
+ median: false
+ },
elu: false
})
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: false,
- medRunTime: false,
- waitTime: true,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: true,
+ average: false,
+ median: false
+ },
elu: false
})
// We need to clean up the resources after our test
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThanOrEqual(
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThanOrEqual(0)
+ expect(workerNode.workerUsage.waitTime.aggregate).toBeGreaterThanOrEqual(
0
)
- expect(
- workerNode.workerUsage.waitTime.aggregation
- ).toBeGreaterThanOrEqual(0)
}
// We need to clean up the resources after our test
await pool.destroy()
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThan(0)
- expect(workerNode.workerUsage.waitTime.aggregation).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.waitTime.aggregate).toBeGreaterThan(0)
}
// We need to clean up the resources after our test
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
// We need to clean up the resources after our test
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: expect.any(Number),
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
elu: undefined
})
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
expect(workerNode.workerUsage.runTime.average).toBeGreaterThan(0)
}
expect(
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: expect.any(Number),
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
elu: undefined
})
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
expect(workerNode.workerUsage.runTime.average).toBeGreaterThan(0)
}
expect(
{
workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE,
workerChoiceStrategyOptions: {
- medRunTime: true
+ runTime: { median: true }
}
}
)
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: 0,
median: expect.any(Number),
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
elu: undefined
})
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
expect(workerNode.workerUsage.runTime.median).toBeGreaterThan(0)
}
expect(
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: true,
- avgRunTime: true,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: true,
+ average: true,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
// We need to clean up the resources after our test
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: expect.any(Number),
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThanOrEqual(
- 0
- )
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThanOrEqual(0)
expect(workerNode.workerUsage.runTime.average).toBeGreaterThanOrEqual(0)
}
expect(
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: expect.any(Number),
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
expect(workerNode.workerUsage.runTime.average).toBeGreaterThan(0)
}
expect(
{
workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN,
workerChoiceStrategyOptions: {
- medRunTime: true
+ runTime: { median: true }
}
}
)
failed: 0
},
runTime: {
- aggregation: expect.any(Number),
+ aggregate: expect.any(Number),
average: 0,
median: expect.any(Number),
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
expect(workerNode.workerUsage.tasks.executed).toBeLessThanOrEqual(
max * maxMultiplier
)
- expect(workerNode.workerUsage.runTime.aggregation).toBeGreaterThan(0)
+ expect(workerNode.workerUsage.runTime.aggregate).toBeGreaterThan(0)
expect(workerNode.workerUsage.runTime.median).toBeGreaterThan(0)
}
expect(
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: false,
- avgRunTime: false,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
await pool.destroy()
expect(
pool.workerChoiceStrategyContext.getTaskStatisticsRequirements()
).toStrictEqual({
- runTime: false,
- avgRunTime: false,
- medRunTime: false,
- waitTime: false,
- avgWaitTime: false,
- medWaitTime: false,
+ runTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
+ waitTime: {
+ aggregate: false,
+ average: false,
+ median: false
+ },
elu: false
})
// We need to clean up the resources after our test
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
failed: 0
},
runTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
},
waitTime: {
- aggregation: 0,
+ aggregate: 0,
average: 0,
median: 0,
history: expect.any(CircularArray)
fixedPool,
wwrWorkerChoiceStrategy,
{
- medRunTime: true
+ runTime: { median: true }
}
)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().avgRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime
+ .average
).toBe(false)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().medRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime.median
).toBe(true)
workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool,
wwrWorkerChoiceStrategy,
{
- medRunTime: true
+ runTime: { median: true }
}
)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().avgRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime
+ .average
).toBe(false)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().medRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime.median
).toBe(true)
const fsWorkerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
fixedPool,
fsWorkerChoiceStrategy,
{
- medRunTime: true
+ runTime: { median: true }
}
)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().avgRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime
+ .average
).toBe(false)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().medRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime.median
).toBe(true)
workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
dynamicPool,
fsWorkerChoiceStrategy,
{
- medRunTime: true
+ runTime: { median: true }
}
)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().avgRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime
+ .average
).toBe(false)
expect(
- workerChoiceStrategyContext.getTaskStatisticsRequirements().medRunTime
+ workerChoiceStrategyContext.getTaskStatisticsRequirements().runTime.median
).toBe(true)
})
})