use of com.cisco.trex.stl.gui.models.Recorder 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()));
}
Aggregations