static void updatePreferenceLists(String zkLayoutPath, String clusterName, String dcs, String resourceName,
      String commaSeparatedPartitions) throws Exception {

    Map<String, ClusterMapUtils.DcZkInfo> dataCenterToZkAddress = parseAndUpdateDcInfoFromArg(dcs, zkLayoutPath);
    info("Removing partitions {} in resource {} from preference lists in cluster {}", commaSeparatedPartitions,
        resourceName, clusterName);

    for (Map.Entry<String, ClusterMapUtils.DcZkInfo> entry : dataCenterToZkAddress.entrySet()) {
      List<String> zkConnectStrs = entry.getValue().getZkConnectStrs();
      if (zkConnectStrs.size() != 1) {
        throw new IllegalArgumentException(
            entry.getKey() + " has invalid number of ZK endpoints: " + zkConnectStrs.size());
      }
      // 1. Get current preference lists from resource config
      ConfigAccessor configAccessor = new ConfigAccessor(zkConnectStrs.get(0));
      ResourceConfig resourceConfig = configAccessor.getResourceConfig(clusterName, resourceName);
      Map<String, List<String>> resourceConfigPreferenceLists = resourceConfig.getPreferenceLists();
      // 2. Remove input partitions from preference lists
      Set<String> partitionSet;
      if (commaSeparatedPartitions.equalsIgnoreCase(ALL)) {
        partitionSet = resourceConfigPreferenceLists.keySet();
      } else {
        partitionSet =
            Arrays.stream(commaSeparatedPartitions.replaceAll("\\p{Space}", "").split(",")).collect(Collectors.toSet());
      }
      for (String partition : partitionSet) {
        resourceConfigPreferenceLists.remove(partition);
        info("Removing partition {} under resource {} in resource config", partition, resourceName);
      }
      // 3. Write to helix
      resourceConfig.setPreferenceLists(resourceConfigPreferenceLists);
      configAccessor.setResourceConfig(clusterName, resourceName, resourceConfig);
      info("Removed partitions {} in resource {} from preference lists in resource config for cluster {} in dc {}",
          commaSeparatedPartitions, resourceName, clusterName, entry.getKey());
    }
  }
Removes given list of partitions from preference lists in Resource configs
@param zkLayoutPath             the path to the zookeeper layout file.
@param clusterName              the name of the cluster in Helix.
@param dcs                      the comma-separated list of data centers in which preference lists needs to be
                                updated.
@param resourceName             the resource name for which preference list needs to be updated.
@param commaSeparatedPartitions comma separated list of partitions that needs to be removed from preference list.
                                If "all" is provided, it removes all existing partitions.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/HelixBootstrapUpgradeUtil.java