我想请你帮忙。我遇到了客户端重新连接到HZ集群的问题,以防整个集群出现故障然后起来。
如果HZ群集至少保留一个节点,则根本没有问题。但是当所有节点都关闭时,相关的客户端永远不会重新连接。
这是我的客户端初始化代码:
public void init() {
List<String> members = (List<String>)Arrays.asList("node1,node2,node3".split(","));
ClientConfig clientConfig = new ClientConfig();
clientConfig.getGroupConfig().
setName( "dev" ).
setPassword( "dev" );
clientConfig.getNetworkConfig().
setConnectionAttemptLimit( 10 ).
setConnectionAttemptPeriod( 100 ).
setConnectionAttemptPeriod( 1000 ).
setRedoOperation(true).
setSmartRouting(true).
setAddresses(members);
hzClient = HazelcastClient.newHazelcastClient(clientConfig);
hzSessionMap = hzClient.getMap("mapsession");
}
public IMap getSessionMap() {
return hzSessionMap;
}
我将我的客户端创建为spring bean,它提供IMap对象。
重新启动整个群集后重新连接时抛出的异常是:
com.hazelcast.nio.serialization.HazelcastSerializationException:
com.hazelcast.core.HazelcastInstanceNotActiveException: Hazelcast instance is not active!
在
com.hazelcast.nio.serialization.SerializationServiceImpl.handleException(SerializationServiceImpl.java:380)〜[hazelcast-3.5.jar:3.5]
在com.hazelcast.nio.serialization.SerializationServiceImpl.toData(SerializationServiceImpl.java:235)〜[hazelcast-3.5.jar:3.5]
在
com.hazelcast.nio.serialization.SerializationServiceImpl.toData(SerializationServiceImpl.java:207)〜[hazelcast-3.5.jar:3.5]
在com.hazelcast.client.spi.ClientProxy.toData(ClientProxy.java:169)〜[hazelcast-client-3.5.jar:3.5]
在com.hazelcast.client.proxy.ClientMapProxy.put(ClientMapProxy.java:362)〜[hazelcast-client-3.5.jar:3.5]
...
问候,
约瑟夫