@Override
  public void addResource(String clusterName, String resourceName, IdealState idealstate) {
    resourcesToIdealStates.put(resourceName, idealstate);
    ResourceInfo resourceInfo = resourceToResourceInfoMap.computeIfAbsent(resourceName, k -> new ResourceInfo());
    for (String partition : idealstate.getPartitionSet()) {
      partitionToResourceMap.put(partition, resourceName);
      if (partitionToInstances.get(partition) == null) {
        Set<String> instanceSet = new HashSet<>();
        partitionToInstances.put(partition, instanceSet);
        partitionToPartitionStates.put(partition, PartitionState.READ_WRITE);
      }
      List<String> instances = new ArrayList<>(idealstate.getInstanceSet(partition));
      partitionToInstances.get(partition).addAll(instances);
      for (int i = 0; i < instances.size(); ++i) {
        String instanceName = instances.get(i);
        String stateStr;
        if (i == 0) {
          stateStr = ReplicaState.LEADER.name();
          partitionToLeaderReplica.put(partition, instanceName);
        } else {
          stateStr = ReplicaState.STANDBY.name();
        }
        instanceToReplicaStateInfos.computeIfAbsent(instanceName, k -> new ReplicaStateInfos())
            .setReplicaState(partition, stateStr);
        resourceInfo.setReplicasState(partition, instanceName, stateStr);
      }
    }
  }
Get the instances that have replicas for the given partition.
@param partition the partition name of the partition.
@return the set of instances that have replicas for this partition.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/MockHelixAdmin.java