Search in sources :

Example 6 with Port

use of com.exalttech.trex.ui.models.Port in project trex-stateless-gui by cisco-system-traffic-generator.

the class RPCMethods method acquireAllServerPorts.

/**
     *
     * @param portList
     * @param force
     */
public void acquireAllServerPorts(List<Port> portList, Boolean force) {
    try {
        connectionHandler.clear();
        for (Port port : portList) {
            String handler = this.acquireServerPort(port.getIndex(), force);
            connectionHandler.put(port.getIndex(), handler);
        }
    } catch (PortAcquireException ex) {
        LOG.error("------" + ex.getMessage());
    }
}
Also used : PortAcquireException(com.exalttech.trex.remote.exceptions.PortAcquireException) Port(com.exalttech.trex.ui.models.Port)

Example 7 with Port

use of com.exalttech.trex.ui.models.Port in project trex-stateless-gui by cisco-system-traffic-generator.

the class PortsManager method updatedPorts.

public void updatedPorts(List<Integer> portIndexes) {
    List<Port> list = portList.stream().filter(port -> portIndexes.contains(port.getIndex())).collect(Collectors.toList());
    try {
        String response = ConnectionManager.getInstance().sendPortStatusRequest(list);
        if (response == null) {
            return;
        }
        List<PortStatus> portStatusList = mapper.readValue(response, mapper.getTypeFactory().constructCollectionType(List.class, PortStatus.class));
        for (Port port : list) {
            PortStatus.PortStatusResult portStatus = portStatusList.get(list.indexOf(port)).getResult();
            port.setOwner(portStatus.getOwner());
            port.setStatus(portStatus.getState());
            port.setAttr(portStatus.getAttr());
            port.setRx_info(portStatus.getRx_info());
            port.setService(portStatus.getService());
            port.linkProperty().set(portStatus.getAttr().getLink().getUp());
        }
        portManagerHandler.onPortListUpdated(true);
    } catch (Exception ex) {
        logger.error("Error reading port status", ex);
    }
}
Also used : Logger(org.apache.log4j.Logger) java.util(java.util) PortModel(com.exalttech.trex.ui.models.PortModel) ConnectionManager(com.exalttech.trex.core.ConnectionManager) PortStatus(com.exalttech.trex.ui.models.PortStatus) Util(com.exalttech.trex.util.Util) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Collectors(java.util.stream.Collectors) Port(com.exalttech.trex.ui.models.Port) Port(com.exalttech.trex.ui.models.Port) PortStatus(com.exalttech.trex.ui.models.PortStatus)

Example 8 with Port

use of com.exalttech.trex.ui.models.Port in project trex-stateless-gui by cisco-system-traffic-generator.

the class StatsTableGenerator method getPortStatTable.

/**
     * Build port stats table
     *
     * @param cached
     * @param portIndex
     * @param columnWidth
     * @param isMultiPort
     * @param visiblePorts
     * @return
     */
public GridPane getPortStatTable(Map<String, String> cached, int portIndex, boolean isMultiPort, double columnWidth, Set<Integer> visiblePorts) {
    this.currentStatsList = StatsLoader.getInstance().getLoadedStatsList();
    this.prevStatsList = StatsLoader.getInstance().getPreviousStatsList();
    this.prevTotalValues = totalValues;
    this.cachedStatsList = cached;
    int startPortIndex = portIndex;
    int endPortIndex = portIndex + 1;
    if (isMultiPort) {
        startPortIndex = 0;
        endPortIndex = portIndex;
    }
    rowIndex = 0;
    totalValues = new HashMap<>();
    statTable.getChildren().clear();
    Util.optimizeMemory();
    addCounterColumn(StatisticConstantsKeys.PORT_STATS_ROW_NAME);
    double l1_total = 0;
    int columnIndex = 1;
    for (int i = startPortIndex; i < endPortIndex; i++) {
        rowIndex = 0;
        odd = true;
        Port port = PortsManager.getInstance().getPortList().get(i);
        if (visiblePorts == null || visiblePorts.contains(port.getIndex())) {
            // add owner and port status
            addPortInfoCells(port, columnWidth, columnIndex);
            StatisticRow row_m_tx_bps = null;
            StatisticRow row_m_tx_pps = null;
            StatisticRow row_m_tx_bps_l1 = null;
            int rowIndex_row_m_tx_bps_l1 = -1;
            boolean odd_l1 = odd;
            String stat_value_m_tx_bps = "222.22";
            String stat_value_m_tx_pps = "333.33";
            for (StatisticRow key : StatisticConstantsKeys.PORT_STATS_KEY) {
                keyBuffer.setLength(0);
                keyBuffer.append(key.getKey()).append("-").append(i);
                if (keyBuffer.toString().startsWith("m_total_tx_bps_l1-" + i)) {
                    row_m_tx_bps_l1 = key;
                    rowIndex_row_m_tx_bps_l1 = rowIndex++;
                    odd_l1 = odd;
                    odd = !odd;
                    continue;
                }
                StatisticCell cell = getGridCell(key, columnWidth, keyBuffer.toString());
                String stat_value = getStatValue(key, i);
                cell.updateItem(getPrevValue(key, i, false), stat_value);
                statTable.getChildren().remove(cell);
                statTable.add((Node) cell, columnIndex, rowIndex++);
                if (keyBuffer.toString().startsWith("m_total_tx_bps-" + i)) {
                    row_m_tx_bps = key;
                    stat_value_m_tx_bps = new String(stat_value);
                } else if (keyBuffer.toString().startsWith("m_total_tx_pps-" + i)) {
                    row_m_tx_pps = key;
                    stat_value_m_tx_pps = new String(stat_value);
                }
            }
            if (row_m_tx_bps_l1 != null && row_m_tx_bps != null && row_m_tx_pps != null) {
                // l1 <-- m_tx_bps + m_tx_pps * 20.0 * 8.0
                double m_tx_bps = Double.parseDouble(stat_value_m_tx_bps);
                double m_tx_pps = Double.parseDouble(stat_value_m_tx_pps);
                double m_tx_bps_l1 = m_tx_bps + m_tx_pps * 20.0 * 8.0;
                odd = odd_l1;
                rowIndex = rowIndex_row_m_tx_bps_l1;
                l1_total += m_tx_bps_l1;
                keyBuffer.setLength(0);
                keyBuffer.append(row_m_tx_bps_l1.getKey()).append("-").append(i);
                StatisticCell cell = getGridCell(row_m_tx_bps_l1, columnWidth, keyBuffer.toString());
                cell.updateItem("" + m_tx_bps_l1, "" + m_tx_bps_l1);
                statTable.getChildren().remove(cell);
                statTable.add((Node) cell, columnIndex, rowIndex_row_m_tx_bps_l1);
            }
            columnIndex++;
        }
    }
    if (isMultiPort) {
        addTotalColumn(columnWidth, columnIndex, l1_total);
    }
    return statTable;
}
Also used : Port(com.exalttech.trex.ui.models.Port)

