Skip to content

Commit 6a084d2

Browse files
authored
Merge pull request #78 from cisco-system-traffic-generator/gui-fixes-dashboard
Gui fixes dashboard
2 parents fd43fbf + 4eb9b0d commit 6a084d2

File tree

13 files changed

+225
-96
lines changed

13 files changed

+225
-96
lines changed

src/main/java/com/cisco/trex/stl/gui/controllers/dashboard/charts/LatencyHistogramController.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ public void render() {
4141
final PGIDStatsStorage pgIDStatsStorage = statsStorage.getPGIDStatsStorage();
4242
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap =
4343
pgIDStatsStorage.getLatencyStatPointHistoryMap();
44-
final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap =
45-
pgIDStatsStorage.getLatencyStatPointShadowMap();
4644
final String[] histogramKeys = pgIDStatsStorage.getHistogramKeys(HISTOGRAM_SIZE);
4745

4846
final List<XYChart.Series<String, Long>> seriesList = new LinkedList<>();
@@ -58,18 +56,12 @@ public void render() {
5856
return;
5957
}
6058

61-
final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
62-
final Map<String, Long> shadowHistogram = latencyShadow != null ?
63-
latencyShadow.getLatencyStat().getLat().getHistogram() :
64-
new HashMap<>();
65-
6659
final Map<String, Long> histogram = history.last().getLatencyStat().getLat().getHistogram();
6760
final XYChart.Series<String, Long> series = new XYChart.Series<>();
6861
series.setName(String.valueOf(pgID));
6962
for (final String key : histogramKeys) {
7063
final long value = histogram.getOrDefault(key, 0L);
71-
final long shadowValue = shadowHistogram.getOrDefault(key, 0L);
72-
series.getData().add(new XYChart.Data<>(key, value - shadowValue));
64+
series.getData().add(new XYChart.Data<>(key, value));
7365
}
7466
setSeriesColor(series, color);
7567
seriesList.add(series);

src/main/java/com/cisco/trex/stl/gui/controllers/dashboard/latency/LatencyController.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ private void renderWindow() {
109109
pgIDStatsStorage.getFlowStatPointShadowMap();
110110
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap =
111111
pgIDStatsStorage.getLatencyStatPointHistoryMap();
112-
final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap =
113-
pgIDStatsStorage.getLatencyStatPointShadowMap();
114112
final Map<Integer, Long> maxLatencyMap = pgIDStatsStorage.getMaxLatencyMap();
115113
final Set<Integer> stoppedPGIds = pgIDStatsStorage.getStoppedPGIds();
116114

@@ -156,11 +154,6 @@ private void renderWindow() {
156154

157155
long totalErr = latencyStat.getErr().getTotal();
158156

159-
final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
160-
if (latencyShadow != null) {
161-
totalErr -= latencyShadow.getLatencyStat().getErr().getTotal();
162-
}
163-
164157
final LatencyStatLat lat = latencyStat.getLat();
165158

166159
final boolean isStopped = stoppedPGIds.contains(pgID);
@@ -188,8 +181,6 @@ private void renderHistogram() {
188181
final PGIDStatsStorage pgIDStatsStorage = StatsStorage.getInstance().getPGIDStatsStorage();
189182
final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap =
190183
pgIDStatsStorage.getLatencyStatPointHistoryMap();
191-
final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap =
192-
pgIDStatsStorage.getLatencyStatPointShadowMap();
193184
final String[] histogramKeys = pgIDStatsStorage.getHistogramKeys(HISTOGRAM_SIZE);
194185
final Set<Integer> stoppedPGIds = pgIDStatsStorage.getStoppedPGIds();
195186

@@ -224,29 +215,13 @@ private void renderHistogram() {
224215
long sth = latencyStatErr.getSth();
225216
long stl = latencyStatErr.getStl();
226217

227-
final LatencyStatPoint latencyShadow = latencyStatPointShadowMap.get(pgID);
228-
Map<String, Long> shadowHistogram;
229-
if (latencyShadow != null) {
230-
final LatencyStatErr latencyStatShadowErr = latencyShadow.getLatencyStat().getErr();
231-
drp -= latencyStatShadowErr.getDrp();
232-
dup -= latencyStatShadowErr.getDup();
233-
ooo -= latencyStatShadowErr.getOoo();
234-
sth -= latencyStatShadowErr.getSth();
235-
stl -= latencyStatShadowErr.getStl();
236-
237-
shadowHistogram = latencyShadow.getLatencyStat().getLat().getHistogram();
238-
} else {
239-
shadowHistogram = new HashMap<>();
240-
}
241-
242218
final boolean isStopped = stoppedPGIds.contains(pgID);
243219

244220
int col = 0;
245221
table.add(new HeaderCell(COLUMN_WIDTH, String.valueOf(pgID), isStopped), rowIndex, col++);
246222
for (final String key : histogramKeys) {
247223
final long value = histogram.getOrDefault(key, 0L);
248-
final long shadowValue = shadowHistogram.getOrDefault(key, 0L);
249-
table.add(new StatisticLabelCell(String.valueOf(value - shadowValue), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true, isStopped), rowIndex, col++);
224+
table.add(new StatisticLabelCell(String.valueOf(value), COLUMN_WIDTH, col % 2 == 0, CellType.DEFAULT_CELL, true, isStopped), rowIndex, col++);
250225
}
251226
table.add(new StatisticLabelCell(String.valueOf(drp), COLUMN_WIDTH, col % 2 == 0, CellType.ERROR_CELL, true, isStopped), rowIndex, col++);
252227
table.add(new StatisticLabelCell(String.valueOf(dup), COLUMN_WIDTH, col % 2 == 0, CellType.ERROR_CELL, true, isStopped), rowIndex, col++);

src/main/java/com/cisco/trex/stl/gui/controllers/dashboard/streams/StreamsController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ protected void render() {
5555
table.add(new StatisticLabelCell("Tx bps L2", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 2);
5656
table.add(new StatisticLabelCell("Tx bps L1", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 3);
5757
table.add(new StatisticLabelCell("Rx pps", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 4);
58-
table.add(new StatisticLabelCell("Rx bps L1", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 5);
59-
table.add(new StatisticLabelCell("Rx bps L2", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 6);
58+
table.add(new StatisticLabelCell("Rx bps L2", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 5);
59+
table.add(new StatisticLabelCell("Rx bps L1", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 6);
6060
table.add(new StatisticLabelCell("Tx pkts", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 7);
6161
table.add(new StatisticLabelCell("Rx pkts", firstColumnWidth, true, CellType.DEFAULT_CELL, false), 0, 8);
6262
table.add(new StatisticLabelCell("Tx bytes", firstColumnWidth, false, CellType.DEFAULT_CELL, false), 0, 9);
@@ -101,8 +101,8 @@ protected void render() {
101101
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getTbsL2())), true, "b/s"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 2);
102102
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getTbsL1())), true, "b/s"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 3);
103103
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getRps())), true, "pkt/s"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 4);
104-
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getRbsL1())), true, "b/s"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 5);
105-
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getRbsL2())), true, "b/s"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 6);
104+
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getRbsL2())), true, "b/s"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 5);
105+
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(round(flowStatPoint.getRbsL1())), true, "b/s"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 6);
106106
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(tp), true, "pkts"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 7);
107107
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(rp), true, "pkts"), secondHeaderWidth, true, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 8);
108108
table.add(new StatisticLabelCell(Util.getFormatted(String.valueOf(tb), true, "B"), secondHeaderWidth, false, CellType.DEFAULT_CELL, true, isStopped), rowIndex, 9);

