本文介绍了更改hazelcast地图的加载模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改Hazelcast 3.2地图的加载模式.这是我通过代码尝试过的(不确定是否可以通过XML配置文件使用它,这对我来说更合适).

I am trying to change the load mode for a Hazelcast 3.2 map. This is what I have tried via the code (not sure if its available via the XML config file which would be preferable for me).

private InitialLoadMode initialLoadMode = InitialLoadMode.EAGER;
final Config config= new Config();
final MapConfig mapConfig = config.getMapConfig("*");
final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
mapStoreConfig.setInitialLoadMode(initialLoadMode); //mapStoreConfig.InitialLoadMode(initialLoadMode);

最后一行似乎无法编译.有什么建议吗?

The last last line does not appear to compile. Any suggestions?

推荐答案

您需要在构造函数中调用它,例如:

You need to call it in a construtor, e.g. :

class Foo{

    private InitialLoadMode initialLoadMode = InitialLoadMode.EAGER;
    final Config config= new Config();
    final MapConfig mapConfig = config.getMapConfig("*");
    final MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
    {
        mapStoreConfig.setInitialLoadMode(initialLoadMode);
    }
}

这篇关于更改hazelcast地图的加载模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 13:25