Hazelcast MapStoreConfig ignored

I use a map repository to store my distributed forest stone map in a database.

In my test case, I run three instances of the Caribbean calendar, each of which is configured the same way:

Config cfg = new Config();
cfg.setInstanceName("name");
hazelcast = Hazelcast.newHazelcastInstance(cfg);    
MapConfig mapConfig = new MapConfig("myMapName");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setClassName(MyMapStore.class.getName());
mapStoreConfig.setWriteDelaySeconds(0);
mapStoreConfig.setEnabled(true);
mapConfig.setMapStoreConfig(mapStoreConfig);
mapConfig.setBackupCount(2);
hazelcast.getConfig().addMapConfig(mapConfig);
IMap myMap = hazelcast.getMap("myMapName");

However, when I add values ​​to the map, only the first member of the cluster is written to the database, MapStoreConfig is installed only by default node. But, if I change the code to the following, it works:

Config cfg = new Config();
cfg.setInstanceName("name");
MapConfig mapConfig = new MapConfig("myMapName");
MapStoreConfig mapStoreConfig = new MapStoreConfig();
mapStoreConfig.setClassName(MyMapStore.class.getName());
mapStoreConfig.setWriteDelaySeconds(0);
mapStoreConfig.setEnabled(true);
mapConfig.setMapStoreConfig(mapStoreConfig);
mapConfig.setBackupCount(2);
cfg.addMapConfig(mapConfig);
hazelcast = Hazelcast.newHazelcastInstance(cfg);
IMap myMap = hazelcast.getMap("myMapName");

It looks like the string is being hazelcast.getConfig().addMapConfig(mapConfig);ignored. Tested with hazelcast v3.1.5.

+4
source share

Source: https://habr.com/ru/post/1523881/


All Articles