private List<ReplicaId> createNewInstance(DataNodeConfig dataNodeConfig, String dcName) throws Exception {
      String instanceName = dataNodeConfig.getInstanceName();
      logger.info("Adding node {} and its disks and replicas in {}", instanceName, dcName);
      AmbryDataNode datanode = null;
      try {
        datanode =
            new AmbryServerDataNode(dataNodeConfig.getDatacenterName(), clusterMapConfig, dataNodeConfig.getHostName(),
                dataNodeConfig.getPort(), dataNodeConfig.getRackId(), dataNodeConfig.getSslPort(),
                dataNodeConfig.getHttp2Port(), DEFAULT_XID, helixClusterManagerQueryHelper);
      } catch (Exception e) {
        logger.error("Fail to create an AmbryServerDataNode for {} in datacenter {}, skip adding this node.",
            dataNodeConfig.getHostName(), dataNodeConfig.getDatacenterName(), e);
        dataNodeInitializationFailureCount.incrementAndGet();
        return Collections.emptyList();
      }
      // for new instance, we first set it to unavailable and rely on its participation to update its liveness
      if (!instanceName.equals(selfInstanceName)) {
        datanode.setState(HardwareState.UNAVAILABLE);
      }
      List<ReplicaId> addedReplicas = initializeDisksAndReplicasOnNode(datanode, dataNodeConfig);
      instanceNameToAmbryDataNode.put(instanceName, datanode);
      dcToNodes.computeIfAbsent(datanode.getDatacenterName(), s -> ConcurrentHashMap.newKeySet()).add(datanode);
      allInstances.add(instanceName);
      return addedReplicas;
    }
Create a new instance(node) and initialize disks/replicas on it.
@param dataNodeConfig the {@link DataNodeConfig} to create new instance
@param dcName data center name.
@return a list of newly added replicas;
@throws Exception if there is an exception in instantiating the {@link ResourceStatePolicy}
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixClusterManager.java