- const deleted = this.workerLastVirtualTaskTimestamp.delete(workerNodeKey)
- for (const [key, value] of this.workerLastVirtualTaskTimestamp) {
- if (key > workerNodeKey) {
- this.workerLastVirtualTaskTimestamp.set(key - 1, value)
+ this.workersVirtualTaskEndTimestamp.splice(workerNodeKey, 1)
+ return true
+ }
+
+ private fairShareNextWorkerNodeKey (): number | undefined {
+ let chosenWorkerNodeKey: number | undefined
+ let minWorkerVirtualTaskEndTimestamp = Infinity
+ for (const [workerNodeKey] of this.pool.workerNodes.entries()) {
+ if (this.workersVirtualTaskEndTimestamp[workerNodeKey] == null) {
+ this.computeWorkerVirtualTaskEndTimestamp(workerNodeKey)
+ }
+ const workerVirtualTaskEndTimestamp =
+ this.workersVirtualTaskEndTimestamp[workerNodeKey]
+ if (workerVirtualTaskEndTimestamp < minWorkerVirtualTaskEndTimestamp) {
+ minWorkerVirtualTaskEndTimestamp = workerVirtualTaskEndTimestamp
+ chosenWorkerNodeKey = workerNodeKey