use of org.apache.hadoop.yarn.api.records.ReservationId 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.api.records.ReservationId in project hadoop by apache.
the class ReservationACLsTestBase method verifySubmitReservationFailure.
private void verifySubmitReservationFailure(String submitter, String queueName) throws Exception {
try {
ReservationId reservationId = createReservation(submitter);
submitReservation(submitter, queueName, reservationId);
Assert.fail("Submit reservation by the enemy should fail!");
} catch (YarnException e) {
handleAdministerException(e, submitter, queueName, ReservationACL.SUBMIT_RESERVATIONS.name());
}
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class ReservationACLsTestBase method verifyUpdateReservationFailure.
private void verifyUpdateReservationFailure(String updater, String originalSubmitter, String queueName) throws Exception {
ReservationId reservationId = createReservation(originalSubmitter);
submitReservation(originalSubmitter, queueName, reservationId);
final ReservationUpdateRequest updateRequest = ReservationUpdateRequest.newInstance(makeSimpleReservationDefinition(), reservationId);
ApplicationClientProtocol unauthorizedClient = getRMClientForUser(updater);
try {
unauthorizedClient.updateReservation(updateRequest);
Assert.fail("Reservation updating by the enemy should fail.");
} catch (YarnException e) {
handleAdministerException(e, updater, queueName, ReservationACL.ADMINISTER_RESERVATIONS.name());
}
deleteReservation(originalSubmitter, reservationId);
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class AbstractReservationSystem method loadPlan.
private void loadPlan(String planName, Map<ReservationId, ReservationAllocationStateProto> reservations) throws PlanningException {
Plan plan = plans.get(planName);
Resource minAllocation = getMinAllocation();
ResourceCalculator rescCalculator = getResourceCalculator();
for (Entry<ReservationId, ReservationAllocationStateProto> currentReservation : reservations.entrySet()) {
plan.addReservation(ReservationSystemUtil.toInMemoryAllocation(planName, currentReservation.getKey(), currentReservation.getValue(), minAllocation, rescCalculator), true);
resQMap.put(currentReservation.getKey(), planName);
}
LOG.info("Recovered reservations for Plan: {}", planName);
}
use of org.apache.hadoop.yarn.api.records.ReservationId in project hadoop by apache.
the class AbstractReservationSystem method getNewReservationId.
@Override
public ReservationId getNewReservationId() {
writeLock.lock();
try {
ReservationId resId = ReservationId.newInstance(ResourceManager.getClusterTimeStamp(), resCounter.incrementAndGet());
LOG.info("Allocated new reservationId: " + resId);
return resId;
} finally {
writeLock.unlock();
}
}
Aggregations