use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestsInfo in project hadoop by apache.
the class RMWebServices method createReservationSubmissionRequest.
private ReservationSubmissionRequest createReservationSubmissionRequest(ReservationSubmissionRequestInfo resContext) throws IOException {
// defending against a couple of common submission format problems
if (resContext == null) {
throw new BadRequestException("Input ReservationSubmissionContext should not be null");
}
ReservationDefinitionInfo resInfo = resContext.getReservationDefinition();
if (resInfo == null) {
throw new BadRequestException("Input ReservationDefinition should not be null");
}
ReservationRequestsInfo resReqsInfo = resInfo.getReservationRequests();
if (resReqsInfo == null || resReqsInfo.getReservationRequest() == null || resReqsInfo.getReservationRequest().size() == 0) {
throw new BadRequestException("The ReservationDefinition should" + " contain at least one ReservationRequest");
}
ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
ReservationRequestInterpreter resInt = values[resReqsInfo.getReservationRequestsInterpreter()];
List<ReservationRequest> list = new ArrayList<ReservationRequest>();
for (ReservationRequestInfo resReqInfo : resReqsInfo.getReservationRequest()) {
ResourceInfo rInfo = resReqInfo.getCapability();
Resource capability = Resource.newInstance(rInfo.getMemorySize(), rInfo.getvCores());
int numContainers = resReqInfo.getNumContainers();
int minConcurrency = resReqInfo.getMinConcurrency();
long duration = resReqInfo.getDuration();
ReservationRequest rr = ReservationRequest.newInstance(capability, numContainers, minConcurrency, duration);
list.add(rr);
}
ReservationRequests reqs = ReservationRequests.newInstance(list, resInt);
ReservationDefinition rDef = ReservationDefinition.newInstance(resInfo.getArrival(), resInfo.getDeadline(), reqs, resInfo.getReservationName());
ReservationId reservationId = ReservationId.parseReservationId(resContext.getReservationId());
ReservationSubmissionRequest request = ReservationSubmissionRequest.newInstance(rDef, resContext.getQueue(), reservationId);
return request;
}
use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationRequestsInfo in project hadoop by apache.
the class RMWebServices method createReservationUpdateRequest.
private ReservationUpdateRequest createReservationUpdateRequest(ReservationUpdateRequestInfo resContext) throws IOException {
// defending against a couple of common submission format problems
if (resContext == null) {
throw new BadRequestException("Input ReservationSubmissionContext should not be null");
}
ReservationDefinitionInfo resInfo = resContext.getReservationDefinition();
if (resInfo == null) {
throw new BadRequestException("Input ReservationDefinition should not be null");
}
ReservationRequestsInfo resReqsInfo = resInfo.getReservationRequests();
if (resReqsInfo == null || resReqsInfo.getReservationRequest() == null || resReqsInfo.getReservationRequest().size() == 0) {
throw new BadRequestException("The ReservationDefinition should" + " contain at least one ReservationRequest");
}
if (resContext.getReservationId() == null) {
throw new BadRequestException("Update operations must specify an existing ReservaitonId");
}
ReservationRequestInterpreter[] values = ReservationRequestInterpreter.values();
ReservationRequestInterpreter resInt = values[resReqsInfo.getReservationRequestsInterpreter()];
List<ReservationRequest> list = new ArrayList<ReservationRequest>();
for (ReservationRequestInfo resReqInfo : resReqsInfo.getReservationRequest()) {
ResourceInfo rInfo = resReqInfo.getCapability();
Resource capability = Resource.newInstance(rInfo.getMemorySize(), rInfo.getvCores());
int numContainers = resReqInfo.getNumContainers();
int minConcurrency = resReqInfo.getMinConcurrency();
long duration = resReqInfo.getDuration();
ReservationRequest rr = ReservationRequest.newInstance(capability, numContainers, minConcurrency, duration);
list.add(rr);
}
ReservationRequests reqs = ReservationRequests.newInstance(list, resInt);
ReservationDefinition rDef = ReservationDefinition.newInstance(resInfo.getArrival(), resInfo.getDeadline(), reqs, resInfo.getReservationName());
ReservationUpdateRequest request = ReservationUpdateRequest.newInstance(rDef, ReservationId.parseReservationId(resContext.getReservationId()));
return request;
}
Aggregations