mirror of
https://github.com/Telecominfraproject/wlan-cloud-rrm.git
synced 2025-10-29 17:52:24 +00:00
scale testing code
This commit is contained in:
committed by
Jun Woo Shin
parent
c635af6c1d
commit
0279437f5c
@@ -135,5 +135,9 @@
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jol</groupId>
|
||||
<artifactId>jol-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -47,17 +47,17 @@ public class DeviceDataManager {
|
||||
private final ReadWriteLock topologyLock = new ReentrantReadWriteLock();
|
||||
|
||||
/** Lock on {@link #deviceLayeredConfig}. */
|
||||
private final ReadWriteLock deviceLayeredConfigLock =
|
||||
public final ReadWriteLock deviceLayeredConfigLock =
|
||||
new ReentrantReadWriteLock();
|
||||
|
||||
/** The current device topology. */
|
||||
private DeviceTopology topology;
|
||||
public DeviceTopology topology;
|
||||
|
||||
/** The current layered device config. */
|
||||
private DeviceLayeredConfig deviceLayeredConfig;
|
||||
public DeviceLayeredConfig deviceLayeredConfig;
|
||||
|
||||
/** The cached device configs (map of serial number to computed config). */
|
||||
private Map<String, DeviceConfig> cachedDeviceConfigs =
|
||||
public Map<String, DeviceConfig> cachedDeviceConfigs =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
/** Empty constructor without backing files (ex. for unit tests). */
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.facebook.openwifi.rrm.optimizers.tpc.RandomTxPowerInitializer;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import org.openjdk.jol.info.GraphLayout;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
import io.swagger.v3.jaxrs2.Reader;
|
||||
@@ -311,6 +312,7 @@ public class ApiServer implements Runnable {
|
||||
service.get("/api/v1/currentModel", new GetCurrentModelEndpoint());
|
||||
service.get("/api/v1/optimizeChannel", new OptimizeChannelEndpoint());
|
||||
service.get("/api/v1/optimizeTxPower", new OptimizeTxPowerEndpoint());
|
||||
service.get("/api/v1/memory", new MemoryEndpoint(this));
|
||||
|
||||
logger.info(
|
||||
"API server listening for HTTP internal on port {} and external on port {}",
|
||||
@@ -1360,6 +1362,91 @@ public class ApiServer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Path("/api/v1/memory")
|
||||
public class MemoryEndpoint implements Route {
|
||||
private final ApiServer apiServer;
|
||||
|
||||
MemoryEndpoint(ApiServer server) {
|
||||
this.apiServer = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Request request, Response response) {
|
||||
String type = request.queryParamOrDefault("type", "");
|
||||
String view = request.queryParamOrDefault("view", "footprint");
|
||||
|
||||
java.util.function.Function<GraphLayout, String> fn = (GraphLayout graph) -> {
|
||||
return view.equals("footprint") ? graph.toFootprint() : graph.toPrintable();
|
||||
};
|
||||
|
||||
String result;
|
||||
switch (type) {
|
||||
case "modeler.dataModel":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.dataModel));
|
||||
break;
|
||||
|
||||
case "modeler.dataModel.latestWifiScans":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.dataModel.latestWifiScans));
|
||||
break;
|
||||
|
||||
case "modeler.dataModel.latestStates":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.dataModel.latestStates));
|
||||
break;
|
||||
|
||||
case "modeler.dataModel.latestDeviceStatusRadios":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.dataModel.latestDeviceStatusRadios));
|
||||
break;
|
||||
|
||||
case "modeler.deviceDataManager":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.deviceDataManager));
|
||||
break;
|
||||
|
||||
case "modeler.deviceDataManager.topology":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.deviceDataManager.topology));
|
||||
break;
|
||||
|
||||
case "modeler.deviceDataManager.deviceLayeredConfig":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.deviceDataManager.deviceLayeredConfig));
|
||||
break;
|
||||
|
||||
case "modeler.deviceDataManager.cachedDeviceConfigs":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.deviceDataManager.cachedDeviceConfigs));
|
||||
break;
|
||||
|
||||
case "modeler.dataModel.latestDeviceCapabilities":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler.dataModel.latestDeviceCapabilities));
|
||||
|
||||
case "modeler":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.modeler));
|
||||
break;
|
||||
|
||||
case "configManager.deviceDataMap":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.configManager.deviceDataMap));
|
||||
break;
|
||||
|
||||
case "configManager":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.configManager));
|
||||
break;
|
||||
|
||||
case "scheduler":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.scheduler));
|
||||
break;
|
||||
|
||||
case "deviceDataManager":
|
||||
result = fn.apply(GraphLayout.parseInstance(apiServer.deviceDataManager));
|
||||
break;
|
||||
|
||||
case "":
|
||||
default:
|
||||
result = GraphLayout.parseInstance(apiServer).toFootprint();
|
||||
break;
|
||||
}
|
||||
|
||||
logger.info("MEMORY RESPONSE: \n{}", result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Path("/api/v1/optimizeTxPower")
|
||||
public class OptimizeTxPowerEndpoint implements Route {
|
||||
// Hack for use in @ApiResponse -> @Content -> @Schema
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ConfigManager implements Runnable {
|
||||
private final UCentralClient client;
|
||||
|
||||
/** Runtime per-device data. */
|
||||
private class DeviceData {
|
||||
public class DeviceData {
|
||||
/** Last received device config. */
|
||||
public UCentralApConfiguration config;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ConfigManager implements Runnable {
|
||||
}
|
||||
|
||||
/** Map from device serial number to runtime data. */
|
||||
private Map<String, DeviceData> deviceDataMap = new TreeMap<>();
|
||||
public Map<String, DeviceData> deviceDataMap = new TreeMap<>();
|
||||
|
||||
/** The main thread reference (i.e. where {@link #run()} is invoked). */
|
||||
private Thread mainThread;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Modeler implements Runnable {
|
||||
private final ModelerParams params;
|
||||
|
||||
/** The device data manager. */
|
||||
private final DeviceDataManager deviceDataManager;
|
||||
public final DeviceDataManager deviceDataManager;
|
||||
|
||||
/** The uCentral client instance. */
|
||||
private final UCentralClient client;
|
||||
@@ -74,7 +74,7 @@ public class Modeler implements Runnable {
|
||||
}
|
||||
|
||||
/** The blocking data queue. */
|
||||
private final BlockingQueue<InputData> dataQueue =
|
||||
public final BlockingQueue<InputData> dataQueue =
|
||||
new LinkedBlockingQueue<>();
|
||||
|
||||
/** Data model representation. */
|
||||
|
||||
Reference in New Issue
Block a user