Exemple #1
0
 protected void handlePartitions(String[] args) {
   Set<Partition> partitions = hazelcast.getPartitionService().getPartitions();
   Map<Member, Integer> partitionCounts = new HashMap<Member, Integer>();
   for (Partition partition : partitions) {
     Member owner = partition.getOwner();
     if (owner != null) {
       Integer count = partitionCounts.get(owner);
       int newCount = 1;
       if (count != null) {
         newCount = count + 1;
       }
       partitionCounts.put(owner, newCount);
     }
     println(partition);
   }
   Set<Map.Entry<Member, Integer>> entries = partitionCounts.entrySet();
   for (Map.Entry<Member, Integer> entry : entries) {
     println(entry.getKey() + ":" + entry.getValue());
   }
 }