【发布时间】:2018-04-20 00:40:19
【问题描述】:
我是 Infinispan 的新手。即使在通过 Infinispan 用户指南和谷歌搜索之后,我也无法弄清楚 Infinispan 在以下情况下的行为:
1) 进行再平衡时是否锁定 HotRod 客户端读取?
2) Infinispan 在 REPL 模式下如何在 HotRod 客户端使用 async 和 nearCache 运行? (我发现如果nearCache被禁用,那么它可以获取数据,但不能使用nearCache。它与nearCache更新有什么关系吗?)
服务器代码:
GlobalConfigurationBuilder globalConfig = GlobalConfigurationBuilder.defaultClusteredBuilder();
globalConfig.transport().clusterName("infiniReplicatedCluster").globalJmxStatistics().enable().allowDuplicateDomains(Boolean.TRUE);
ConfigurationBuilder configBuilder = new ConfigurationBuilder();
EmbeddedCacheManager embeddedCacheManager = new DefaultCacheManager(globalConfig.build());
configBuilder.dataContainer().compatibility().enable().clustering().cacheMode(CacheMode.REPL_ASYNC)
.async().replQueueInterval(120, TimeUnit.SECONDS).useReplQueue(true).hash();
embeddedCacheManager.defineConfiguration("TestCache", configBuilder.build());
Cache<String, TopologyData> cache = embeddedCacheManager.getCache("TestCache");
cache.put("00000", new TopologyData());
HotRodServerConfiguration build = new HotRodServerConfigurationBuilder().build();
HotRodServer server = new HotRodServer();
server.start(build, embeddedCacheManager);
客户代码:
ConfigurationBuilder remoteBuilder = new ConfigurationBuilder();
remoteBuilder.nearCache().mode(NearCacheMode.EAGER).maxEntries(100);
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(remoteBuilder.build());
remoteCache = remoteCacheManager.getCache("TestCache");
System.out.println(remoteCache.get(fetchKey));
使用上面的代码,下面列出了场景和结果(所有运行都进行了多次,导致相同的结果):
-没有 nearCache 1 Key --> 得到了预期的值
-with nearCache (LAZY/EAGER) 1 key --> null
-在同一次运行中,两次相同的 Key 使用 nearCache (LAZY/EAGER) --> null(第一次) - 预期值(下一次)
需要澄清:如果一个示例代码重新验证 HotRod 客户端在 DIST 模式下的负载平衡(RoundRobin)行为。 (我能够成功地使用 REPL 模式检查它,并且它的工作原理与它声称的一样)
【问题讨论】:
-
从配置来看,您似乎使用的是较旧的 Infinispan 版本,因为我们在较新的 Infinispan 版本中删除了复制队列。您只需将缓存设置为异步复制即可。如果我是你,我会看看最新的 Infinispan 稳定版本是否存在问题,即 9.1.2
标签: infinispan infinispan-9 near-cache hot-rod