This is the code with ClusterStorage being our code which wraps Hazelcast
.
public ClusterStorage clusterStorage() {
Config config = new Config();
String mapName = "cluster-storage";
ReplicatedMapConfig mapConfig = config.getReplicatedMapConfig(mapName);
mapConfig.setInMemoryFormat(InMemoryFormat.BINARY);
config.getGroupConfig()
.setName("name")
.setPassword("pass");
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
return new ClusterStorage(instance.getReplicatedMap(mapName));
}
When I change the map while both nodes are up the change is replicated but when I change the map on node n1 and then start the second node n2 the state from n1 is not replicated and n2 node has empty map.
I suppose this should work, right ? What might be wrong?
I managed to do it. My findings:
The problem was combination of version 3.7.1 and 3.5.5 comming from dependency management in Maven's pom.xml
. We were not aware that Spring Boot's imported dependency management also defines hazelcast
artifact with different version which in turn might have caused imcompatible libraries to be on the class path.