Source:
public Topology(final List<String> allNodes, final List<String> liveNodes, final Map<String, InstanceConfig> instanceConfigMap, ClusterConfig clusterConfig) { try { _md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException ex) { throw new IllegalArgumentException(ex); } _allInstances = allNodes; _liveInstances = liveNodes; _instanceConfigMap = instanceConfigMap; if (_instanceConfigMap == null || !_instanceConfigMap.keySet().containsAll(allNodes)) { throw new HelixException(String.format("Config for instances %s is not found!", _allInstances.removeAll(_instanceConfigMap.keySet()))); } _clusterConfig = clusterConfig; if (clusterConfig.isTopologyAwareEnabled()) { String topologyDef = _clusterConfig.getTopology(); if (topologyDef != null) { String[] topologyStr = topologyDef.trim().split("/"); int lastValidTypeIdx = topologyStr.length - 1; for (; lastValidTypeIdx >= 0; --lastValidTypeIdx) { if (topologyStr[lastValidTypeIdx].length() != 0) { break; } } if (lastValidTypeIdx < 0) { throw new HelixException("Invalid cluster topology definition " + topologyDef); } _endNodeType = topologyStr[lastValidTypeIdx]; _faultZoneType = clusterConfig.getFaultZoneType(); if (_faultZoneType == null) { _faultZoneType = _endNodeType; } if (Arrays.stream(topologyStr).noneMatch(type -> type.equals(_faultZoneType))) { throw new HelixException(String .format("Invalid fault zone type %s, not present in topology definition %s.", _faultZoneType, topologyDef)); } } else { _endNodeType = Types.INSTANCE.name(); _faultZoneType = Types.ZONE.name(); } } else { _endNodeType = Types.INSTANCE.name(); _faultZoneType = Types.INSTANCE.name(); } _root = createClusterTree(); }

Target:
public Topology(final List<String> allNodes, final List<String> liveNodes, final Map<String, InstanceConfig> instanceConfigMap, ClusterConfig clusterConfig) { try { _md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException ex) { throw new IllegalArgumentException(ex); } _allInstances = allNodes; _liveInstances = liveNodes; _instanceConfigMap = instanceConfigMap; if (_instanceConfigMap == null || !_instanceConfigMap.keySet().containsAll(allNodes)) { throw new HelixException(String.format("Config for instances %s is not found!", _allInstances.removeAll(_instanceConfigMap.keySet()))); } _clusterConfig = clusterConfig; _clusterTopologyKeys = new LinkedHashSet<>(); if (clusterConfig.isTopologyAwareEnabled()) { String topologyDef = _clusterConfig.getTopology(); if (topologyDef != null) { String[] topologyKeys = topologyDef.trim().split("/"); int lastValidTypeIdx = 0; for (int i = 0; i < topologyKeys.length; i++) { if (topologyKeys[i].length() != 0) { _clusterTopologyKeys.add(topologyKeys[i]); _defaultDomainPathValues.put(topologyKeys[i], DEFAULT_DOMAIN_PREFIX + topologyKeys[i]); lastValidTypeIdx = i; } } if (_clusterTopologyKeys.size() == 0) { throw new HelixException("Invalid cluster topology definition " + topologyDef); } _endNodeType = topologyKeys[lastValidTypeIdx]; _faultZoneType = clusterConfig.getFaultZoneType(); if (_faultZoneType == null) { _faultZoneType = _endNodeType; } else if (!_clusterTopologyKeys.contains(_faultZoneType)) { throw new HelixException(String .format("Invalid fault zone type %s, not present in topology definition %s.", _faultZoneType, topologyDef)); } } else { _endNodeType = Types.INSTANCE.name(); _faultZoneType = Types.ZONE.name(); } } else { _endNodeType = Types.INSTANCE.name(); _faultZoneType = Types.INSTANCE.name(); } _root = createClusterTree(); }