private boolean isPartitionEligibleForParanoidDurability(PartitionId partitionId) {
      // Create a map (validRemoteReplicasPerDc) where the keys are names of remote data centers and the values are the number of replicas in that
      // data center that are both up and in the right Helix state (LEADER or STANDBY).
      Map<ReplicaState, ? extends List<? extends ReplicaId>> replicasByState = partitionId.getReplicaIdsByStates(EnumSet.of(ReplicaState.STANDBY, ReplicaState.LEADER), null);
      List<? extends ReplicaId> replicas = replicasByState.values().stream().flatMap(List::stream).collect(Collectors.toList());

      Map<String, Integer> validRemoteReplicasPerDc = replicas.stream()
          .filter(replica -> !replica.getDataNodeId().getDatacenterName().equals(this.localDatacenterName))
          .filter(replica -> !replica.isDown())
          .collect(Collectors.groupingBy(replica -> replica.getDataNodeId().getDatacenterName(),
              Collectors.reducing(0, replica -> 1, Integer::sum)));

      return !validRemoteReplicasPerDc.isEmpty() && validRemoteReplicasPerDc.values().stream().allMatch(count -> count > 0);
    }
Checks whether there is at least one replica in every remote data center that is eligible for puts.
@param partitionId the {@link PartitionId} to check.
@return true if the given partition has at least one replica in every remote data center that is both up and
in the right Helix state.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/ClusterMapUtils.java