Ethanlm 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_r388509017
 
 

 ##########
 File path: 
storm-server/src/main/java/org/apache/storm/scheduler/resource/strategies/scheduling/ConstraintSolverStrategy.java
 ##########
 @@ -420,21 +528,24 @@ public boolean isExecAssignmentToWorkerValid(WorkerSlot 
worker, SearcherState st
 
         //check if exec can be on worker based on user defined component 
exclusions
         String execComp = execToComp.get(exec);
-        Set<String> components = state.workerCompAssignment.get(worker);
-        if (components != null) {
-            Map<String, Integer> subMatrix = constraintMatrix.get(execComp);
-            for (String comp : components) {
-                if (subMatrix.get(comp) != 0) {
+        Map<String, Integer> compAssignmentCnts = 
state.workerCompAssignmentCnts.get(worker);
+        if (compAssignmentCnts != null && 
constraintConfig.incompatibleComponents.containsKey(execComp)) {
+            Set<String> subMatrix = 
constraintConfig.incompatibleComponents.get(execComp);
+            for (String comp : compAssignmentCnts.keySet()) {
+                if (subMatrix.contains(comp)) {
                     LOG.trace("{} found {} constraint violation {} on {}", 
exec, execComp, comp, worker);
                     return false;
                 }
             }
         }
 
         //check if exec satisfy spread
-        if (spreadComps.contains(execComp)) {
-            if (state.nodeCompAssignment.computeIfAbsent(node, (k) -> new 
HashSet<>()).contains(execComp)) {
-                LOG.trace("{} Found spread violation {} on node {}", exec, 
execComp, node.getId());
+        if (constraintConfig.maxCoLocationCnts.containsKey(execComp)) {
+            int coLocationMaxCnt = 
constraintConfig.maxCoLocationCnts.get(execComp);
+            if (state.nodeCompAssignmentCnts.containsKey(node)
+                    && 
state.nodeCompAssignmentCnts.get(node).getOrDefault(execComp, 0) >= 
coLocationMaxCnt) {
 
 Review comment:
   You are right. Thanks

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