我设置了两个节点hazelcast 3.2,每个节点包含500 MB数据。我已经配置了客户端近缓存。
我有以下问题
我的服务器端配置
mapCfg = new MapConfig();
mapCfg.setName("TL_MAP_2");
mapCfg.setBackupCount(1);
mapCfg.setReadBackupData(true);//enabled as it is sync backup
mapCfg.setInMemoryFormat(InMemoryFormat.BINARY);
cfg.addMapConfig(mapCfg);
我的客户端代码是单身
public enum CacheService {
INSTANCE;
private static ClientConfig clientConfig = null;
private static HazelcastInstance cacheClient = null;
private static Set<String> nearcaches = new HashSet<String>(Arrays.asList("TL_MAP_1","TL_MAP_2","TL_MAP_3","TL_MAP_4","TL_MAP_5","TL_MAP_6","TL_MAP_7","TL_MAP_8","TL_MAP_9","TL_MAP_10"));
static{
if(clientConfig ==null || cacheClient ==null){
clientConfig = new ClientConfig();
clientConfig.getGroupConfig().setName("dev").setPassword("dev-pass");
clientConfig.getNetworkConfig().addAddress("XXX.XX.XXX.XXX:5701","XXX.XX.XXX.XXX:5702").setSmartRouting(true);;
clientConfig.setExecutorPoolSize(120);
Iterator<String> iterator = nearcaches.iterator();
String near = null;
while(iterator.hasNext()){
near = iterator.next();
clientConfig.addNearCacheConfig(near, new NearCacheConfig().setInMemoryFormat(InMemoryFormat.OBJECT));
}
cacheClient = HazelcastClient.newHazelcastClient(clientConfig);
}
}
public HazelcastInstance getCacheClient(){
return cacheClient;
}
public Map get(String cacheName) {
Map cacheMap = cacheClient.getMap(cacheName);
if (nearcaches.contains(cacheName)) {
NearCacheStats stats = ((IMap) cacheMap).getLocalMapStats()
.getNearCacheStats();
logger.info("Near Cache HITS for map " + cacheName + " ::"
+ stats.getHits());
}
return cacheMap;
}
}