我是Infinispan的新手。即使在通过Infinispan用户指南&谷歌搜索,我无法在下面的案例中找出Infinispan的行为:
1)重新平衡时是否会锁定HotRod客户端读取?
2)Infinispan如何使用异步和放大器的REPL模式运行hotRod客户端附近的附近? (我发现如果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));
使用上面的代码,场景&amp;结果列在下面(所有运行都进行了多次,结果相同):
- 没有nearCache 1 Key - &gt;得到了预期的价值
- 使用nearCache(LAZY / EAGER)1键 - &gt;空
- 在同一次运行中,相同的键两次使用nearCache(LAZY / EAGER) - &gt; null(第一次) - 期望值(下次)
需要澄清:如果示例代码在DIST模式下重新验证HotRod客户端的负载平衡(RoundRobin)行为。 (我能够成功地使用REPL模式进行检查,并且它按照它的要求运行)
答案 0 :(得分:1)
澄清:Hot Rod以DIST和REPL模式进入主要拥有者(REPL只是一种特殊的DIST模式,其中所有者的数量等于群集的大小)根据密钥进行哈希处理并且仅使用Round Robin如果主要没有响应。