sanpwc commented on a change in pull request #8351:
URL: https://github.com/apache/ignite/pull/8351#discussion_r506352880



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/visor/baseline/VisorBaselineTaskResult.java
##########
@@ -75,14 +86,90 @@ public VisorBaselineTaskResult() {
         Map<String, VisorBaselineNode> map = new TreeMap<>();
 
         for (BaselineNode node : nodes) {
-            VisorBaselineNode dto = new VisorBaselineNode(node);
+            VisorBaselineNode dto = new VisorBaselineNode(node, 
Collections.emptyList());
 
             map.put(dto.getConsistentId(), dto);
         }
 
         return map;
     }
 
+    /**
+     * @param nodes Nodes to process.
+     * @return Map of DTO objects, with resolved ip->hostname pairs.
+     */
+    private static Map<String, VisorBaselineNode> 
toMapWithResolvedAddresses(Collection<? extends BaselineNode> nodes) {
+        if (F.isEmpty(nodes))
+            return null;
+
+        Map<String, VisorBaselineNode> map = new TreeMap<>();
+
+        for (BaselineNode node : nodes) {
+            Collection<VisorBaselineNode.ResolvedAddresses> addrs = new 
ArrayList<>();
+
+            if (node instanceof IgniteClusterNode) {
+                for (InetAddress inetAddress: 
resolveInetAddresses((ClusterNode)node))
+                    addrs.add(new 
VisorBaselineNode.ResolvedAddresses(inetAddress));
+            }
+
+            VisorBaselineNode dto = new VisorBaselineNode(node, addrs);
+
+            map.put(dto.getConsistentId(), dto);
+        }
+
+        return map;
+    }
+
+    /**
+     * @return Resolved inet addresses of node
+     */
+    private static Collection<InetAddress> resolveInetAddresses(ClusterNode 
node) {
+        Set<InetAddress> res = new HashSet<>(node.addresses().size());
+
+        Iterator<String> hostNamesIt = node.hostNames().iterator();
+
+        for (String addr : node.addresses()) {
+            String hostName = hostNamesIt.hasNext() ? hostNamesIt.next() : 
null;
+
+            InetAddress inetAddr = null;
+
+            if (!F.isEmpty(hostName)) {
+                try {
+                    if 
(IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_TEST_ENV)) {
+                        // 127.0.0.1.hostname will be resolved to 127.0.0.1
+                        if (hostName.endsWith(".hostname")) {
+                            String ipStr = hostName.substring(0, 
hostName.length() - ".hostname".length());
+                            inetAddr = InetAddress.getByAddress(hostName, 
InetAddress.getByName(ipStr).getAddress());
+                        }
+                        else
+                            throw new UnknownHostException(hostName);

Review comment:
       What's the point of throwing UnknownHostException and caching it within 
few lines?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to