| 9 | |
| 10 | class LoadEstimator { |
| 11 | constructor(jobType, maxJobCount, warnOnOldJobs) { |
| 12 | debug(`LoadEstimator(): jobType = ${jobType}`); |
| 13 | this.jobType = jobType; |
| 14 | const nowMS = Date.now(); |
| 15 | this.lastEstimateTimeMS = nowMS; |
| 16 | this.lastIncrementTimeMS = nowMS; |
| 17 | this.integratedLoad = 0; |
| 18 | this.currentJobs = {}; |
| 19 | this.maxJobCount = maxJobCount || 1; |
| 20 | this.warnOnOldJobs = (warnOnOldJobs == null) ? true : warnOnOldJobs; |
| 21 | this.timeoutID = null; |
| 22 | this.active = true; |
| 23 | this._reportLoad(); |
| 24 | } |
| 25 | |
| 26 | startJob(id) { |
| 27 | debug(`LoadEstimator.startJob(): jobType = ${this.jobType}, id = ${id}`); |