Reputation: 97
I am using hazelcast IMap for caching data(key,uuid).
In class App
static HazelcastInstance hzInstance;
@Autowired
private static Config config;
public static HazelcastInstance hazelcastInstanceM {
if (sharedInstance == null)
sharedInstance = Hazelcast.newHazelcastInstance(config);
return sharedInstance;
}
In another class B I get hazelcastinstance to get map CD
static {
hazelcastInstance = App.hazelcastInstanceM();
map= hazelcastInstance.getMap("CD");
}
I have two members in the cluster. The first time request is made to the service say member 1 the key1,uuid1gets saved in map. The second request when made to the service say member 2 it should add key1 if not present in map.
kmap.putIfAbsent(key1, uuid1, 4, TimeUnit.MINUTES);
Now its observed that when the second time the request is fired via member 2 key1,uuid2 gets added again in map. Ideally as expected it should not be added and hence map doesn't show distributed behavior among the cluster members
What can be the reason for map not behaving in distributed way
Upvotes: 0
Views: 298
Reputation: 969
Are you sure your Hazelcast instances are discovering each other and forming a cluster? It might be that both are running on their own. If possible please attach Hazelcast logs of both instances to the question.
Upvotes: 1