Last active
March 28, 2018 11:56
-
-
Save Vachok/235aa6a8ec5d96e6d89b9c299644d2bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
List<String>ipsFromDb=ipsFromDB(); | |
System.out.println(" ipsFromDb.size() = " + ipsFromDb.size()); | |
HashMap<String,String> ipsMaps = nameAndIpMap(ipsFromDb); | |
BiConsumer<String,String> consumer = (x,y)->{ | |
System.out.println("x = " + x); | |
System.out.println("y = " + y); | |
}; | |
System.out.println(ipsMaps.size()); | |
} | |
private static List<String> ipsFromDB() {...} SIZE = 127 | |
@Contract(pure = true) | |
private static HashMap<String,String> nameAndIpMap(List<String> enterIps){ | |
Thread.currentThread().setName("NamesResolver.nameAndIpMap"); | |
System.out.println("NamesResolver.nameAndIpMap"); | |
HashMap<String,String> nameAndIpMap = new HashMap<>(); | |
System.out.println(enterIps.size()); | |
try { | |
for (String enterIp:enterIps) { | |
InetAddress dnsAddr = Address.getByAddress(enterIp); | |
String dnsName = Address.getHostName(dnsAddr); | |
InetAddress inetAddress = InetAddress.getByName(dnsName); | |
System.out.println(" enterIp, dnsName = " + enterIp+ ", "+dnsName); | |
Thread.sleep(1000); | |
nameAndIpMap.put(enterIp.toString(), dnsName.toString()); | |
} | |
} catch (UnknownHostException ignore) {} catch (InterruptedException e) { | |
new MySwing().infoTrace(NamesResolver.class.getSimpleName() + "|" + e.getMessage(), e.getStackTrace()); | |
logger.warning("e.getMessage() & Cause() = " + e.getMessage() + " & " + e.getCause() + "id this record is " + new Random().nextInt()); | |
e.printStackTrace(); | |
} | |
return nameAndIpMap; SIZE = 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment