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_r389810185
##########
File path:
storm-server/src/test/java/org/apache/storm/scheduler/resource/strategies/scheduling/TestConstraintSolverStrategy.java
##########
@@ -146,7 +267,43 @@ public void
basicUnitTestWithKillAndRecover(ConstraintSolverStrategy cs, int bol
Assert.assertTrue("Assert scheduling topology success " + result,
result.isSuccess());
Assert.assertEquals("topo all executors scheduled?", 0,
cluster.getUnassignedExecutors(topo).size());
- Assert.assertTrue("Valid Scheduling?",
ConstraintSolverStrategy.validateSolution(cluster, topo));
+ Assert.assertTrue("Valid Scheduling?",
ConstraintSolverStrategy.validateSolution(cluster, topo, null));
+ }
+
+ @Test
+ public void testNewConstraintFormat() {
+ String s = String.format(
+ "{ \"comp-1\": "
+ + " { \"%s\": 2, "
+ + " \"%s\": [\"comp-2\", \"comp-3\"
] }, "
+ + " \"comp-2\": "
+ + " { \"%s\": [ \"comp-4\" ] }, "
+ + " \"comp-3\": "
+ + " { \"%s\": \"comp-5\" } "
+ + "}",
+
ConstraintSolverStrategy.CONSTRAINT_TYPE_MAX_NODE_CO_LOCATION_CNT,
+
ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS,
+
ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS,
+
ConstraintSolverStrategy.CONSTRAINT_TYPE_INCOMPATIBLE_COMPONENTS
+ );
+ Object jsonValue = JSONValue.parse(s);
+ Map<String, Object> config = Utils.readDefaultConfig();
+ config.put(Config.TOPOLOGY_RAS_CONSTRAINTS, jsonValue);
+ Set<String> allComps = new HashSet<>();
+ allComps.addAll(Arrays.asList("comp-1", "comp-2", "comp-3", "comp-4",
"comp-5"));
+ ConstraintSolverStrategy.ConstraintConfig constraintConfig = new
ConstraintSolverStrategy.ConstraintConfig(config, allComps);
+
+ Set<String> expectedSetComp1 = new HashSet<>();
+ expectedSetComp1.addAll(Arrays.asList("comp-2", "comp-3"));
+ Set<String> expectedSetComp2 = new HashSet<>();
+ expectedSetComp2.addAll(Arrays.asList("comp-1", "comp-4"));
+ Set<String> expectedSetComp3 = new HashSet<>();
+ expectedSetComp3.addAll(Arrays.asList("comp-1", "comp-5"));
+ Assert.assertEquals("comp-1 incompatible components",
expectedSetComp1, constraintConfig.getIncompatibleComponents().get("comp-1"));
+ Assert.assertEquals("comp-2 incompatible components",
expectedSetComp2, constraintConfig.getIncompatibleComponents().get("comp-2"));
+ Assert.assertEquals("comp-3 incompatible components",
expectedSetComp3, constraintConfig.getIncompatibleComponents().get("comp-3"));
+ Assert.assertEquals("comp-1 maxNodeCoLocationCnt", (int)2,
(int)constraintConfig.getMaxCoLocationCnts().getOrDefault("comp-1", -1));
Review comment:
fixed cast
----------------------------------------------------------------
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