src/main/java/com/cisco/trex/stl/gui/models/LatencyStatPoint.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.cisco.trex.stl.gui.models;
22

33
import com.cisco.trex.stateless.model.stats.LatencyStat;
4+
import com.cisco.trex.stateless.model.stats.LatencyStatErr;
5+
import com.cisco.trex.stateless.model.stats.LatencyStatLat;
6+
7+
import java.util.HashMap;
8+
import java.util.Map;
49

510

611
public class LatencyStatPoint {
@@ -19,4 +24,46 @@ public LatencyStat getLatencyStat() {
1924
public double getTime() {
2025
return time;
2126
}
27+
28+
public LatencyStatPoint subtractOffset(LatencyStatPoint offset) {
29+
LatencyStat newLatencyStat = subtractLatencyStat(this.latencyStat, offset.latencyStat);
30+
return new LatencyStatPoint(newLatencyStat, time);
31+
}
32+
33+
private LatencyStat subtractLatencyStat(LatencyStat stat1, LatencyStat statOffset) {
34+
LatencyStatErr newErr = subtractLatencyStatErr(stat1.getErr(), statOffset.getErr());
35+
LatencyStatLat newLat = subtractLatencyStatLat(stat1.getLat(), statOffset.getLat());
36+
37+
LatencyStat result = new LatencyStat();
38+
result.setErr(newErr);
39+
result.setLat(newLat);
40+
return result;
41+
}
42+
43+
private LatencyStatLat subtractLatencyStatLat(LatencyStatLat lat1, LatencyStatLat latOffset) {
44+
LatencyStatLat result = new LatencyStatLat();
45+
result.setAverage(lat1.getAverage());
46+
result.setJit(lat1.getJit());
47+
result.setLastMax(lat1.getLastMax());
48+
result.setTotalMax(lat1.getTotalMax());
49+
50+
Map<String, Long> shiftedHistogram = new HashMap<>();
51+
lat1.getHistogram().forEach((final String key, final Long value) -> {
52+
Long newvalue = value - latOffset.getHistogram().getOrDefault(key, 0L);
53+
shiftedHistogram.put(key, newvalue);
54+
});
55+
result.setHistogram(shiftedHistogram);
56+
57+
return result;
58+
}
59+
60+
private LatencyStatErr subtractLatencyStatErr(LatencyStatErr err1, LatencyStatErr errOffset) {
61+
LatencyStatErr result = new LatencyStatErr();
62+
result.setDrp(err1.getDrp() - errOffset.getDrp());
63+
result.setDup(err1.getDup() - errOffset.getDup());
64+
result.setOoo(err1.getOoo() - errOffset.getOoo());
65+
result.setSth(err1.getSth() - errOffset.getSth());
66+
result.setStl(err1.getStl() - errOffset.getStl());
67+
return result;
68+
}
2269
}

src/main/java/com/cisco/trex/stl/gui/storages/PGIDStatsStorage.java

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public interface StatsChangedListener {
2929
private final Set<Integer> stoppedPGIds = new HashSet<>();
3030
private final Map<Integer, FlowStatPoint> flowStatPointShadowMap = new HashMap<>();
3131

32-
private final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyStatPointHistoryMap = new HashMap<>();
32+
private final Map<Integer, ArrayHistory<LatencyStatPoint>> latencyHistoryByPGID = new HashMap<>();
33+
private final Map<Integer, LatencyStatPoint> latencyInitialOffsetByPGID = new HashMap<>();
3334
private final Map<Integer, Long> maxLatencyMap = new HashMap<>();
34-
private final Map<Integer, LatencyStatPoint> latencyStatPointShadowMap = new HashMap<>();
3535
private String[] histogramKeys = new String[0];
3636

3737
private Map<String, Integer> lastVerId = new HashMap<>();
@@ -55,17 +55,13 @@ public Map<Integer, FlowStatPoint> getFlowStatPointShadowMap() {
5555
}
5656

5757
public Map<Integer, ArrayHistory<LatencyStatPoint>> getLatencyStatPointHistoryMap() {
58-
return latencyStatPointHistoryMap;
58+
return latencyHistoryByPGID;
5959
}
6060

6161
public Map<Integer, Long> getMaxLatencyMap() {
6262
return maxLatencyMap;
6363
}
6464

65-
public Map<Integer, LatencyStatPoint> getLatencyStatPointShadowMap() {
66-
return latencyStatPointShadowMap;
67-
}
68-
6965
public String[] getHistogramKeys(final int size) {
7066
return Arrays.copyOfRange(histogramKeys, Math.max(0, histogramKeys.length - size), histogramKeys.length);
7167
}
@@ -161,7 +157,7 @@ private void handlePGIDStatsReceived(final WorkerStateEvent event) {
161157

162158
final Map<String, LatencyStat> latencyStatMap = receivedPGIDStats.getLatency();
163159
if (latencyStatMap != null) {
164-
processLatencyStats(receivedPGIDStats.getLatency(), verId, time);
160+
processLatencyStats(latencyStatMap, verId, time);
165161
} else {
166162
clearLatencyStats();
167163
}
@@ -241,7 +237,7 @@ private void processLatencyStats(
241237
final Map<String, Integer> verId,
242238
final double time
243239
) {
244-
final Set<Integer> unvisitedStreams = new HashSet<>(latencyStatPointHistoryMap.keySet());
240+
final Set<Integer> unvisitedStreams = new HashSet<>(latencyHistoryByPGID.keySet());
245241
final Set<String> histogramKeysSet = new HashSet<>();
246242

247243
latencyStatMap.forEach((final String pgID, final LatencyStat latencyStat) -> {
@@ -251,20 +247,23 @@ private void processLatencyStats(
251247
} catch (NumberFormatException exc) {
252248
return;
253249
}
254-
255250
unvisitedStreams.remove(intPGID);
256251

257-
final LatencyStatPoint statsFlowHistoryPoint = new LatencyStatPoint(latencyStat, time);
258-
ArrayHistory<LatencyStatPoint> history = latencyStatPointHistoryMap.get(intPGID);
252+
ArrayHistory<LatencyStatPoint> history = latencyHistoryByPGID.get(intPGID);
259253
if (history == null) {
260254
history = new ArrayHistory<>(HISTORY_SIZE);
261-
latencyStatPointHistoryMap.put(intPGID, history);
255+
latencyHistoryByPGID.put(intPGID, history);
262256
} else if (!verId.get(pgID).equals(lastVerId.get(pgID))) {
263257
history.clear();
264258
maxLatencyMap.remove(intPGID);
265-
latencyStatPointShadowMap.remove(intPGID);
259+
latencyInitialOffsetByPGID.remove(intPGID);
266260
}
267-
history.add(statsFlowHistoryPoint);
261+
262+
final LatencyStatPoint latencyStatPoint = new LatencyStatPoint(latencyStat, time);
263+
latencyInitialOffsetByPGID.putIfAbsent(intPGID, latencyStatPoint);
264+
265+
LatencyStatPoint shifted = latencyStatPoint.subtractOffset(latencyInitialOffsetByPGID.get(intPGID));
266+
history.add(shifted);
268267

269268
final long lastMax = latencyStat.getLat().getLastMax();
270269
final Long maxLatency = maxLatencyMap.get(intPGID);
@@ -273,37 +272,33 @@ private void processLatencyStats(
273272
}
274273

275274
histogramKeysSet.addAll(latencyStat.getLat().getHistogram().keySet());
276-
277-
latencyStatPointShadowMap.putIfAbsent(intPGID, statsFlowHistoryPoint);
278275
});
279276

280277
histogramKeys = new String[histogramKeysSet.size()];
281278
histogramKeysSet.toArray(histogramKeys);
282279
Arrays.sort(histogramKeys, PGIDStatsStorage::compareHistogramKeys);
283280

284281
unvisitedStreams.forEach((final Integer pgID) -> {
285-
latencyStatPointHistoryMap.remove(pgID);
282+
latencyHistoryByPGID.remove(pgID);
286283
maxLatencyMap.remove(pgID);
287-
latencyStatPointShadowMap.remove(pgID);
284+
latencyInitialOffsetByPGID.remove(pgID);
288285
});
289286
}
290287

291288
private void clearLatencyStats() {
292-
latencyStatPointHistoryMap.clear();
289+
latencyHistoryByPGID.clear();
293290
maxLatencyMap.clear();
294-
latencyStatPointShadowMap.clear();
291+
latencyInitialOffsetByPGID.clear();
295292
}
296293

297294
private void resetLatencyStats() {
298-
latencyStatPointShadowMap.clear();
295+
latencyInitialOffsetByPGID.clear();
299296
maxLatencyMap.clear();
300-
latencyStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<LatencyStatPoint> history) -> {
297+
latencyHistoryByPGID.forEach((final Integer pgID, final ArrayHistory<LatencyStatPoint> history) -> {
301298
if (!history.isEmpty()) {
302299
final LatencyStatPoint last = history.last();
303300
maxLatencyMap.put(pgID, last.getLatencyStat().getLat().getLastMax());
304-
latencyStatPointShadowMap.put(pgID, last);
305301
history.clear();
306-
history.add(last);
307302
}
308303
});
309304
}

0 commit comments

Comments
 (0)