use of com.cisco.trex.stl.gui.models.CpuUtilStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.
the class CPUUtilizationChartController method render.
public void render(Map<String, ArrayHistory<CpuUtilStatPoint>> cpuUtilizationHistoryMap) {
chart.getData().clear();
final List<XYChart.Series<Double, Number>> seriesList = new LinkedList<>();
final AtomicInteger index = new AtomicInteger(0);
cpuUtilizationHistoryMap.entrySet().stream().limit(colors.length).forEach(entry -> {
String core = entry.getKey();
ArrayHistory<CpuUtilStatPoint> history = entry.getValue();
XYChart.Series<Double, Number> series = new XYChart.Series<>();
series.setName(core);
double lastTime = history.last().getTime();
int size = history.size();
for (int i = 0; i < size; ++i) {
final CpuUtilStatPoint point = history.get(i);
final double time = point.getTime();
series.getData().add(new XYChart.Data<>(time - lastTime, point.getValue()));
}
setSeriesColor(series, colors[index.getAndIncrement()]);
seriesList.add(series);
});
chart.getData().addAll(seriesList);
}
use of com.cisco.trex.stl.gui.models.CpuUtilStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.
the class UtilizationStorage method handleUtilizationReceived.
private void handleUtilizationReceived(final WorkerStateEvent event) {
final UtilizationService service = (UtilizationService) event.getSource();
final Utilization receivedUtilization = service.getValue();
if (receivedUtilization == null) {
return;
}
synchronized (utilizationStatsMonitor) {
synchronized (dataLock) {
List<UtilizationCPU> cpuUtilizationStats = receivedUtilization.getCpu();
int idx = 0;
for (UtilizationCPU cpuUtilizationStat : cpuUtilizationStats) {
String ports = cpuUtilizationStat.getPorts().stream().map(Objects::toString).collect(joining(", "));
String key = String.format("Socket %s (%s)", idx, ports);
String socketKey = String.format("Socket %s", idx);
Optional<Map.Entry<String, ArrayHistory<CpuUtilStatPoint>>> entryOptional = cpuUtilizationHistoryMap.entrySet().stream().filter(entry -> entry.getKey().startsWith(socketKey)).findFirst();
ArrayHistory<CpuUtilStatPoint> history;
if (entryOptional.isPresent()) {
history = entryOptional.get().getValue();
cpuUtilizationHistoryMap.remove(entryOptional.get().getKey());
} else {
history = new ArrayHistory<>(303);
}
int value = cpuUtilizationStat.getHistory().get(0);
double time = System.currentTimeMillis() / 1000.0;
history.add(new CpuUtilStatPoint(value, time));
cpuUtilizationHistoryMap.put(key, history);
idx++;
}
}
cpuUtilsModels = toCPUUtilModel(receivedUtilization.getCpu());
memUtilsModels.clear();
memUtilsModels.add(totalMemUtilization(receivedUtilization.getMbufStats()));
memUtilsModels.addAll(toMemUtilModel(receivedUtilization.getMbufStats()));
memUtilsModels.add(percentageMemUtilization(receivedUtilization.getMbufStats()));
}
handleUtilizationChanged();
}
Aggregations