And sone cleanups.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
"distributeStationsToTenantsEqually": true,
"statisticsDisplayInterval": 60,
"useWorkerPool": false,
- "workerMaxPoolSize": 16,
+ "workerPoolMaxSize": 16,
"chargingStationsPerWorker": 1,
"stationTemplateURLs": [
{
this._workerData = workerData;
this._workerScript = workerScript;
if (Configuration.useWorkerPool()) {
- WorkerPool.maxConcurrentWorkers = Configuration.getWorkerMaxPoolSize();
+ WorkerPool.maxConcurrentWorkers = Configuration.getWorkerPoolMaxSize();
}
}
return;
}
this._workerData = workerData;
- this._worker.postMessage({ id : Constants.START_WORKER_ELEMENT, workerData: workerData });
+ this._worker.postMessage({ id: Constants.START_WORKER_ELEMENT, workerData: workerData });
+ }
+
+ /**
+ *
+ * @return {number}
+ * @public
+ */
+ public getWorkerPoolSize(): number {
+ if (Configuration.useWorkerPool()) {
+ return WorkerPool.getPoolSize();
+ }
}
/**
this._worker = worker;
});
}
-
- /**
- *
- * @return {number}
- * @public
- */
- public getPoolSize(): number {
- return WorkerPool.getPoolSize();
- }
}
}
public static getPoolSize(): number {
- return WorkerPool._instance.size;
+ return WorkerPool.getInstance().size;
}
}
if (Configuration.useWorkerPool()) {
worker = new Wrk('./dist/charging-station/StationWorker.js', workerData);
worker.start().catch(() => { });
- numConcurrentWorkers = worker.getPoolSize();
+ numConcurrentWorkers = worker.getWorkerPoolSize();
numStationsTotal = numConcurrentWorkers;
+ // Start Wrk sequentially to optimize memory at start time
await Utils.sleep(Constants.START_WORKER_DELAY);
} else if (!Configuration.useWorkerPool() && (chargingStationsPerWorkerCounter === 0 || chargingStationsPerWorkerCounter === chargingStationsPerWorker)) {
// Start new Wrk with one charging station
}
if (numStationsTotal === 0) {
console.log('No charging station template enabled in configuration, exiting');
+ } else if (Configuration.useWorkerPool()) {
+ console.log('Charging station simulator started with ' + numStationsTotal.toString() + ' charging station(s) and ' + numConcurrentWorkers.toString() + '/' + Configuration.getWorkerPoolMaxSize().toString() + ' worker(s) concurrently running');
} else {
- if (Configuration.useWorkerPool()) {
- console.log('Charging station simulator started with ' + numStationsTotal.toString() + ' charging station(s) and ' + numConcurrentWorkers.toString() + '/' + Configuration.getWorkerMaxPoolSize() + ' worker(s) concurrently running');
- } else {
- console.log('Charging station simulator started with ' + numStationsTotal.toString() + ' charging station(s) and ' + numConcurrentWorkers.toString() + ' worker(s) concurrently running');
- }
+ console.log('Charging station simulator started with ' + numStationsTotal.toString() + ' charging station(s) and ' + numConcurrentWorkers.toString() + ' worker(s) concurrently running');
}
} catch (error) {
// eslint-disable-next-line no-console
autoReconnectMaxRetries?: number;
distributeStationsToTenantsEqually?: boolean;
useWorkerPool?: boolean;
- workerMaxPoolSize?: number;
+ workerPoolMaxSize?: number;
chargingStationsPerWorker?: number;
logFormat?: string;
logLevel?: string;
return Configuration.getConfig().useWorkerPool;
}
- static getWorkerMaxPoolSize(): number {
- return Configuration.getConfig().workerMaxPoolSize;
+ static getWorkerPoolMaxSize(): number {
+ Configuration.deprecateConfigurationKey('workerPoolSize;', 'Use \'workerPoolMaxSize\' instead');
+ return Configuration.getConfig().workerPoolMaxSize;
}
static getChargingStationsPerWorker(): number {