Map<ReplicaState, List<ReplicaId>> getReplicasByState(String dcName, EnumSet<ReplicaState> states) {
    Map<ReplicaState, List<ReplicaId>> map = new HashMap<>();
    for (ReplicaState replicaState : states) {
      if (allDcReplicasByState.containsKey(replicaState)) {
        for (ReplicaId replicaId : allDcReplicasByState.get(replicaState)) {
          if (dcName == null || replicaId.getDataNodeId().getDatacenterName().equals(dcName)) {
            map.putIfAbsent(replicaState, new ArrayList<>());
            map.get(replicaState).add(replicaId);
          }
        }
      }
    }
    return map;
  }
Get replicas in required states for the specified datacenter.
@param dcName the name of data center from which the replicas should come from. This can be {@code null}.
@param states a set of {@link ReplicaState}(s) that replicas should match.
@return a map whose key is {@link ReplicaState} and value is a list of {@link ReplicaId}(s) in that state.
ambry-router/src/main/java/com/github/ambry/router/SimpleOperationTracker.java