bipinprasad commented on a change in pull request #3215: Storm3585 - New 
compact Constraint config including maxNodeCoLocationCnt and 
incompatibleComponents
URL: https://github.com/apache/storm/pull/3215#discussion_r390723935
 
 

 ##########
 File path: 
storm-server/src/test/java/org/apache/storm/scheduler/resource/strategies/scheduling/TestConstraintSolverStrategy.java
 ##########
 @@ -85,6 +132,80 @@
         return config;
     }
 
+    /**
+     * Set Config.TOPOLOGY_RAS_CONSTRAINTS (when consolidatedConfigFlag is 
true) or both
+     * Config.TOPOLOGY_RAS_CONSTRAINTS/Config.TOPOLOGY_SPREAD_COMPONENTS (when 
consolidatedConfigFlag is false).
+     *
+     * When consolidatedConfigFlag when true, use the new more consolidated 
format to set Config.TOPOLOGY_RAS_CONSTRAINTS.
+     * When false, use the old configuration format for 
Config.TOPOLOGY_RAS_CONSTRAINTS/TOPOLOGY_SPREAD_COMPONENTS.
+     *
+     * @param constraints List of components, where the first one cannot 
co-exist with the others in the list
+     * @param spreads Map of component and its maxCoLocationCnt
+     * @param config Configuration to be updated
+     */
+    private void setConstraintConfig(List<List<String>> constraints, 
Map<String, Integer> spreads, Map<String, Object> config) {
+        if (consolidatedConfigFlag) {
+            // single configuration for each component
+            Map<String, Map<String,Object>> modifiedConstraints = new 
HashMap<>();
+            for (List<String> constraint: constraints) {
+                if (constraint.size() < 2) {
+                    continue;
+                }
+                String comp = constraint.get(0);
+                List<String> others = constraint.subList(1, constraint.size());
+                List<Object> incompatibleComponents = 
(List<Object>)modifiedConstraints.computeIfAbsent(comp, k -> new 
HashMap<String,Object>())
+                        
.computeIfAbsent(ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS,
 k -> new ArrayList<Object>());
+                incompatibleComponents.addAll(others);
+            }
+            for (String comp: spreads.keySet()) {
+                modifiedConstraints.computeIfAbsent(comp, k -> new 
HashMap<String,Object>()).put(ConstraintSolverStrategy.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT,
 ""+spreads.get(comp));
 
 Review comment:
   yes on first
    sending in String into Map only.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to