Search code examples
hazelcast

Hazelcast localKeySet


I'm working with hazelcast version 3.10. I am trying to work with map localKeySet() and the following happens:

  • If I work without including a MapStore, localKeySet() works correctly: in each local node, KeySet () returns a reduced set of keys.

  • If I add a MapStore in the map configuration, localKeySet() would
    seem to not work correctly: in each local node, localKeySet() returns all keys in the map.

I configured the map with this function:

private MapConfig mapConfigurationAux (Config config, String name, int backupCount, boolean statisticsEnabled, int mapStoreDelay,
        MapStore implementationMapStore) {

        MapConfig mapConfig = config.getMapConfig (name);
        mapConfig.setBackupCount(backupCount);
        mapConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
        mapConfig.setStatisticsEnabled(statisticsEnabled);

        if (implementationMapStore! = null) {
            MapStoreConfig mapStoreConfig = new MapStoreConfig();
            mapStoreConfig.setEnabled(true);
            mapStoreConfig.setImplementation(implementationMapStore);
            mapStoreConfig.setWriteDelaySeconds(mapStoreDelay);
            mapStoreConfig.setWriteBatchSize(100);
            mapStoreConfig.setInitialLoadMode(InitialLoadMode.LAZY);
            mapConfig.setMapStoreConfig(mapStoreConfig);
        }
        return mapConfig;
    }

What I can be doing wrong?


Solution

  • I found the problem As expected, I had a Hazelcast configuration problem. In the interface that set the NetWorkConfig, it was setting 127.0.0.1 in all instances of the cluster.

    NetworkConfig network = cfg.getNetworkConfig();
    network.setPort(port).setPortAutoIncrement(true);
    network.setPublicAddress(publicAddress);
    network.getInterfaces().addInterface("127.0.0.1").setEnabled(true);