use of com.exalttech.trex.ui.models.stats.FlowStatPoint 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.models.stats.FlowStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.
the class PGIDStatsStorage method resetFlowStats.
private void resetFlowStats() {
synchronized (flowLock) {
flowStatPointShadowMap.clear();
flowStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<FlowStatPoint> history) -> {
if (!history.isEmpty()) {
final FlowStatPoint last = history.last();
flowStatPointShadowMap.put(pgID, history.last());
history.clear();
history.add(last);
}
});
}
}
use of com.exalttech.trex.ui.models.stats.FlowStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.
the class Latency method renderWindow.
private void renderWindow() {
table.getChildren().clear();
int hCol = 0;
table.add(new HeaderCell(FIRST_COLUMN_WIDTH, "PG ID"), 0, hCol++);
table.add(new StatisticLabelCell("Tx pkt", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Rx pkt", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Max Latency", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Avg Latency", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Last (max)", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
for (int i = 0; i < WINDOW_SIZE - 1; ++i) {
table.add(new StatisticLabelCell(String.format("Last-%d", i + 1), FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
}
table.add(new StatisticLabelCell("Jitter", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol++);
table.add(new StatisticLabelCell("Errors", FIRST_COLUMN_WIDTH, hCol % 2 == 0, CellType.DEFAULT_CELL, false), 0, hCol);
final PGIDStatsStorage pgIDStatsStorage = StatsStorage.getInstance().getPGIDStatsStorage();
final Map<Integer, ArrayHistory<FlowStatPoint>> flowStatPointHistoryMap = pgIDStatsStorage.getFlowStatPointHistoryMap();
final Map<Integer, FlowStatPoint> flowStatPointShadowMap = pgIDStatsStorage.getFlowStatPointShadowMap();
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = pgIDStatsStorage.getLatencyStatPointHistoryMap();
final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap = pgIDStatsStorage.getLatencyStatPointShadowMap();
int rowIndex = 1;
synchronized (pgIDStatsStorage.getFlowLock()) {
synchronized (pgIDStatsStorage.getLatencyLock()) {
for (final Map.Entry<Integer, ArrayHistory<FlowStatPoint>> entry : flowStatPointHistoryMap.entrySet()) {
final int pgID = entry.getKey();
final ArrayHistory<FlowStatPoint> flowHistory = entry.getValue();
if (flowHistory == null || flowHistory.isEmpty()) {
continue;
}
final FlowStatPoint flowStatPoint = flowHistory.last();
final ArrayHistory<LatencyStatPoint> latencyHistory = latencyStatPointHistoryMap.get(pgID);
if (latencyHistory == null || latencyHistory.isEmpty()) {
continue;
}
final LatencyStat latencyStat = latencyHistory.last().getLatencyStat();
final long[] window = new long[WINDOW_SIZE];
for (int i = 0; i < WINDOW_SIZE; ++i) {
window[i] = 0;
}
final int latencyHistorySize = latencyHistory.size();
final int size = Math.min(latencyHistorySize, WINDOW_SIZE);
for (int i = 0; i < size; i++) {
window[i] = latencyHistory.get(latencyHistorySize - 1 - i).getLatencyStat().getLat().getLastMax();
}
long tp = flowStatPoint.getTp();
long rp = flowStatPoint.getRp();
final FlowStatPoint flowShadow = flowStatPointShadowMap.get(pgID);
if (flowShadow != null) {
tp -= flowShadow.getTp();
rp -= flowShadow.getRp();
}
long totalErr = latencyStat.getErr().getTotal();
final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
if (latencyShadow != null) {
totalErr -= latencyShadow.getLatencyStat().getErr().getTotal();
}
final LatencyStatLat lat = latencyStat.getLat();
int col = 0;
table.add(new HeaderCell(COLUMN_WIDTH, String.valueOf(pgID)), rowIndex, col++);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(tp), true, "pkts"), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(rp), true, "pkts"), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.format("%d µs", lat.getTotalMax()), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.format(Locale.US, "%.2f µs", round(lat.getAverage())), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
for (int i = 0; i < WINDOW_SIZE; ++i) {
table.add(new StatisticLabelCell(String.valueOf(window[i]), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
}
table.add(new StatisticLabelCell(String.format("%d µs", lat.getJit()), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true), rowIndex, col++);
table.add(new StatisticLabelCell(String.valueOf(totalErr), COLUMN_WIDTH, true, CellType.ERROR_CELL, true), rowIndex, col++);
rowIndex++;
}
}
}
}
use of com.exalttech.trex.ui.models.stats.FlowStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.
the class Streams method render.
@Override
protected void render() {
int firstColumnWidth = 120;
int secondHeaderWidth = 150;
table.getChildren().clear();
table.add(new HeaderCell(firstColumnWidth, "PG ID"), 0, 0);
table.add(new StatisticLabelCell("Tx pps", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 1);
table.add(new StatisticLabelCell("Tx bps L2", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 2);
table.add(new StatisticLabelCell("Tx bps L1", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 3);
table.add(new StatisticLabelCell("Rx pps", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 4);
table.add(new StatisticLabelCell("Rx bps L2", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 5);
table.add(new StatisticLabelCell("Tx pkts", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 6);
table.add(new StatisticLabelCell("Rx pkts", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 7);
table.add(new StatisticLabelCell("Tx bytes", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 8);
table.add(new StatisticLabelCell("Rx bytes", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 9);
int rowIndex = 1;
final PGIDStatsStorage pgIDStatsStorage = StatsStorage.getInstance().getPGIDStatsStorage();
final Map<Integer, ArrayHistory<FlowStatPoint>> flowStatPointHistoryMap = pgIDStatsStorage.getFlowStatPointHistoryMap();
final Map<Integer, FlowStatPoint> flowStatPointShadowMap = pgIDStatsStorage.getFlowStatPointShadowMap();
synchronized (pgIDStatsStorage.getFlowLock()) {
for (final Map.Entry<Integer, ArrayHistory<FlowStatPoint>> entry : flowStatPointHistoryMap.entrySet()) {
final int pgID = entry.getKey();
final ArrayHistory<FlowStatPoint> history = entry.getValue();
if (history == null || history.isEmpty()) {
continue;
}
final FlowStatPoint flowStatPoint = history.last();
long tp = flowStatPoint.getTp();
long rp = flowStatPoint.getRp();
long tb = flowStatPoint.getTb();
long rb = flowStatPoint.getRb();
final FlowStatPoint shadow = flowStatPointShadowMap.get(pgID);
if (shadow != null) {
tp -= shadow.getTp();
rp -= shadow.getRp();
tb -= shadow.getTb();
rb -= shadow.getRb();
}
table.add(new HeaderCell(secondHeaderWidth, String.valueOf(pgID)), rowIndex, 0);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getTps())), true, "pkt/s"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true), rowIndex, 1);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getTbsL2())), true, "b/s"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true), rowIndex, 2);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getTbsL1())), true, "b/s"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true), rowIndex, 3);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getRps())), true, "pkt/s"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true), rowIndex, 4);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getRbsL2())), true, "b/s"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true), rowIndex, 5);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(tp), true, "pkts"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true), rowIndex, 6);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(rp), true, "pkts"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true), rowIndex, 7);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(tb), true, "B"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true), rowIndex, 8);
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(rb), true, "B"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true), rowIndex, 9);
rowIndex++;
}
}
}
use of com.exalttech.trex.ui.models.stats.FlowStatPoint in project trex-stateless-gui by cisco-system-traffic-generator.
the class PGIDStatsStorage method processFlowStats.
private void processFlowStats(final Map<String, FlowStat> flowStatMap, final double time) {
synchronized (flowLock) {
final Set<Integer> unvisitedStreams = new HashSet<>(flowStatPointHistoryMap.keySet());
flowStatMap.forEach((final String pgID, final FlowStat flowStat) -> {
int intPGID;
try {
intPGID = Integer.valueOf(pgID);
} catch (NumberFormatException exc) {
return;
}
unvisitedStreams.remove(intPGID);
final FlowStatPoint statsFlowHistoryPoint = new FlowStatPoint(flowStat, time);
ArrayHistory<FlowStatPoint> history = flowStatPointHistoryMap.get(intPGID);
if (history == null) {
history = new ArrayHistory<>(HISTORY_SIZE);
flowStatPointHistoryMap.put(intPGID, history);
}
history.add(statsFlowHistoryPoint);
flowStatPointShadowMap.putIfAbsent(intPGID, statsFlowHistoryPoint);
});
unvisitedStreams.forEach((final Integer pgID) -> {
flowStatPointHistoryMap.remove(pgID);
flowStatPointShadowMap.remove(pgID);
});
}
}
Aggregations