List<DataNode> getIndependentDataNodes(int dataNodeCountPerDc) {
      List<DataNode> dataNodesToReturn = new ArrayList<DataNode>();
      for (Datacenter datacenter : hardwareLayout.getDatacenters()) {
        List<DataNode> dataNodesInThisDc = new ArrayList<>();
        dataNodesInThisDc.addAll(datacenter.getDataNodes());
        if (dataNodeCountPerDc < 0 || dataNodeCountPerDc > dataNodesInThisDc.size()) {
          throw new IndexOutOfBoundsException("dataNodeCount out of bounds:" + dataNodeCountPerDc);
        }
        Collections.shuffle(dataNodesInThisDc);
        dataNodesToReturn.addAll(dataNodesInThisDc.subList(0, dataNodeCountPerDc));
      }
      return dataNodesToReturn;
    }
Get given number of datanodes from each datacenter.
@param dataNodeCountPerDc number of datanodes to get from each datacenter.
@return a list of datanodes.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/TestUtils.java