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());
}
}
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);
}
}
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;
}
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("");
}
}
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);
}
Aggregations