use of com.cisco.trex.stl.gui.models.IPv6Host in project trex-stateless-gui by cisco-system-traffic-generator.
the class PortLayerConfiguration method handleStartIPv6Scan.
private void handleStartIPv6Scan(ActionEvent actionEvent) {
LogsController.getInstance().appendText(LogType.INFO, "Start scanning IPv6 neighbor hosts.");
AsyncResponseManager.getInstance().muteLogger();
AsyncResponseManager.getInstance().suppressIncomingEvents(true);
boolean multicastEnabled = model.getMulticast();
if (!multicastEnabled) {
model.multicastProperty().setValue(true);
}
getIPv6NDService();
startScanIpv6Btn.setDisable(true);
ipv6Hosts.getItems().clear();
ipv6Hosts.setPlaceholder(new Label("Scanning in progress..."));
Task<Optional<Map<String, Ipv6Node>>> scanIpv6NeighborsTask = new Task<Optional<Map<String, Ipv6Node>>>() {
@Override
public Optional<Map<String, Ipv6Node>> call() {
try {
return Optional.of(iPv6NDService.scan(model.getIndex(), 10, null, null));
} catch (ServiceModeRequiredException e) {
AsyncResponseManager.getInstance().unmuteLogger();
AsyncResponseManager.getInstance().suppressIncomingEvents(false);
Platform.runLater(() -> {
ipv6Hosts.setPlaceholder(ipv6HostsDefaultPlaceholder);
LogsController.getInstance().appendText(LogType.ERROR, "Service mode is not enabled for port: " + model.getIndex() + ". Enable Service Mode in Control tab.");
});
}
return Optional.empty();
}
};
scanIpv6NeighborsTask.setOnSucceeded(e -> {
AsyncResponseManager.getInstance().unmuteLogger();
AsyncResponseManager.getInstance().suppressIncomingEvents(false);
startScanIpv6Btn.setDisable(false);
Optional<Map<String, Ipv6Node>> result = scanIpv6NeighborsTask.getValue();
result.ifPresent((hosts) -> {
ipv6Hosts.getItems().addAll(hosts.entrySet().stream().map(entry -> new IPv6Host(entry.getValue().getMac(), entry.getValue().getIp())).collect(Collectors.toList()));
if (hosts.isEmpty()) {
ipv6Hosts.setPlaceholder(ipv6HostsNotFoundPlaceholder);
}
LogsController.getInstance().appendText(LogType.INFO, "Found " + hosts.size() + " nodes.");
LogsController.getInstance().appendText(LogType.INFO, "Scanning complete.");
});
if (!multicastEnabled) {
model.multicastProperty().setValue(false);
}
});
executorService.submit(scanIpv6NeighborsTask);
}
Aggregations