try { PingSweepSummary summary = future.get(1, TimeUnit.SECONDS); if (summary.getResponses().isEmpty()) { System.out.printf("\n\nNone of the IP addresses responsed to our pings.\n"); } else { System.out.printf("\n\nIP Address\tRound-trip time\n"); summary.getResponses().forEach((address, rtt) -> { System.out.printf("%s\t%.3f ms\n", address.getHostAddress(), rtt); });
@Override public CompletableFuture<PingSweepSummary> execute() { final PingSweepRequestDTO requestDTO = new PingSweepRequestDTO(); requestDTO.setIpRanges(ranges); requestDTO.setLocation(location); requestDTO.setSystemId(systemId); requestDTO.setPacketSize(packetSize); requestDTO.setPacketsPerSecond(packetsPerSecond); return client.execute(requestDTO).thenApply(responseDTO -> { final PingSweepSummary summary = new PingSweepSummary(); final Map<InetAddress, Double> responses = new LinkedHashMap<>(); for (PingSweepResultDTO result : responseDTO.getPingSweepResult()) { responses.put(result.getAddress(), result.getRtt()); } summary.setResponses(responses); return summary; }); }
try { PingSweepSummary summary = future.get(1, TimeUnit.SECONDS); if (summary.getResponses().isEmpty()) { System.out.printf("\n\nNone of the IP addresses responsed to our pings.\n"); } else { System.out.printf("\n\nIP Address\tRound-trip time\n"); summary.getResponses().forEach((address, rtt) -> { System.out.printf("%s\t%.3f ms\n", address.getHostAddress(), rtt); });
protected static Log toNewSuspectEvents(DiscoveryJob job, PingSweepSummary summary) { final Log eventLog = new Log(); for (Entry<InetAddress, Double> entry : summary.getResponses().entrySet()) { EventBuilder eb = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, Discovery.DAEMON_NAME); eb.setInterface(entry.getKey()); eb.addParam("RTT", entry.getValue()); if (job.getForeignSource() != null) { eb.addParam(EventConstants.PARM_FOREIGN_SOURCE, job.getForeignSource()); } if (job.getLocation() != null) { eb.addParam(EventConstants.PARM_LOCATION, job.getLocation()); } eventLog.addEvent(eb.getEvent()); } return eventLog; }
protected static Log toNewSuspectEvents(DiscoveryJob job, PingSweepSummary summary) { final Log eventLog = new Log(); for (Entry<InetAddress, Double> entry : summary.getResponses().entrySet()) { EventBuilder eb = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, Discovery.DAEMON_NAME); eb.setInterface(entry.getKey()); eb.addParam("RTT", entry.getValue()); if (job.getForeignSource() != null) { eb.addParam(EventConstants.PARM_FOREIGN_SOURCE, job.getForeignSource()); } if (job.getLocation() != null) { eb.addParam(EventConstants.PARM_LOCATION, job.getLocation()); } eventLog.addEvent(eb.getEvent()); } return eventLog; }