xyuanlu commented on a change in pull request #1043:
URL: https://github.com/apache/helix/pull/1043#discussion_r439688790



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/topology/Topology.java
##########
@@ -81,62 +78,43 @@ public Topology(final List<String> allNodes, final 
List<String> liveNodes,
       throw new HelixException(String.format("Config for instances %s is not 
found!",
           _allInstances.removeAll(_instanceConfigMap.keySet())));
     }
-
     _clusterConfig = clusterConfig;
-    _types = new LinkedHashSet<>();
-    _topologyAwareEnabled = clusterConfig.isTopologyAwareEnabled();
+    _clusterTopologyKeys = new LinkedHashSet<>();
 
-    if (_topologyAwareEnabled) {
+    if (clusterConfig.isTopologyAwareEnabled()) {
       String topologyDef = _clusterConfig.getTopology();
       if (topologyDef != null) {
         // Customized cluster topology definition is configured.
-        String[] types = topologyDef.trim().split("/");
-        for (int i = 0; i < types.length; i++) {
-          if (types[i].length() != 0) {
-            _types.add(types[i]);
+        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]);
+            lastValidTypeIdx = i;
           }
         }
-        if (_types.size() == 0) {
-          logger.error("Invalid cluster topology definition " + topologyDef);
+        if (_clusterTopologyKeys.size() == 0) {
           throw new HelixException("Invalid cluster topology definition " + 
topologyDef);
-        } else {
-          String lastType = null;
-          for (String type : _types) {
-            _defaultDomainPathValues.put(type, "Helix_default_" + type);
-            lastType = type;
-          }
-          _endNodeType = lastType;
-          _faultZoneType = clusterConfig.getFaultZoneType();
-          if (_faultZoneType == null) {
-            _faultZoneType = _endNodeType;
-          }
-          if (!_types.contains(_faultZoneType)) {
-            throw new HelixException(String
-                .format("Invalid fault zone type %s, not present in topology 
definition %s.",
-                    _faultZoneType, topologyDef));
-          }
-          _useDefaultTopologyDef = false;
+        }
+        _endNodeType = topologyKeys[lastValidTypeIdx];

Review comment:
       I am not sure if there is a get() function for LinkedHashSet.
   
   
https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashSet.html#method.summary




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to