为什么在日志中重复此消息:
hazelcast.web.ClusteredSessionService:重试连接!!
2018-05-06 13:25:19,328 INFO c.h.i.DefaultAddressPicker [LOCAL] [dev] [3.6] Picked Address[127.0.0.1]:5703, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5703], bind any local is true
2018-05-06 13:25:29.333 INFO 9947 --- [.ensureInstance] c.hazelcast.web.ClusteredSessionService : Retrying the connection!!
2018-05-06 13:25:29,333 INFO c.h.w.ClusteredSessionService Retrying the connection!!
2018-05-06 13:25:29.334 INFO 9947 --- [.ensureInstance] com.hazelcast.config.XmlConfigLocator : Loading 'hazelcast-default.xml' from classpath.
2018-05-06 13:25:29,334 INFO c.h.c.XmlConfigLocator Loading 'hazelcast-default.xml' from classpath.
2018-05-06 13:25:29.342 INFO 9947 --- [.ensureInstance] c.hazelcast.web.HazelcastInstanceLoader : Creating a new HazelcastInstance for session replication
2018-05-06 13:25:29,342 INFO c.h.w.HazelcastInstanceLoader Creating a new HazelcastInstance for session replication
2018-05-06 13:25:29.343 INFO 9947 --- [.ensureInstance] c.h.instance.DefaultAddressPicker : [LOCAL] [dev] [3.6] Picked Address[127.0.0.1]:5703, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5703], bind any local is true
hazelcast.xml
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
<management-center enabled="true">http://localhost:8080/mancenter-3.3/</management-center>
<network>
<port>5080</port>
<join>
<multicast enabled="false"/>
<tcp-ip enabled="true">
<member>192.168.1.3</member>
<member>192.168.1.15</member>
</tcp-ip>
</join>
</network>
Hazelcast cacheConfiguration,HazelcastInstance方法:
Config config = new ClasspathXmlConfig(String.format(Constants.HAZEL_XML_CONF_FILE, Constants.SPRING_PROFILE_DEVELOPMENT));
GroupConfig groupConfig = config.getGroupConfig();
groupConfig.setName(env.getProperty("cache.group.name", String.class, "appName"));
groupConfig.setPassword(env.getProperty("cache.group.password", String.class, "appName-password"));
config.setGroupConfig(groupConfig);
//TODO remove these lines and read from hazelcast-dev.xml
config.getNetworkConfig().setPort(Integer.parseInt(env.getProperty("hazelcast.port")));
config.setProperty("hazelcast.socket.bind.any", "false");
config.setProperty("hazelcast.socket.server.bind.any", "false");
config.setProperty("hazelcast.socket.client.bind.any", "false");
config.setProperty("hazelcast.socket.client.bind", "false");
config.setInstanceName(String.format("%s-%s", SABADBAN, Constants.SPRING_PROFILE_DEVELOPMENT));
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
return HazelcastInstanceFactory.newHazelcastInstance(config);
答案 0 :(得分:0)
删除hazelcast.xml 更改Hazelcast cacheConfiguration,HazelcastInstance方法:
@Bean
@PostConstruct
public HazelcastInstance hazelcastInstance() {
Config config = new Config();
config.setInstanceName(String.format("%s-%s", BROKER_PRO, env.getProperty("spring.profiles.active", String.class, "default")));
config.getGroupConfig().setName(env.getProperty("cache.hazelcast.group.name", String.class, "appName"));
config.getGroupConfig().setPassword(env.getProperty("cache.hazelcast.group.password", String.class, "appName-password"));
config.getNetworkConfig().setPortAutoIncrement(env.getProperty("cache.hazelcast.network.portAutoIncrement", Boolean.class, false));
config.getNetworkConfig().setPortCount(env.getProperty("cache.hazelcast.network.portCount", Integer.class, 1));
config.getNetworkConfig().setPort(env.getProperty("cache.hazelcast.network.port", Integer.class, 5701));
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(env.getProperty("cache.hazelcast.network.join.multicastConfig.enable", Boolean.class, false));
TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
String[] ips = env.getProperty("cache.hazelcast.network.join.tcpIpConfig.members", String[].class, new String[]{});
for (String ip : ips) {
tcpIpConfig.addMember(ip);
}
config.getNetworkConfig().getJoin().setTcpIpConfig(tcpIpConfig);
config.getMapConfigs().put("default", initializeDefaultMapConfig());
return HazelcastInstanceFactory.newHazelcastInstance(config);
}