YARN-9921. Issue in PlacementConstraint when YARN Service AM retries allocation on component failure. Contributed by Tarun Parimi

This commit is contained in:
Zhankun Tang 2019-10-24 10:05:00 +08:00
parent 1d5d7d0989
commit fd84ca5161
2 changed files with 37 additions and 2 deletions

View File

@ -277,8 +277,27 @@ public boolean equals(Object other) {
if (other == null) { if (other == null) {
return false; return false;
} }
if (other.getClass().isAssignableFrom(this.getClass())) { if (other instanceof SchedulingRequest) {
return this.getProto().equals(this.getClass().cast(other).getProto()); if (this == other) {
return true;
}
SchedulingRequest that = (SchedulingRequest) other;
if (getAllocationRequestId() != that.getAllocationRequestId()) {
return false;
}
if (!getAllocationTags().equals(that.getAllocationTags())) {
return false;
}
if (!getPriority().equals(that.getPriority())) {
return false;
}
if(!getExecutionType().equals(that.getExecutionType())) {
return false;
}
if(!getResourceSizing().equals(that.getResourceSizing())) {
return false;
}
return getPlacementConstraint().equals(that.getPlacementConstraint());
} }
return false; return false;
} }

View File

@ -226,6 +226,22 @@ public void testSchedulingRequestUpdate() {
schedulingRequest.getResourceSizing().setNumAllocations(10); schedulingRequest.getResourceSizing().setNumAllocations(10);
allocator.updatePendingAsk(schedulerRequestKey, schedulingRequest, false); allocator.updatePendingAsk(schedulerRequestKey, schedulingRequest, false);
// Update allocator with a newly constructed scheduling request different at
// #allocations, should succeeded.
SchedulingRequest newSchedulingRequest =
SchedulingRequest.newBuilder().executionType(
ExecutionTypeRequest.newInstance(ExecutionType.GUARANTEED))
.allocationRequestId(10L).priority(Priority.newInstance(1))
.placementConstraintExpression(PlacementConstraints
.targetNotIn(PlacementConstraints.NODE,
PlacementConstraints.PlacementTargets.nodePartition(""),
PlacementConstraints.PlacementTargets
.allocationTag("mapper", "reducer"))
.build()).resourceSizing(
ResourceSizing.newInstance(11, Resource.newInstance(1024, 1)))
.build();
allocator.updatePendingAsk(schedulerRequestKey, newSchedulingRequest, false);
// Update allocator with scheduling request different at resource, // Update allocator with scheduling request different at resource,
// should failed. // should failed.
schedulingRequest.getResourceSizing().setResources( schedulingRequest.getResourceSizing().setResources(