示例#1
0
 public long getPartitionInStateCount(PartitionState partitionState) {
   int count = 0;
   for (Partition partition : partitionMap.values()) {
     if (partition.getPartitionState() == partitionState) {
       count++;
     }
   }
   return count;
 }
示例#2
0
 public List<PartitionId> getWritablePartitions() {
   List<PartitionId> writablePartitions = new ArrayList();
   List<PartitionId> healthyWritablePartitions = new ArrayList();
   for (Partition partition : partitionMap.values()) {
     if (partition.getPartitionState() == PartitionState.READ_WRITE) {
       writablePartitions.add(partition);
       boolean up = true;
       for (Replica replica : partition.getReplicas()) {
         if (replica.isDown()) {
           up = false;
           break;
         }
       }
       if (up) {
         healthyWritablePartitions.add(partition);
       }
     }
   }
   return healthyWritablePartitions.isEmpty() ? writablePartitions : healthyWritablePartitions;
 }