use of com.exalttech.trex.ui.views.storages.StatsStorage in project trex-stateless-gui by cisco-system-traffic-generator.
the class LatencyLineChart method render.
@Override
protected void render() {
getChart().getData().clear();
final StatsStorage statsStorage = StatsStorage.getInstance();
final Map<Integer, String> selectedPGIDs = statsStorage.getPGIDsStorage().getSelectedPGIds();
final PGIDStatsStorage pgIDStatsStorage = statsStorage.getPGIDStatsStorage();
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getLatencyStatPointHistoryMap();
final List<XYChart.Series<Double, Number>> seriesList = new LinkedList<>();
synchronized (pgIDStatsStorage.getLatencyLock()) {
latencyStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<LatencyStatPoint> history) -> {
if (history == null || history.isEmpty()) {
return;
}
final String color = selectedPGIDs.get(pgID);
if (color == null) {
return;
}
final double lastTime = history.last().getTime();
final XYChart.Series<Double, Number> series = new XYChart.Series<>();
series.setName(String.valueOf(pgID));
int size = history.size();
for (int i = 0; i < size; ++i) {
final LatencyStatPoint point = history.get(i);
final double time = point.getTime();
series.getData().add(new XYChart.Data<>(time - lastTime, getValue(point)));
}
setSeriesColor(series, color);
seriesList.add(series);
});
}
getChart().getData().addAll(seriesList);
}
use of com.exalttech.trex.ui.views.storages.StatsStorage in project trex-stateless-gui by cisco-system-traffic-generator.
the class StreamLineChart method render.
@Override
protected void render() {
getChart().getData().clear();
final StatsStorage statsStorage = StatsStorage.getInstance();
final Map<Integer, String> selectedPGIDs = statsStorage.getPGIDsStorage().getSelectedPGIds();
final PGIDStatsStorage pgIDStatsStorage = statsStorage.getPGIDStatsStorage();
final Map<Integer, ArrayHistory<FlowStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getFlowStatPointHistoryMap();
final List<XYChart.Series<Double, Number>> seriesList = new LinkedList<>();
final Formatter formatter = new Formatter();
synchronized (pgIDStatsStorage.getFlowLock()) {
latencyStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<FlowStatPoint> history) -> {
if (history == null || history.isEmpty()) {
return;
}
final String color = selectedPGIDs.get(pgID);
if (color == null) {
return;
}
final double lastTime = history.last().getTime();
final XYChart.Series<Double, Number> series = new XYChart.Series<>();
series.setName(String.valueOf(pgID));
int size = history.size();
for (int i = 0; i < size; ++i) {
final FlowStatPoint point = history.get(i);
final double time = point.getTime();
final Number value = getValue(point);
formatter.addValue(value);
series.getData().add(new XYChart.Data<>(time - lastTime, value));
}
setSeriesColor(series, color);
seriesList.add(series);
});
}
getChart().getData().addAll(seriesList);
getYAxis().setLabel(String.format("%s (%s%s)", getYChartName(), formatter.getUnitsPrefix(), getYChartUnits()));
}
use of com.exalttech.trex.ui.views.storages.StatsStorage in project trex-stateless-gui by cisco-system-traffic-generator.
the class LatencyHistogram method render.
public void render() {
histogram.getData().clear();
xAxis.setAutoRanging(true);
final StatsStorage statsStorage = StatsStorage.getInstance();
final Map<Integer, String> selectedPGIDs = statsStorage.getPGIDsStorage().getSelectedPGIds();
final PGIDStatsStorage pgIDStatsStorage = statsStorage.getPGIDStatsStorage();
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getLatencyStatPointHistoryMap();
final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap = pgIDStatsStorage.getLatencyStatPointShadowMap();
final String[] histogramKeys = pgIDStatsStorage.getHistogramKeys(HISTOGRAM_SIZE);
final List<XYChart.Series<String, Long>> seriesList = new LinkedList<>();
synchronized (pgIDStatsStorage.getLatencyLock()) {
latencyStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<LatencyStatPoint> history) -> {
if (history == null || history.isEmpty()) {
return;
}
final String color = selectedPGIDs.get(pgID);
if (color == null) {
return;
}
final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
final Map<String, Long> shadowHistogram = latencyShadow != null ? latencyShadow.getLatencyStat().getLat().getHistogram() : new HashMap<>();
final Map<String, Long> histogram = history.last().getLatencyStat().getLat().getHistogram();
final XYChart.Series<String, Long> series = new XYChart.Series<>();
series.setName(String.valueOf(pgID));
for (final String key : histogramKeys) {
final long value = histogram.getOrDefault(key, 0L);
final long shadowValue = shadowHistogram.getOrDefault(key, 0L);
series.getData().add(new XYChart.Data<>(key, value - shadowValue));
}
setSeriesColor(series, color);
seriesList.add(series);
});
}
if (seriesList.isEmpty()) {
return;
}
histogram.getData().addAll(seriesList);
xAxis.setAutoRanging(true);
}
Aggregations