void removeReplicaFromPartition(Replica replicaToRemove) {
      version += 1;
      String partitionName = replicaToRemove.getPartitionId().toPathString();
      int index;
      for (index = 0; index < jsonPartitions.length(); ++index) {
        String partitionId = String.valueOf(((JSONObject) jsonPartitions.get(index)).get("id"));
        if (partitionId.equals(partitionName)) {
          break;
        }
      }
      JSONObject jsonPartition = (JSONObject) jsonPartitions.get(index);
      JSONArray jsonReplicas = (JSONArray) jsonPartition.get("replicas");
      int replicaIdx;
      DataNode targetNode = (DataNode) replicaToRemove.getDataNodeId();
      for (replicaIdx = 0; replicaIdx < jsonReplicas.length(); ++replicaIdx) {
        JSONObject jsonReplica = (JSONObject) jsonReplicas.get(replicaIdx);
        String hostname = (String) jsonReplica.get("hostname");
        int port = (int) jsonReplica.get("port");
        if (hostname.equals(targetNode.getHostname()) && port == targetNode.getPort()) {
          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