Commit ebb6ccdd authored by Matija Obreza's avatar Matija Obreza
Browse files

Resolve HZ members’ IP

parent 30f9b43f
......@@ -18,6 +18,7 @@ package org.genesys2.spring.config;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import com.hazelcast.config.Config;
......@@ -103,7 +104,22 @@ public class HazelcastConfigCacher extends HazelcastConfig {
TcpIpConfig tcpIpConfig = join.getTcpIpConfig();
tcpIpConfig.setEnabled(true);
tcpIpConfig.setConnectionTimeoutSeconds(20);
tcpIpConfig.setMembers(hazelcastMembers);
List<String> hzMembers=new ArrayList<>();
for (String hazelcastMember : hazelcastMembers) {
String trimmed = hazelcastMember.trim();
if (StringUtils.isNotBlank(trimmed)) {
System.out.println("Hazelcast: Adding member " + trimmed);
try {
InetAddress ipAddress = InetAddress.getByName(trimmed);
LOG.warn("Interface ip={} ={}", ipAddress, ipAddress.isSiteLocalAddress());
hzMembers.add(ipAddress.getHostAddress());
} catch (UnknownHostException e) {
LOG.warn("Could not resolve {}, error {}", trimmed, e.getMessage());
hzMembers.add(trimmed);
}
}
}
tcpIpConfig.setMembers(hzMembers);
}
configureHazelcast(cfg);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment