private List<PartitionId> getPartitionsInClass(String partitionClass, boolean minimumReplicaCountRequired) {
      List<PartitionId> toReturn = new ArrayList<>();
      rwLock.readLock().lock();
      try {
        if (partitionClass == null) {
          toReturn.addAll(allPartitions);
        } else {
          SortedMap<Integer, List<PartitionId>> partitionsByReplicaCount =
              partitionIdsByClassAndLocalReplicaCount.get(partitionClass);
          if (partitionsByReplicaCount == null) {
            partitionsByReplicaCount = partitionIdsByClassAndLocalReplicaCount.get(defaultPartitionClass);
          }
          if (partitionsByReplicaCount == null) {
            throw new IllegalArgumentException(
                "No partitions for partition class = '" + partitionClass + "' or default partition class = '" + defaultPartitionClass + "' found");
          }
          if (minimumReplicaCountRequired) {
            // get partitions with replica count >= min replica count specified in ClusterMapConfig
            for (List<PartitionId> partitionIds : partitionsByReplicaCount.tailMap(minimumLocalReplicaCount).values()) {
              toReturn.addAll(partitionIds);
            }
          } else {
            for (List<PartitionId> partitionIds : partitionsByReplicaCount.values()) {
              toReturn.addAll(partitionIds);
            }
          }
        }
      } finally {
        rwLock.readLock().unlock();
      }
      return toReturn;
    }
Returns the partitions belonging to the {@code partitionClass}. Returns all partitions if {@code partitionClass}
is {@code null}.
@param partitionClass the class of the partitions desired.
@param minimumReplicaCountRequired if {@code true}, returns only the partitions with the number of replicas in
                                   local datacenter that is larger than or equal to minimum required count.
@return the partitions belonging to the {@code partitionClass}. Returns all partitions if {@code partitionClass}
is {@code null}.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/ClusterMapUtils.java