use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.
the class TestAlignedPlanner method testOrderNoGapImpossible.
@Test
public void testOrderNoGapImpossible() throws PlanningException {
// Prepare basic plan
int numJobsInScenario = initializeScenario2();
// Create reservation
ReservationDefinition rr1 = createReservationDefinition(// Job arrival time
10L, // Job deadline
15 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
20, // Concurrency
20, // Duration
step), ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
20, // Concurrency
20, // Duration
step) }, ReservationRequestInterpreter.R_ORDER_NO_GAP, "u1");
// Add reservation
try {
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID, "u1", plan, rr1);
fail();
} catch (PlanningException e) {
// Expected failure
}
// CHECK: allocation was not accepted
assertTrue("Agent-based allocation should have failed", plan.getAllReservations().size() == numJobsInScenario);
}
use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.
the class TestAlignedPlanner method testAllImpossible.
@Test
public void testAllImpossible() throws PlanningException {
// Prepare basic plan
int numJobsInScenario = initializeScenario2();
// Create reservation
ReservationDefinition rr1 = createReservationDefinition(// Job arrival time
10 * step, // Job deadline
15 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
20, // Concurrency
20, // Duration
step), ReservationRequest.newInstance(// Capability
Resource.newInstance(1024, 1), // Num containers
20, // Concurrency
20, // Duration
2 * step) }, ReservationRequestInterpreter.R_ALL, "u1");
// Add reservation
try {
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID, "u1", plan, rr1);
fail();
} catch (PlanningException e) {
// Expected failure
}
// CHECK: allocation was not accepted
assertTrue("Agent-based allocation should have failed", plan.getAllReservations().size() == numJobsInScenario);
}
use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.
the class TestGreedyReservationAgent method testSharingPolicyFeedback.
@SuppressWarnings("javadoc")
@Test
public void testSharingPolicyFeedback() throws PlanningException {
prepareBasicPlan();
// let's constraint the instantaneous allocation and see the
// policy kicking in during planning
float instConstraint = 40;
float avgConstraint = 40;
ReservationSchedulerConfiguration conf = ReservationSystemTestUtil.createConf(plan.getQueueName(), 100000, instConstraint, avgConstraint);
plan.getSharingPolicy().init(plan.getQueueName(), conf);
// create a request with a single atomic ask
ReservationDefinition rr = new ReservationDefinitionPBImpl();
rr.setArrival(5 * step);
rr.setDeadline(100 * step);
ReservationRequest r = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 20, 20, 10 * step);
ReservationRequests reqs = new ReservationRequestsPBImpl();
reqs.setReservationResources(Collections.singletonList(r));
rr.setReservationRequests(reqs);
ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID, "u3", plan, rr);
ReservationId reservationID2 = ReservationSystemTestUtil.getNewReservationId();
agent.createReservation(reservationID2, "u3", plan, rr);
ReservationDefinition rr3 = new ReservationDefinitionPBImpl();
rr3.setArrival(5 * step);
rr3.setDeadline(100 * step);
ReservationRequest r3 = ReservationRequest.newInstance(Resource.newInstance(2048, 2), 45, 45, 10 * step);
ReservationRequests reqs3 = new ReservationRequestsPBImpl();
reqs3.setReservationResources(Collections.singletonList(r3));
rr3.setReservationRequests(reqs3);
ReservationId reservationID3 = ReservationSystemTestUtil.getNewReservationId();
try {
// RR3 is simply too big to fit
agent.createReservation(reservationID3, "u3", plan, rr3);
fail();
} catch (PlanningException pe) {
// expected
}
assertTrue("Agent-based allocation failed", reservationID != null);
assertTrue("Agent-based allocation failed", plan.getAllReservations().size() == 4);
ReservationAllocation cs = plan.getReservationById(reservationID);
ReservationAllocation cs2 = plan.getReservationById(reservationID2);
ReservationAllocation cs3 = plan.getReservationById(reservationID3);
assertNotNull(cs);
assertNotNull(cs2);
assertNull(cs3);
System.out.println("--------AFTER SIMPLE ALLOCATION (queue: " + reservationID + ")----------");
System.out.println(plan.toString());
System.out.println(plan.toCumulativeString());
if (allocateLeft) {
for (long i = 5 * step; i < 15 * step; i++) {
assertTrue("Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
for (long i = 15 * step; i < 25 * step; i++) {
// RR2 is pushed out by the presence of RR
assertTrue("Agent-based allocation unexpected", Resources.equals(cs2.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
} else {
for (long i = 90 * step; i < 100 * step; i++) {
assertTrue("Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
for (long i = 80 * step; i < 90 * step; i++) {
assertTrue("Agent-based allocation unexpected", Resources.equals(cs2.getResourcesAtTime(i), Resource.newInstance(2048 * 20, 2 * 20)));
}
}
}
use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.
the class ClientRMService method submitReservation.
@Override
public ReservationSubmissionResponse submitReservation(ReservationSubmissionRequest request) throws YarnException, IOException {
// Check if reservation system is enabled
checkReservationSytem(AuditConstants.SUBMIT_RESERVATION_REQUEST);
ReservationSubmissionResponse response = recordFactory.newRecordInstance(ReservationSubmissionResponse.class);
ReservationId reservationId = request.getReservationId();
// Validate the input
Plan plan = rValidator.validateReservationSubmissionRequest(reservationSystem, request, reservationId);
ReservationAllocation allocation = plan.getReservationById(reservationId);
if (allocation != null) {
boolean isNewDefinition = !allocation.getReservationDefinition().equals(request.getReservationDefinition());
if (isNewDefinition) {
String message = "Reservation allocation already exists with the " + "reservation id " + reservationId.toString() + ", but a different" + " reservation definition was provided. Please try again with a " + "new reservation id, or consider updating the reservation instead.";
throw RPCUtil.getRemoteException(message);
} else {
return response;
}
}
// Check ACLs
String queueName = request.getQueue();
String user = checkReservationACLs(queueName, AuditConstants.SUBMIT_RESERVATION_REQUEST, null);
try {
// Try to place the reservation using the agent
boolean result = plan.getReservationAgent().createReservation(reservationId, user, plan, request.getReservationDefinition());
if (result) {
// add the reservation id to valid ones maintained by reservation
// system
reservationSystem.setQueueForReservation(reservationId, queueName);
// create the reservation synchronously if required
refreshScheduler(queueName, request.getReservationDefinition(), reservationId.toString());
// return the reservation id
}
} catch (PlanningException e) {
RMAuditLogger.logFailure(user, AuditConstants.SUBMIT_RESERVATION_REQUEST, e.getMessage(), "ClientRMService", "Unable to create the reservation: " + reservationId);
throw RPCUtil.getRemoteException(e);
}
RMAuditLogger.logSuccess(user, AuditConstants.SUBMIT_RESERVATION_REQUEST, "ClientRMService: " + reservationId);
return response;
}
use of org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException in project hadoop by apache.
the class ClientRMService method updateReservation.
@Override
public ReservationUpdateResponse updateReservation(ReservationUpdateRequest request) throws YarnException, IOException {
// Check if reservation system is enabled
checkReservationSytem(AuditConstants.UPDATE_RESERVATION_REQUEST);
ReservationUpdateResponse response = recordFactory.newRecordInstance(ReservationUpdateResponse.class);
// Validate the input
Plan plan = rValidator.validateReservationUpdateRequest(reservationSystem, request);
ReservationId reservationId = request.getReservationId();
String queueName = reservationSystem.getQueueForReservation(reservationId);
// Check ACLs
String user = checkReservationACLs(queueName, AuditConstants.UPDATE_RESERVATION_REQUEST, reservationId);
// Try to update the reservation using default agent
try {
boolean result = plan.getReservationAgent().updateReservation(reservationId, user, plan, request.getReservationDefinition());
if (!result) {
String errMsg = "Unable to update reservation: " + reservationId;
RMAuditLogger.logFailure(user, AuditConstants.UPDATE_RESERVATION_REQUEST, errMsg, "ClientRMService", errMsg);
throw RPCUtil.getRemoteException(errMsg);
}
} catch (PlanningException e) {
RMAuditLogger.logFailure(user, AuditConstants.UPDATE_RESERVATION_REQUEST, e.getMessage(), "ClientRMService", "Unable to update the reservation: " + reservationId);
throw RPCUtil.getRemoteException(e);
}
RMAuditLogger.logSuccess(user, AuditConstants.UPDATE_RESERVATION_REQUEST, "ClientRMService: " + reservationId);
return response;
}
Aggregations