Search in sources :

Example 1 with PortStatus

use of com.exalttech.trex.ui.models.PortStatus 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)

Aggregations

ConnectionManager (com.exalttech.trex.core.ConnectionManager)1 Port (com.exalttech.trex.ui.models.Port)1 PortModel (com.exalttech.trex.ui.models.PortModel)1 PortStatus (com.exalttech.trex.ui.models.PortStatus)1 Util (com.exalttech.trex.util.Util)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1