我确信我做错了什么但却无法弄明白。 hazelcast xml配置将在下面复制到地图中。当我在地图上放置时,我可以看到地图上的计数增加但稍后,当我得到对同一地图的引用时,大小似乎为零。我正在测试一个节点来测试我的逻辑。我正在使用hazelcast 3.2。我没有添加任何商店加载或监听器实现(我想我可以添加监听器以确认是否添加了条目)。
<map name="testMap">
<in-memory-format>BINARY</in-memory-format>
<backup-count>0</backup-count>
<time-to-live-seconds>0</time-to-live-seconds>
<max-idle-seconds>0</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<max-size policy="PER_NODE">0</max-size>
<eviction-percentage>25</eviction-percentage>
<merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy>
</map>
示例代码: 我得到如下关于hazelcast的引用:
static HazelCastClientAccessor hazelcastClientAccessor = HazelCastClientAccessor.getAccessorInstance();
static HazelcastInstance hazelcast = hazelcastClientAccessor.getHazelCastInstance();
一旦我得到了参考资料,我就会打电话或者上地图。
IMap<String, String> testMap = hcast.getMap("testMap");
testMap.put("abc", "xyz");
然后在另一个课程中,我再次获得了如上所述的hazelcast参考。然后我得到地图并打电话给它,但地图是空的。我搞砸了什么想法?
IMap<String, String> testMap = hcast.getMap("testMap");
for (String s: testMap.keySet()) {
Logger.info("keys + values{} {}:", s, testMap.get(s));
}
我正在提取像这样的Hazelcast实例:
Config config = new FileSystemXmlConfig("somelocation/conf/hazelcast.xml"); //location is correct
HazelcastInstance hazelcast = HazelcastClient.newHazelcastClient(config);