initial.min.cluster.size的行为

Hazelcast是否始终阻止以防未到达initial.min.cluster.size?如果不是,在哪种情况下不是?initial.min.cluster.size的行为


详情: 我用下面的代码来初始化hazelcast:

Config cfg = new Config(); 

cfg.setProperty("hazelcast.initial.min.cluster.size",Integer.

toString(minimumInitialMembersInHazelCluster)); //2 in this case

cfg.getGroupConfig().setName(clusterName);

NetworkConfig network = cfg.getNetworkConfig();

JoinConfig join = network.getJoin();

join.getMulticastConfig().setEnabled(false);

join.getTcpIpConfig().addMember("192.168.0.1").addMember("192.168.0.2").

addMember("192.168.0.3").addMember("192.168.0.4").

addMember("192.168.0.5").addMember("192.168.0.6").

addMember("192.168.0.7").setRequiredMember(null).setEnabled(true);

network.getInterfaces().setEnabled(true).addInterface("192.168.0.*");

join.getMulticastConfig().setMulticastTimeoutSeconds(MCSOCK_TIMEOUT/100);

hazelInst = Hazelcast.newHazelcastInstance(cfg);

distrDischargedTTGs = hazelInst.getList(clusterName);

,并得到日志消息像

调试:从Hazelcluster开始淡褐色pullExternal 1组的成员。

这是否意味着还有其他成员已经加入并离开了?它看起来不像其他实例的日志文件。因此,我想知道是否存在那些hazelInst = Hazelcast.newHazelcastInstance(cfg);不会阻止的情况,即使它是榛树群集中的唯一实例。

回答:

newHazelcastInstance阻塞,直到群集具有所需数量的成员。

查看下列它是如何实现的代码:

private static void awaitMinimalClusterSize(HazelcastInstanceImpl hazelcastInstance, Node node, boolean firstMember) 

throws InterruptedException {

final int initialMinClusterSize = node.groupProperties.INITIAL_MIN_CLUSTER_SIZE.getInteger();

while (node.getClusterService().getSize() < initialMinClusterSize) {

try {

hazelcastInstance.logger.info("HazelcastInstance waiting for cluster size of " + initialMinClusterSize);

//noinspection BusyWait

Thread.sleep(TimeUnit.SECONDS.toMillis(1));

} catch (InterruptedException ignored) {

}

}

if (initialMinClusterSize > 1) {

if (firstMember) {

node.partitionService.firstArrangement();

} else {

Thread.sleep(TimeUnit.SECONDS.toMillis(3));

}

hazelcastInstance.logger.info("HazelcastInstance starting after waiting for cluster size of "

+ initialMinClusterSize);

}

}

如果你设置调试日志记录,那么也许你可以看得更清楚发生了什么。会员加入和离开应已在信息下可见。

以上是 initial.min.cluster.size的行为 的全部内容, 来源链接: utcz.com/qa/263066.html

回到顶部