@Override
  public ReplicaId getBootstrapReplica(String partitionIdStr, DataNodeId dataNodeId) {
    String instanceName = getInstanceName(dataNodeId.getHostname(), dataNodeId.getPort());
    try {
      ReplicaId bootstrapReplica =
          isDataNodeInFullAutoMode(dataNodeId, true) ? getBootstrapReplicaInFullAuto(partitionIdStr, dataNodeId)
              : getBootstrapReplicaInSemiAuto(partitionIdStr, dataNodeId);
      // For now this method is only called by server which new replica will be added to. So if datanode equals to current
      // node, we temporarily add this into a map (because we don't know whether store addition in storage manager
      // succeeds or not). After store addition succeeds, current node is supposed to update InstanceConfig and will
      // receive notification from Helix afterwards. At that time, dynamic cluster change handler will move replica from
      // this map to clustermap related data structures that can be queried by other components.
      if (bootstrapReplica != null && instanceName.equals(selfInstanceName)) {
        // Note that this method might be called by several state transition threads concurrently.
        bootstrapReplicas.put(partitionIdStr, bootstrapReplica);
        // Add the selected disk so that it is not picked
        disksAttemptedForBootstrap.computeIfAbsent(partitionIdStr, k -> new HashSet<>())
            .add(bootstrapReplica.getDiskId());
      }
      return bootstrapReplica;
    } catch (Exception e) {
      logger.error("Failed to create bootstrap replica for partition {} on {} due to exception: ", partitionIdStr,
          instanceName, e);
      return null;
    }
  }
Initialize HelixManager in local datacenter and complete subscription of HelixPropertyStore to listen for
PartitionOverride zNode. This needs to happen before other datacenters are initialized so that any partition
overrides can be properly honored.
@param dataCenterToZkAddress the map mapping each datacenter to its corresponding ZkAddress.
@param instanceName the String representation of the instance associated with this manager.
@param helixFactory the factory class to construct and get a reference to a {@link HelixManager}.
@return the HelixManager of local datacenter, or {@code null} if the local datacenter is
        {@link ReplicaType#CLOUD_BACKED}, as we currently do not support getting cluster state from Helix for cloud
        datacenters.
@throws Exception
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixClusterManager.java