} else { placementConstraints = PlacementConstraints .targetNotIn(scope, target);
@Before public void before() { this.pcm = createPCM(); // Build appIDs, constraints, source tags, and constraint map. long ts = System.currentTimeMillis(); appId1 = BuilderUtils.newApplicationId(ts, 123); appId2 = BuilderUtils.newApplicationId(ts, 234); c1 = PlacementConstraints.build(targetIn(NODE, allocationTag("hbase-m"))); c2 = PlacementConstraints.build(targetIn(RACK, allocationTag("hbase-rs"))); c3 = PlacementConstraints .build(targetNotIn(NODE, nodeAttribute("java", "1.8"))); c4 = PlacementConstraints .build(targetCardinality(RACK, 2, 10, allocationTag("zk"))); sourceTag1 = new HashSet<>(Arrays.asList("spark")); sourceTag2 = new HashSet<>(Arrays.asList("zk")); sourceTag3 = new HashSet<>(Arrays.asList("storm")); sourceTag4 = new HashSet<>(Arrays.asList("hbase-m", "hbase-sec")); constraintMap1 = Stream .of(new SimpleEntry<>(sourceTag1, c1), new SimpleEntry<>(sourceTag2, c2)) .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); constraintMap2 = Stream.of(new SimpleEntry<>(sourceTag3, c4)) .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); }
@Test public void testNodeAntiAffinityToAttribute() { AbstractConstraint constraintExpr = targetNotIn(NODE, nodeAttribute("java", "1.8")); SingleConstraint sConstraint = (SingleConstraint) constraintExpr; Assert.assertEquals(NODE, sConstraint.getScope()); Assert.assertEquals(0, sConstraint.getMinCardinality()); Assert.assertEquals(0, sConstraint.getMaxCardinality()); Assert.assertEquals(1, sConstraint.getTargetExpressions().size()); TargetExpression tExpr = sConstraint.getTargetExpressions().iterator().next(); Assert.assertEquals("java", tExpr.getTargetKey()); Assert.assertEquals(TargetType.NODE_ATTRIBUTE, tExpr.getTargetType()); Assert.assertEquals(1, tExpr.getTargetValues().size()); Assert.assertEquals("1.8", tExpr.getTargetValues().iterator().next()); }
c2 = PlacementConstraints.build(targetIn(RACK, allocationTag("hbase-rs"))); c3 = PlacementConstraints .build(targetNotIn(NODE, allocationTag("hbase-m"))); c4 = PlacementConstraints .build(targetNotIn(RACK, allocationTag("hbase-rs"))); c5 = PlacementConstraints .build(and(targetNotIn(NODE, allocationTag("hbase-m")), maxCardinality(NODE, 3, "spark"))); c6 = PlacementConstraints
PlacementConstraints.build(targetNotIn(NODE, allocationTag("bar"))));
pcMap.put(Collections.singleton("foo"), PlacementConstraints.build( PlacementConstraints.targetNotIn(NODE, allocationTag("foo")))); pcMap.put(Collections.singleton("bar"), PlacementConstraints.build( PlacementConstraints.targetNotIn(NODE, allocationTag("foo")))); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm2, pcMap); am1.addSchedulingRequest(
Collections.singletonMap(Collections.singleton("foo"), PlacementConstraints.build( PlacementConstraints.targetNotIn(NODE, allocationTag("foo"))))); am1.addSchedulingRequest( Arrays.asList(schedulingRequest(1, 1, 1, 512, "foo"),
.targetNotIn(NODE, allocationTagWithNamespace("unknown_namespace", "hbase-m")) .build();
Collections.singleton("foo"), PlacementConstraints.build( PlacementConstraints.targetNotIn(NODE, allocationTag("foo"))) )); am1.addSchedulingRequest(
Collections.singleton("foo"), PlacementConstraints.build( PlacementConstraints.targetNotIn(NODE, allocationTag("foo"))) )); am1.addSchedulingRequest(
.allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer"), .allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer"),
public AllocateResponse allocateAppAntiAffinity( ResourceSizing resourceSizing, Priority priority, long allocationId, String namespace, Set<String> allocationTags, String... targetTags) throws Exception { return this.allocate(null, Arrays.asList(SchedulingRequest.newBuilder().executionType( ExecutionTypeRequest.newInstance(ExecutionType.GUARANTEED)) .allocationRequestId(allocationId).priority(priority) .allocationTags(allocationTags).placementConstraintExpression( PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTagWithNamespace(namespace, targetTags)) .build()) .resourceSizing(resourceSizing).build()), null); }
public AllocateResponse allocateIntraAppAntiAffinity( String nodePartition, ResourceSizing resourceSizing, Priority priority, long allocationId, String... tags) throws Exception { return this.allocate(null, Arrays.asList(SchedulingRequest.newBuilder().executionType( ExecutionTypeRequest.newInstance(ExecutionType.GUARANTEED)) .allocationRequestId(allocationId).priority(priority) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag(tags), PlacementConstraints.PlacementTargets .nodePartition(nodePartition)).build()) .resourceSizing(resourceSizing).build()), null); }
Collections.singleton("foo"), PlacementConstraints.build( PlacementConstraints.targetNotIn(NODE, allocationTag("foo"))) )); am1.addSchedulingRequest(
Map<Set<String>, PlacementConstraint> constraintMap = new HashMap<>(); PlacementConstraint constraint2 = PlacementConstraints .targetNotIn(NODE, allocationTagWithNamespace(namespace.toString(), "hbase-m")) .build();
PlacementConstraint pc = targetNotIn("node", allocationTagWithNamespace(AllocationTagNamespaceType.ALL.toString(), server1Ports)) am2.registerAppAttempt(); pc = targetNotIn("node", allocationTagWithNamespace(AllocationTagNamespaceType.ALL.toString(), server2Ports))
PlacementConstraint constraint = targetNotIn("node", allocationTag("t1")) .build(); SchedulingRequest sc = SchedulingRequest
targetNotIn(NODE, allocationTag("A", "B")));
.allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer"), .allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer"), .allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer")).build()) .allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer")).build()) .allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer")).build())
.allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer"), .allocationRequestId(10L).priority(Priority.newInstance(1)) .placementConstraintExpression(PlacementConstraints .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer"),