Source:
private HelixBootstrapUpgradeUtil(String hardwareLayoutPath, String partitionLayoutPath, String zkLayoutPath, String clusterNamePrefix, int maxPartitionsInOneResource, boolean dryRun, boolean forceRemove, HelixAdminFactory helixAdminFactory) throws Exception { this.maxPartitionsInOneResource = maxPartitionsInOneResource; this.dryRun = dryRun; this.forceRemove = forceRemove; this.dataCenterToZkAddress = ClusterMapUtils.parseDcJsonAndPopulateDcInfo(Utils.readStringFromFile(zkLayoutPath)); Properties props = new Properties(); props.setProperty("clustermap.host.name", "localhost"); props.setProperty("clustermap.cluster.name", ""); props.setProperty("clustermap.datacenter.name", ""); ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); if (new File(partitionLayoutPath).exists()) { staticClusterMap = (new StaticClusterAgentsFactory(clusterMapConfig, hardwareLayoutPath, partitionLayoutPath)).getClusterMap(); } else { staticClusterMap = (new StaticClusterAgentsFactory(clusterMapConfig, new PartitionLayout( new HardwareLayout(new JSONObject(Utils.readStringFromFile(hardwareLayoutPath)), clusterMapConfig), null))).getClusterMap(); } String clusterNameInStaticClusterMap = staticClusterMap.partitionLayout.getClusterName(); clusterName = clusterNamePrefix + clusterNameInStaticClusterMap; System.out.println( "Associating static Ambry cluster \"" + clusterNameInStaticClusterMap + "\" with cluster\"" + clusterName + "\" in Helix"); for (Datacenter datacenter : staticClusterMap.hardwareLayout.getDatacenters()) { if (!dataCenterToZkAddress.keySet().contains(datacenter.getName())) { throw new IllegalArgumentException( "There is no ZK host for datacenter " + datacenter.getName() + " in the static clustermap"); } } for (Map.Entry<String, ClusterMapUtils.DcZkInfo> entry : dataCenterToZkAddress.entrySet()) { HelixAdmin admin = helixAdminFactory.getHelixAdmin(entry.getValue().getZkConnectStr()); adminForDc.put(entry.getKey(), admin); } }

Target:
private HelixBootstrapUpgradeUtil(String hardwareLayoutPath, String partitionLayoutPath, String zkLayoutPath, String clusterNamePrefix, int maxPartitionsInOneResource, boolean dryRun, boolean forceRemove, HelixAdminFactory helixAdminFactory) throws Exception { this.maxPartitionsInOneResource = maxPartitionsInOneResource; this.dryRun = dryRun; this.forceRemove = forceRemove; this.dataCenterToZkAddress = ClusterMapUtils.parseDcJsonAndPopulateDcInfo(Utils.readStringFromFile(zkLayoutPath)); Properties props = new Properties(); props.setProperty("clustermap.host.name", "localhost"); props.setProperty("clustermap.cluster.name", ""); props.setProperty("clustermap.datacenter.name", ""); ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); if (new File(partitionLayoutPath).exists()) { staticClusterMap = (new StaticClusterAgentsFactory(clusterMapConfig, hardwareLayoutPath, partitionLayoutPath)).getClusterMap(); } else { staticClusterMap = (new StaticClusterAgentsFactory(clusterMapConfig, new PartitionLayout( new HardwareLayout(new JSONObject(Utils.readStringFromFile(hardwareLayoutPath)), clusterMapConfig), null))).getClusterMap(); } String clusterNameInStaticClusterMap = staticClusterMap.partitionLayout.getClusterName(); clusterName = clusterNamePrefix + clusterNameInStaticClusterMap; info("Associating static Ambry cluster \"" + clusterNameInStaticClusterMap + "\" with cluster\"" + clusterName + "\" in Helix"); for (Datacenter datacenter : staticClusterMap.hardwareLayout.getDatacenters()) { if (!dataCenterToZkAddress.keySet().contains(datacenter.getName())) { throw new IllegalArgumentException( "There is no ZK host for datacenter " + datacenter.getName() + " in the static clustermap"); } } for (Map.Entry<String, ClusterMapUtils.DcZkInfo> entry : dataCenterToZkAddress.entrySet()) { HelixAdmin admin = helixAdminFactory.getHelixAdmin(entry.getValue().getZkConnectStr()); adminForDc.put(entry.getKey(), admin); } }