Search in sources :

Example 6 with ArrayHistory

use of com.exalttech.trex.util.ArrayHistory 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++;
        }
    }
}
Also used : ArrayHistory(com.exalttech.trex.util.ArrayHistory) HeaderCell(com.exalttech.trex.ui.views.statistics.cells.HeaderCell) StatisticLabelCell(com.exalttech.trex.ui.views.statistics.cells.StatisticLabelCell) FlowStatPoint(com.exalttech.trex.ui.models.stats.FlowStatPoint) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) FlowStatPoint(com.exalttech.trex.ui.models.stats.FlowStatPoint)

Example 7 with ArrayHistory

use of com.exalttech.trex.util.ArrayHistory 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);
}
Also used : ArrayHistory(com.exalttech.trex.util.ArrayHistory) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) StatsStorage(com.exalttech.trex.ui.views.storages.StatsStorage) LinkedList(java.util.LinkedList) PGIDStatsStorage(com.exalttech.trex.ui.views.storages.PGIDStatsStorage) XYChart(javafx.scene.chart.XYChart) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint)

Example 8 with ArrayHistory

use of com.exalttech.trex.util.ArrayHistory in project trex-stateless-gui by cisco-system-traffic-generator.

the class PGIDStatsStorage method resetLatencyStats.

private void resetLatencyStats() {
    synchronized (latencyLock) {
        latencyStatPointShadowMap.clear();
        latencyStatPointHistoryMap.forEach((final Integer pgID, final ArrayHistory<LatencyStatPoint> history) -> {
            if (!history.isEmpty()) {
                final LatencyStatPoint last = history.last();
                latencyStatPointShadowMap.put(pgID, history.last());
                history.clear();
                history.add(last);
            }
        });
    }
}
Also used : ArrayHistory(com.exalttech.trex.util.ArrayHistory) LatencyStatPoint(com.exalttech.trex.ui.models.stats.LatencyStatPoint)

Aggregations

ArrayHistory (com.exalttech.trex.util.ArrayHistory)8 PGIDStatsStorage (com.exalttech.trex.ui.views.storages.PGIDStatsStorage)6 FlowStatPoint (com.exalttech.trex.ui.models.stats.FlowStatPoint)5 LatencyStatPoint (com.exalttech.trex.ui.models.stats.LatencyStatPoint)5 HeaderCell (com.exalttech.trex.ui.views.statistics.cells.HeaderCell)3 StatisticLabelCell (com.exalttech.trex.ui.views.statistics.cells.StatisticLabelCell)3 StatsStorage (com.exalttech.trex.ui.views.storages.StatsStorage)3 LinkedList (java.util.LinkedList)3 XYChart (javafx.scene.chart.XYChart)3 LatencyStat (com.cisco.trex.stateless.model.stats.LatencyStat)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 LatencyStatErr (com.cisco.trex.stateless.model.stats.LatencyStatErr)1 LatencyStatLat (com.cisco.trex.stateless.model.stats.LatencyStatLat)1 Formatter (com.exalttech.trex.util.Formatter)1