Search in sources :

Example 1 with CaptureInfo

use of com.cisco.trex.stateless.model.capture.CaptureInfo in project trex-stateless-gui by cisco-system-traffic-generator.

the class RecordController method handleOnRecorderReceived.

private void handleOnRecorderReceived(WorkerStateEvent workerStateEvent) {
    List<CaptureInfo> monitors = recorderService.getValue();
    ObservableList<Recorder> currentRecorders = activeRecorders.getItems();
    monitors.stream().filter(monitor -> {
        final String mode = monitor.getMode();
        if (mode == null)
            return false;
        final boolean isModeSuitable = mode.equalsIgnoreCase("fixed") || mode.equalsIgnoreCase("cyclic");
        return isModeSuitable && monitor.getId() != pktCaptureService.getCurrentActiveMonitorId();
    }).map(this::captureInfo2Recorder).collect(toList()).forEach(newRecorder -> {
        Optional<Recorder> existed = currentRecorders.stream().filter(recorder -> recorder.getId() == newRecorder.getId()).findFirst();
        if (existed.isPresent()) {
            Recorder recorder = existed.get();
            recorder.setBytes(newRecorder.getBytes());
            recorder.setPackets(newRecorder.getPackets());
            recorder.setStatus(newRecorder.getStatus());
        } else {
            currentRecorders.add(newRecorder);
        }
    });
    currentRecorders.removeIf(recorder -> !monitors.stream().anyMatch(newRecorder -> newRecorder.getId() == recorder.getId()));
}
Also used : java.util(java.util) javafx.scene.control(javafx.scene.control) PktCaptureServiceException(com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException) CaptureInfo(com.cisco.trex.stateless.model.capture.CaptureInfo) Logger(org.apache.log4j.Logger) Task(javafx.concurrent.Task) PortsManager(com.exalttech.trex.ui.PortsManager) Insets(javafx.geometry.Insets) PortModel(com.exalttech.trex.ui.models.PortModel) CapturedPackets(com.cisco.trex.stateless.model.capture.CapturedPackets) Initialization(com.exalttech.trex.util.Initialization) DataLinkType(org.pcap4j.packet.namednumber.DataLinkType) HBox(javafx.scene.layout.HBox) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) ScheduledService(javafx.concurrent.ScheduledService) org.pcap4j.core(org.pcap4j.core) PktCaptureService(com.cisco.trex.stl.gui.services.capture.PktCaptureService) EthernetPacket(org.pcap4j.packet.EthernetPacket) CapturedPkt(com.cisco.trex.stateless.model.capture.CapturedPkt) IllegalRawDataException(org.pcap4j.packet.IllegalRawDataException) Collectors(java.util.stream.Collectors) TrexAlertBuilder(com.exalttech.trex.ui.util.TrexAlertBuilder) File(java.io.File) Collectors.joining(java.util.stream.Collectors.joining) FXML(javafx.fxml.FXML) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) Duration(javafx.util.Duration) Collectors.toList(java.util.stream.Collectors.toList) ImageView(javafx.scene.image.ImageView) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) WorkerStateEvent(javafx.concurrent.WorkerStateEvent) Recorder(com.cisco.trex.stl.gui.models.Recorder) Recorder(com.cisco.trex.stl.gui.models.Recorder) CaptureInfo(com.cisco.trex.stateless.model.capture.CaptureInfo)

Aggregations

CaptureInfo (com.cisco.trex.stateless.model.capture.CaptureInfo)1 CapturedPackets (com.cisco.trex.stateless.model.capture.CapturedPackets)1 CapturedPkt (com.cisco.trex.stateless.model.capture.CapturedPkt)1 Recorder (com.cisco.trex.stl.gui.models.Recorder)1 PktCaptureService (com.cisco.trex.stl.gui.services.capture.PktCaptureService)1 PktCaptureServiceException (com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException)1 PortsManager (com.exalttech.trex.ui.PortsManager)1 PortModel (com.exalttech.trex.ui.models.PortModel)1 TrexAlertBuilder (com.exalttech.trex.ui.util.TrexAlertBuilder)1 Initialization (com.exalttech.trex.util.Initialization)1 File (java.io.File)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Collectors.joining (java.util.stream.Collectors.joining)1 Collectors.toList (java.util.stream.Collectors.toList)1 ObservableList (javafx.collections.ObservableList)1 ScheduledService (javafx.concurrent.ScheduledService)1 Task (javafx.concurrent.Task)1 WorkerStateEvent (javafx.concurrent.WorkerStateEvent)1 ActionEvent (javafx.event.ActionEvent)1