use of com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketCaptureDashboardController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
final PktCaptureService pktCaptureService = new PktCaptureService();
monitorController.setPktCaptureService(pktCaptureService);
recordController.setPktCaptureService(pktCaptureService);
monitorController.setStartHandler(() -> {
startMonitorBtn.setDisable(true);
stopMonitorBtn.setDisable(false);
monitorIsActive = true;
});
monitorController.setStopHandler(() -> {
stopMonitorBtn.setDisable(true);
startMonitorBtn.setDisable(false);
monitorIsActive = false;
});
startMonitorBtn.setOnMouseClicked(event -> {
monitorController.startCapture();
});
stopMonitorBtn.setOnMouseClicked(event -> {
monitorController.stopCapture();
});
clearMonitorBtn.setOnMouseClicked(event -> monitorController.clearCapture());
startWiresharkBtn.setOnMouseClicked(event -> monitorController.startWireshark());
startRecorderBtn.setOnMouseClicked(event -> {
Dialog<AddRecordPojo> dialog = createAddRecorderDialog("Add Recorder", new AddRecorderController());
Optional<AddRecordPojo> addRecordPojo = dialog.showAndWait();
addRecordPojo.ifPresent(pojo -> {
try {
monitorController.startRecorder(pojo.rxPorts, pojo.txPorts, pojo.filter, pojo.pktLimit);
} catch (PktCaptureServiceException e) {
TrexAlertBuilder.build().setType(Alert.AlertType.ERROR).setTitle("Recorder error").setHeader("Unable to start the recorder").setContent(e.getLocalizedMessage()).getAlert().showAndWait();
}
});
});
captureTabPane.getSelectionModel().selectedItemProperty().addListener((o, oldVal, newVal) -> {
boolean isMonitorTabSelected = newVal.getText().equalsIgnoreCase("Monitor");
updateButtonBar(isMonitorTabSelected);
});
updateButtonBar(true);
}
use of com.cisco.trex.stl.gui.services.capture.PktCaptureServiceException in project trex-stateless-gui by cisco-system-traffic-generator.
the class RecordController method handleSavePkts.
public void handleSavePkts(int monitorId) {
List<CapturedPkt> capturedPkts = new ArrayList<>();
int pendingPkts = 1;
while (pendingPkts > 0) {
try {
CapturedPackets capturedPackets = pktCaptureService.fetchCapturedPkts(monitorId, 1000);
pendingPkts = capturedPackets.getPendingPkts();
capturedPkts.addAll(capturedPackets.getPkts());
} catch (PktCaptureServiceException e) {
LOG.error("Unable to fetch packets.", e);
break;
}
}
File outFile = fileChooser.showSaveDialog(getScene().getWindow());
if (outFile != null) {
try {
dumpPkts(capturedPkts, outFile.getAbsolutePath());
} catch (Exception e) {
LOG.error("Unable to dump packets.", e);
}
}
}
Aggregations