Example 9 with Port

use of com.exalttech.trex.ui.models.Port in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method enableUpdateBtn.

/**
     * Enable update/Stop button button
     */
private void enableUpdateBtn(boolean enableCounter, boolean enableUpdate) {
    Port currentPort = portManager.getPortList().get(lastLoadedPortPtofileIndex);
    boolean enableUpdateBtn = enableUpdate && (reAssign || PortState.getPortStatus(currentPort.getStatus()) == PortState.TX && isContinuousStream());
    boolean startCounting = enableCounter && (reAssign || PortState.getPortStatus(currentPort.getStatus()) == PortState.TX && isContinuousStream());
    stopUpdateBtn.setVisible(startCounting);
    countdownValue.setVisible(startCounting);
    updateBtn.setDisable(!enableUpdateBtn);
    if (startCounting) {
        countdownService.restart();
    } else if (countdownService.isRunning()) {
        countdownService.cancel();
        countdownValue.setText("");
    }
}
Also used : Port(com.exalttech.trex.ui.models.Port)

Example 10 with Port

use of com.exalttech.trex.ui.models.Port in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method enableDisableStartStopAllBtn.

/**
     * Enable/Disable start/stop all button according to port state
     */
private void enableDisableStartStopAllBtn() {
    boolean disableStartStopAll = true;
    for (Port port : portManager.getPortList()) {
        if (PortState.getPortStatus(port.getStatus()) != PortState.IDLE) {
            disableStartStopAll = false;
            break;
        }
    }
    startAllStream.setDisable(disableStartStopAll);
    stopAllStream.setDisable(disableStartStopAll);
}
Also used : Port(com.exalttech.trex.ui.models.Port)

Aggregations

Port (com.exalttech.trex.ui.models.Port)10 PortModel (com.exalttech.trex.ui.models.PortModel)3 ConnectionManager (com.exalttech.trex.core.ConnectionManager)2 TrexEvent (com.exalttech.trex.core.TrexEvent)2 PortAcquireException (com.exalttech.trex.remote.exceptions.PortAcquireException)2 PortState (com.exalttech.trex.ui.PortState)2 AssignedProfile (com.exalttech.trex.ui.views.models.AssignedProfile)2 StatsTableGenerator (com.exalttech.trex.ui.views.statistics.StatsTableGenerator)2 EventBus (com.google.common.eventbus.EventBus)2 Image (javafx.scene.image.Image)2 TRexClient (com.cisco.trex.stateless.TRexClient)1 TrexApp (com.exalttech.trex.application.TrexApp)1 AsyncResponseManager (com.exalttech.trex.core.AsyncResponseManager)1 RPCMethods (com.exalttech.trex.core.RPCMethods)1 IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)1 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)1 TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)1 RPCRequest (com.exalttech.trex.remote.models.common.RPCRequest)1 Profile (com.exalttech.trex.remote.models.profiles.Profile)1 StreamValidation (com.exalttech.trex.remote.models.validate.StreamValidation)1