private void addToPool(ReplicaId replicaId) {
    String replicaDatacenterName = replicaId.getDataNodeId().getDatacenterName();
    if (replicaDatacenterName.equals(datacenterName)) {
      if (!replicaId.isDown()) {
        localReplicas.addFirst(replicaId);
      } else {
        localReplicas.addLast(replicaId);  // We may still attempt to send requests to down replicas as a very last resort.
      }
    } else {
      // Remote replicas will be sorted later so just add them in any order.
      replicaPoolByDc.computeIfAbsent(replicaDatacenterName, k -> new LinkedList<>()).add(replicaId);
    }
  }
Add a replica to the to the list for its data center.
@param replicaId the replica to add.
ambry-router/src/main/java/com/github/ambry/router/ParanoidDurabilityOperationTracker.java