Пример #1
0
  protected void validateUniqueness() {
    // Validate uniqueness of each logical component. Partition uniqueness is validated by method
    // addPartition.
    Set<Replica> replicaSet = new HashSet<Replica>();

    for (Partition partition : partitionMap.values()) {
      for (Replica replica : partition.getReplicas()) {
        if (!replicaSet.add(replica)) {
          throw new IllegalStateException("Duplicate Replica detected: " + replica.toString());
        }
      }
    }
  }
Пример #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;
 }