TCP-IP cluster discovery issue

48 views
Skip to first unread message

Abdülhakim Ünlü

unread,
Feb 13, 2024, 9:19:36 AMFeb 13
to Hazelcast
Hi,

In my local tests with tcp-ip discovery, I see that hazelcast instances only try first 3 ports. If the instance cannot join due to incorrect cluster name, it does not try upper ports. Is there a way to increase this 3 port limit ?

Here is a simple test code:

private Config getConfig(String instanceName, String clusterName) {
Config cfg = new Config();
cfg.setClusterName(clusterName);
cfg.setInstanceName(instanceName);
cfg.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
cfg.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
TcpIpConfig tcpIpConfig = cfg.getNetworkConfig().getJoin().getTcpIpConfig();
tcpIpConfig.setEnabled(true).addMember("127.0.0.1");
return cfg;
}

@Test
public void testHA2() {
List<HazelcastInstance> hzList = new ArrayList<>();

HazelcastInstance hazelcastInstance1 = Hazelcast.newHazelcastInstance(getConfig("instance_1", "cluster_a"));
hzList.add(hazelcastInstance1);
HazelcastInstance hazelcastInstance2 = Hazelcast.newHazelcastInstance(getConfig("instance_2", "cluster_a"));
hzList.add(hazelcastInstance2);
HazelcastInstance hazelcastInstance3 = Hazelcast.newHazelcastInstance(getConfig("instance_3", "cluster_a"));
hzList.add(hazelcastInstance3);
HazelcastInstance hazelcastInstance4 = Hazelcast.newHazelcastInstance(getConfig("instance_4", "cluster_b"));
hzList.add(hazelcastInstance4);
HazelcastInstance hazelcastInstance7 = Hazelcast.newHazelcastInstance(getConfig("instance_5", "cluster_b"));
hzList.add(hazelcastInstance7);
try {
Thread.sleep(1000);
for (HazelcastInstance hz : hzList) {
System.out.println("hz = " + hz + ", uuid = " + hz.getLocalEndpoint().getUuid());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}

When I run this test locally with hz version 5.1.7, I get following logs. As you can see, members of cluster-b never pair with each other. Because instance-5 (port 5705) never tries ports above 5703.

INFO: [127.0.0.1]:5705 [cluster_b] [5.1.7] [127.0.0.1]:5705 is STARTING
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.server.tcp.TcpServerConnection
INFO: [127.0.0.1]:5703 [cluster_a] [5.1.7] Initialized new cluster connection between /127.0.0.1:5703 and /127.0.0.1:57019
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.server.tcp.TcpServerConnection
INFO: [127.0.0.1]:5701 [cluster_a] [5.1.7] Initialized new cluster connection between /127.0.0.1:5701 and /127.0.0.1:40989
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.server.tcp.TcpServerConnection
INFO: [127.0.0.1]:5705 [cluster_b] [5.1.7] Initialized new cluster connection between /127.0.0.1:40989 and /127.0.0.1:5701
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.server.tcp.TcpServerConnection
INFO: [127.0.0.1]:5702 [cluster_a] [5.1.7] Initialized new cluster connection between /127.0.0.1:5702 and /127.0.0.1:40689
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.server.tcp.TcpServerConnection
INFO: [127.0.0.1]:5705 [cluster_b] [5.1.7] Initialized new cluster connection between /127.0.0.1:57019 and /127.0.0.1:5703
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.server.tcp.TcpServerConnection
INFO: [127.0.0.1]:5705 [cluster_b] [5.1.7] Initialized new cluster connection between /127.0.0.1:40689 and /127.0.0.1:5702
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.cluster.impl.ClusterJoinManager
WARNING: [127.0.0.1]:5702 [cluster_a] [5.1.7] Received an invalid join request from [127.0.0.1]:5705, cause: members part of different cluster
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.cluster.impl.ClusterJoinManager
WARNING: [127.0.0.1]:5703 [cluster_a] [5.1.7] Received an invalid join request from [127.0.0.1]:5705, cause: members part of different cluster
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.cluster.impl.ClusterJoinManager
WARNING: [127.0.0.1]:5701 [cluster_a] [5.1.7] Received an invalid join request from [127.0.0.1]:5705, cause: members part of different cluster
Feb 13, 2024 5:12:52 PM com.hazelcast.internal.server.tcp.TcpServerConnection
INFO: [127.0.0.1]:5705 [cluster_b] [5.1.7]

Members {size:1, ver:1} [
Member [127.0.0.1]:5705 - 30249620-b586-48ce-9bc7-1b72edf81e03 this
]
Reply all
Reply to author
Forward
0 new messages