PlacementConstraintParser.parseExpression(exprs); result.put(st, constraint.build());
Assert.assertEquals("foo", tag1.getTag()); Assert.assertEquals(3, tag1.getNumOfAllocations()); expectedPc1 = targetNotIn("node", allocationTag("foo")).build(); actualPc1 = result.values().iterator().next(); Assert.assertEquals(expectedPc1, actualPc1); Assert.assertEquals("foo", tag1.getTag()); Assert.assertEquals(3, tag1.getNumOfAllocations()); expectedPc1 = targetNotIn("node", allocationTag("foo")).build(); actualPc1 = result.values().iterator().next(); Assert.assertEquals(expectedPc1, actualPc1); Assert.assertEquals("foo", tag1.getTag()); Assert.assertEquals(10, tag1.getNumOfAllocations()); expectedPc1 = cardinality("node", 0, 100, "foo", "bar").build(); Assert.assertEquals(expectedPc1, result.values().iterator().next()); Assert.assertEquals(2, tag2.getNumOfAllocations()); Iterator<PlacementConstraint> valueIt = result.values().iterator(); expectedPc1 = targetNotIn("node", allocationTag("foo")).build(); expectedPc2 = targetIn("node", allocationTag("foo")).build(); Assert.assertEquals(expectedPc1, valueIt.next()); Assert.assertEquals(expectedPc2, valueIt.next()); targetIn("node", allocationTag("moo")))).build(); Assert.assertEquals(actualPc1, expectedPc1); expectedPc2 = targetNotIn("node", allocationTag("foo")).build(); Assert.assertEquals(expectedPc2, actualPc2);
.targetNotIn(NODE, allocationTagWithNamespace("unknown_namespace", "hbase-m")) .build(); Set<String> srcTags1 = new HashSet<>(); srcTags1.add("app1");
.build(); am.addSchedulingRequest( ImmutableList.of( new TargetApplicationsNamespace.AppID(app5Id).toString(), "foo")) .build(); am1.addSchedulingRequest( ImmutableList.of( new TargetApplicationsNamespace.AppTag("xyz").toString(), "foo")) .build(); am2.addSchedulingRequest( ImmutableList.of( 1, 1, "foo").build(); am3.addSchedulingRequest( ImmutableList.of(
mergedConstraint = (And) constraint.getConstraintExpr(); Assert.assertEquals(1, mergedConstraint.getChildren().size()); Assert.assertEquals(c1, mergedConstraint.getChildren().get(0).build()); Assert.assertEquals(c1, mergedConstraint.getChildren().get(0).build()); pcm.unregisterApplication(appId1); Assert.assertEquals(c1, mergedConstraint.getChildren().get(0).build()); pcm.removeGlobalConstraint(sourceTag1);
.nodeAttribute("java", "1.8"), PlacementConstraints.PlacementTargets.nodePartition("")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build(); .nodeAttribute("python", "3"), PlacementConstraints.PlacementTargets.nodePartition("")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build();
.build(); SchedulingRequest sc = SchedulingRequest .newInstance(0, Priority.newInstance(1),
.allocationTag("mapper", "reducer"), PlacementConstraints.PlacementTargets.nodePartition("")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build(); .allocationTag("mapper"), PlacementConstraints.PlacementTargets.nodePartition("")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build(); .allocationTag("mapper", "reducer"), PlacementConstraints.PlacementTargets.nodePartition("")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build();
.allocationTag("mapper", "reducer"), PlacementConstraints.PlacementTargets.nodePartition("")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build()); .allocationTag("mapper", "reducer"), PlacementConstraints.PlacementTargets.nodePartition("x")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build()); .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer")).build()) .resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer")).build()) .resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .targetNotIn(PlacementConstraints.NODE, PlacementConstraints.PlacementTargets .allocationTag("mapper", "reducer")).build()) .build(), true);
.targetNotIn(NODE, allocationTagWithNamespace(namespace.toString(), "hbase-m")) .build(); Set<String> srcTags2 = ImmutableSet.of("app2"); constraintMap.put(srcTags2, constraint2);
.allocationTag("mapper", "reducer"), PlacementConstraints.PlacementTargets.nodePartition("")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build(); .allocationTag("mapper", "reducer"), PlacementConstraints.PlacementTargets.nodePartition("x")) .build()).resourceSizing( ResourceSizing.newInstance(1, Resource.newInstance(1024, 1))) .build();
/** * Returns true if all child constraints are satisfied. * @param appId application id * @param constraint Or constraint * @param node node * @param atm allocation tags manager * @return true if all child constraints are satisfied, false otherwise * @throws InvalidAllocationTagsQueryException */ private static boolean canSatisfyAndConstraint(ApplicationId appId, And constraint, SchedulerNode node, AllocationTagsManager atm) throws InvalidAllocationTagsQueryException { // Iterate over the constraints tree, if found any child constraint // isn't satisfied, return false. for (AbstractConstraint child : constraint.getChildren()) { if(!canSatisfyConstraints(appId, child.build(), node, atm)) { return false; } } return true; }
/** * Returns true as long as any of child constraint is satisfied. * @param appId application id * @param constraint Or constraint * @param node node * @param atm allocation tags manager * @return true if any child constraint is satisfied, false otherwise * @throws InvalidAllocationTagsQueryException */ private static boolean canSatisfyOrConstraint(ApplicationId appId, Or constraint, SchedulerNode node, AllocationTagsManager atm) throws InvalidAllocationTagsQueryException { for (AbstractConstraint child : constraint.getChildren()) { if (canSatisfyConstraints(appId, child.build(), node, atm)) { return true; } } return false; }
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); }
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); }
/** * Creates a {@link PlacementConstraint} given a constraint expression. * * @param constraintExpr the constraint expression * @return the placement constraint */ public static PlacementConstraint build(AbstractConstraint constraintExpr) { return constraintExpr.build(); } }