hazelcast:禁用集群

t5fffqht  于 2021-06-26  发布在  Java
关注(0)|答案(1)|浏览(488)

我在java项目中使用hazelcast,但是我只使用一个节点,不需要任何集群。当几个dev示例发现彼此并形成一个集群时,这实际上给我们带来了问题。
有没有办法在xml配置中完全禁用集群?
编辑:我使用的是hazelcast 3.8.4,我尝试过禁用多播,但看起来它仍然处于启用状态:

<hz:hazelcast id="hazelcast">
        <hz:config>
            <hz:group name="dev" password="password"/>
            <hz:properties>
                <hz:property name="hazelcast.logging.type">slf4j</hz:property>
            </hz:properties>
            <hz:network port="5701" port-auto-increment="true">
                <hz:join>
                    <hz:multicast enabled="false"/>
                </hz:join>
            </hz:network>
            <hz:topic name="topicStuff"/>
        </hz:config>
    </hz:hazelcast>

日志:

12:54:51,273 INFO  [com.hazelcast.hibernate.HazelcastLocalCacheRegionFactory] - Starting up HazelcastLocalCacheRegionFactory
12:54:51,284 INFO  [com.hazelcast.config.XmlConfigLocator] - Loading 'hazelcast-default.xml' from classpath.
12:54:51,398 INFO  [com.hazelcast.instance.DefaultAddressPicker] - [LOCAL] [dev] [3.8.4] Prefer IPv4 stack is true.
12:54:51,409 INFO  [com.hazelcast.instance.DefaultAddressPicker] - [LOCAL] [dev] [3.8.4] Picked [10.212.134.200]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true 
12:54:51,426 INFO  [com.hazelcast.system] - [10.212.134.200]:5701 [dev] [3.8.4] Hazelcast 3.8.4 (20170809 - 297a77e) starting at [10.212.134.200]:5701
12:54:51,426 INFO  [com.hazelcast.system] - [10.212.134.200]:5701 [dev] [3.8.4] Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
12:54:51,426 INFO  [com.hazelcast.system] - [10.212.134.200]:5701 [dev] [3.8.4] Configured Hazelcast Serialization version : 1
12:54:51,648 INFO  [com.hazelcast.spi.impl.operationservice.impl.BackpressureRegulator] - [10.212.134.200]:5701 [dev] [3.8.4] Backpressure is disabled
12:54:52,088 INFO  [com.hazelcast.instance.Node] - [10.212.134.200]:5701 [dev] [3.8.4] Creating MulticastJoiner
12:54:52,219 INFO  [com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl] - [10.212.134.200]:5701 [dev] [3.8.4] Starting 12 partition threads 
12:54:52,220 INFO  [com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl] - [10.212.134.200]:5701 [dev] [3.8.4] Starting 7 generic threads (1 dedicated for priority tasks)
12:54:52,241 INFO  [com.hazelcast.core.LifecycleService] - [10.212.134.200]:5701 [dev] [3.8.4] [10.212.134.200]:5701 is STARTING
12:54:54,286 INFO  [com.hazelcast.system] - [10.212.134.200]:5701 [dev] [3.8.4] Cluster version set to 3.8
12:54:54,289 INFO  [com.hazelcast.internal.cluster.impl.MulticastJoiner] - [10.212.134.200]:5701 [dev] [3.8.4] 

Members [1] {   Member [10.212.134.200]:5701 - 820072f4-f1ef-4a5e-9722-eb2bd038f37e this }

12:54:54,361 INFO  [com.hazelcast.core.LifecycleService] - [10.212.134.200]:5701 [dev] [3.8.4] [10.212.134.200]:5701 is STARTEDsdf
tjrkku2a

tjrkku2a1#

如果未启用任何联接方法,则hazelcast将以独立模式启动。在版本4.1之前,默认的连接方法是多播,当它被禁用时,成员将独立启动:

<network>
    <join>
        <multicast enabled="false"/>
    </join>
</network>

从而生成日志:

WARNING: [192.168.1.3]:5701 [dev] [4.0] No join method is enabled! Starting standalone.

对于版本4.1,这将成为

<network>
    <join>
        <auto-detection enabled="false"/>
    </join>
</network>

相关问题