private static void setInstanceConfig(String clusterName, String instanceName, String resource,
      ConfigAccessor configAccessor, PropertyStoreToDataNodeConfigAdapter propertyStoreToDataNodeConfigAdapter,
      HelixAdmin helixAdmin, boolean dryRun) {
    InstanceConfig instanceConfig = configAccessor.getInstanceConfig(clusterName, instanceName);
    DataNodeConfig nodeConfigFromHelix =
        getDataNodeConfigFromHelix(clusterName, instanceName, propertyStoreToDataNodeConfigAdapter, null, helixAdmin,
            PROPERTY_STORE);

    // 1. Add tag
    // Remove previous tags
    // Add latest tag
    instanceConfig.addTag(getResourceTag(resource));

    // 2. Setup domain information
    Map<String, String> domainMap = new HashMap<>();
    domainMap.put(RACK_KEY, nodeConfigFromHelix.getRackId());
    domainMap.put(HOST_KEY, instanceName);
    instanceConfig.setDomain(domainMap);

    // 3. Set instance capacity
    Map<String, Integer> capacityMap = new HashMap<>();
    long capacity = nodeConfigFromHelix.getDiskConfigs()
        .values()
        .stream()
        .mapToLong(DataNodeConfig.DiskConfig::getDiskCapacityInBytes)
        .sum();
    long capacityInGB = capacity / 1024 / 1024 / 1024;
    int actualCapacityInGB = (int) ((double) INSTANCE_MAX_CAPACITY_PERCENTAGE / 100 * capacityInGB);
    capacityMap.put(DISK_KEY, actualCapacityInGB);
    instanceConfig.setInstanceCapacityMap(capacityMap);

    // Update instance config in Helix/ZK
    if (!dryRun) {
      configAccessor.updateInstanceConfig(clusterName, instanceName, instanceConfig);
      info("Updated instance config fields for Instance {}. TAGS: {}, DOMAIN: {}, INSTANCE_CAPACITY_MAP {}",
          instanceName, instanceConfig.getTags(), instanceConfig.getDomainAsString(),
          instanceConfig.getInstanceCapacityMap());
    } else {
      info(
          "Dry run. This will update instance config fields for Instance {}. TAGS: {}, DOMAIN: {}, INSTANCE_CAPACITY_MAP {}",
          instanceName, instanceConfig.getTags(), instanceConfig.getDomainAsString(),
          instanceConfig.getInstanceCapacityMap());
    }
  }
Sets up instance to use waged rebalancer

@param clusterName
@param instanceName                         instance name
@param resource                             resource name
@param configAccessor                       the {@link ConfigAccessor} to access configuration in Helix.
@param propertyStoreToDataNodeConfigAdapter {@link PropertyStoreToDataNodeConfigAdapter} to access property store
                                            data.
@param helixAdmin                           {@link HelixAdmin}
@param dryRun                               if true, perform a dry run; do not change ideal state to Full-Auto in Helix.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixBootstrapUpgradeUtil.java