我的主要成员
int
日志
const
我的奴隶成员
public static void main(String[] args) throws InterruptedException {
Config config = new Config();
config.setProperty(GroupProperty.ENABLE_JMX, "true");
config.setProperty(GroupProperty.BACKPRESSURE_ENABLED, "true");
config.setProperty(GroupProperty.SLOW_OPERATION_DETECTOR_ENABLED, "true");
config.getSerializationConfig().addPortableFactory(1, new MyPortableFactory());
HazelcastInstance hz = Hazelcast.newHazelcastInstance(config);
IMap<Integer, Rule> ruleMap = hz.getMap("ruleMap");
// TODO generate rule map data ; more than 100,000 entries
generateRuleMapData(ruleMap);
logger.info("generate rule finised!");
// TODO rule map index
// health check
PartitionService partitionService = hz.getPartitionService();
LocalMapStats mapStatistics = ruleMap.getLocalMapStats();
while (true) {
logger.info("isClusterSafe:{},isLocalMemberSafe:{},number of entries owned on this node = {}",
partitionService.isClusterSafe(), partitionService.isLocalMemberSafe(),
mapStatistics.getOwnedEntryCount());
Thread.sleep(1000);
}
}
日志 2016-06-28 14:05:53,543 INFO [main] b.SlaveMember(SlaveMember.java:31) - isClusterSafe:false,isLocalMemberSafe:false,此节点上拥有的条目数= 412441 2016-06-28 14:05:54,556 INFO [main] b.SlaveMember(SlaveMember.java:31) - isClusterSafe:false,isLocalMemberSafe:false,此节点上拥有的条目数= 412441 2016-06-28 14:05:55,563 INFO [main] b.SlaveMember(SlaveMember.java:31) - isClusterSafe:false,isLocalMemberSafe:false,此节点上拥有的条目数= 412441 2016-06-28 14:05:56,578 INFO [main] b.SlaveMember(SlaveMember.java:31) - isClusterSafe:false,isLocalMemberSafe:false,此节点上拥有的条目数= 412441
我的问题是:
为什么在群集添加一个从属成员后,主要成员上拥有的条目数不会更改?
答案 0 :(得分:0)
我应该每秒获得静态。
while (true) {
LocalMapStats mapStatistics = ruleMap.getLocalMapStats();
logger.info(
"isClusterSafe:{},isLocalMemberSafe:{},rulemap.size:{}, number of entries owned on this node = {}",
partitionService.isClusterSafe(), partitionService.isLocalMemberSafe(), ruleMap.size(),
mapStatistics.getOwnedEntryCount());
Thread.sleep(1000);
}
答案 1 :(得分:0)
另一种选择是使用localKeySet,它返回本地拥有的密钥集。
IMap::localKeySet.size()