private synchronized SchedulingRequestPBImpl convertFromProtoFormat( YarnProtos.SchedulingRequestProto p) { return new SchedulingRequestPBImpl(p); } }
private synchronized YarnProtos.SchedulingRequestProto convertToProtoFormat( SchedulingRequest r) { return ((SchedulingRequestPBImpl)r).getProto(); }
@Override public String toString() { return "SchedulingRequestPBImpl{" + "priority=" + getPriority() + ", allocationReqId=" + getAllocationRequestId() + ", executionType=" + getExecutionType() + ", allocationTags=" + getAllocationTags() + ", resourceSizing=" + getResourceSizing() + ", placementConstraint=" + getPlacementConstraint() + '}'; } }
@Override public ContainerRequest allocate(SchedulerRequestKey schedulerKey, NodeType type, SchedulerNode node) { writeLock.lock(); try { // Per container scheduling request, it is just a copy of existing // scheduling request with #allocations=1 SchedulingRequest containerSchedulingRequest = new SchedulingRequestPBImpl( ((SchedulingRequestPBImpl) schedulingRequest).getProto()); containerSchedulingRequest.getResourceSizing().setNumAllocations(1); // Deduct sizing decreasePendingNumAllocation(); return new ContainerRequest(containerSchedulingRequest); } finally { writeLock.unlock(); } }
@Override public Priority getPriority() { SchedulingRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.priority != null) { return this.priority; } if (!p.hasPriority()) { return null; } this.priority = convertFromProtoFormat(p.getPriority()); return this.priority; }
private void mergeLocalToBuilder() { if (this.priority != null) { builder.setPriority(convertToProtoFormat(this.priority)); } if (this.executionType != null) { builder.setExecutionType(convertToProtoFormat(this.executionType)); } if (this.allocationTags != null) { builder.clearAllocationTags(); builder.addAllAllocationTags(this.allocationTags); } if (this.resourceSizing != null) { builder.setResourceSizing(convertToProtoFormat(this.resourceSizing)); } if (this.placementConstraint != null) { builder.setPlacementConstraint( convertToProtoFormat(this.placementConstraint)); } }
private void validateAndSetSchedulingRequest(SchedulingRequest newSchedulingRequest) throws SchedulerInvalidResoureRequestException { // Check sizing exists if (newSchedulingRequest.getResourceSizing() == null || newSchedulingRequest.getResourceSizing().getResources() == null) { throwExceptionWithMetaInfo( "No ResourceSizing found in the scheduling request, please double " + "check"); } // Check execution type == GUARANTEED if (newSchedulingRequest.getExecutionType() != null && newSchedulingRequest.getExecutionType().getExecutionType() != ExecutionType.GUARANTEED) { throwExceptionWithMetaInfo( "Only GUARANTEED execution type is supported."); } this.targetNodePartition = validateAndGetTargetNodePartition( newSchedulingRequest.getPlacementConstraint()); this.schedulingRequest = new SchedulingRequestPBImpl( ((SchedulingRequestPBImpl) newSchedulingRequest).getProto()); LOG.info("Successfully added SchedulingRequest to app=" + appSchedulingInfo.getApplicationAttemptId() + " placementConstraint=[" + schedulingRequest.getPlacementConstraint() + "]. nodePartition=" + targetNodePartition); }
@Override public ResourceSizing getResourceSizing() { SchedulingRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.resourceSizing != null) { return this.resourceSizing; } if (!p.hasResourceSizing()) { return null; } this.resourceSizing = convertFromProtoFormat(p.getResourceSizing()); return this.resourceSizing; }
private SchedulingRequestProto convertToProtoFormat( SchedulingRequest t) { return ((SchedulingRequestPBImpl) t).getProto(); }
private SchedulingRequestPBImpl convertFromProtoFormat( SchedulingRequestProto p) { return new SchedulingRequestPBImpl(p); }
@Override public ExecutionTypeRequest getExecutionType() { SchedulingRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.executionType != null) { return this.executionType; } if (!p.hasExecutionType()) { return null; } this.executionType = convertFromProtoFormat(p.getExecutionType()); return this.executionType; }
@Override public PlacementConstraint getPlacementConstraint() { SchedulingRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.placementConstraint != null) { return this.placementConstraint; } if (!p.hasPlacementConstraint()) { return null; } this.placementConstraint = convertFromProtoFormat(p.getPlacementConstraint()); return this.placementConstraint; }
@Override public int hashCode() { return getProto().hashCode(); }