void removeReplicasOfDatanode(String hostname, int port) {
      version += 1;
      int index;
      for (index = 0; index < jsonPartitions.length(); ++index) {
        JSONObject jsonPartition = (JSONObject) jsonPartitions.get(index);
        JSONArray jsonReplicas = (JSONArray) jsonPartition.get("replicas");
        int replicaIdx;
        for (replicaIdx = 0; replicaIdx < jsonReplicas.length(); ++replicaIdx) {
          JSONObject jsonReplica = (JSONObject) jsonReplicas.get(replicaIdx);
          String jsonHostname = (String) jsonReplica.get("jsonHostname");
          int jsonPort = (int) jsonReplica.get("port");
          if (jsonHostname.equals(hostname) && jsonPort == port) {
            break;
          }
        }
        // remove given replica from replicas
        jsonReplicas.remove(replicaIdx);
        jsonPartition.put("replicas", jsonReplicas);
        jsonPartitions.put(index, jsonPartition);
      }
      JSONObject jsonPartitionLayout =
          getJsonPartitionLayout(testHardwareLayout.getHardwareLayout().getClusterName(), version, partitionCount,
              jsonPartitions);
      this.partitionLayout =
          new PartitionLayout(testHardwareLayout.getHardwareLayout(), jsonPartitionLayout, clusterMapConfig);
    }
Return the partition layout as a {@link JSONObject}
@param partitionClass the partition class that these partitions must belong to
@param partitionState the state of the newly created partitions
@return the partition layout as a {@link JSONObject}
@throws JSONException if there is an exception parsing or constructing JSON.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/TestUtils.java