InMemoryPlan implements Plan { @Override public boolean deleteReservation(ReservationId reservationID) { writeLock.lock(); try { ReservationAllocation reservation = getReservationById(reservationID); if (reservation == null) { String errMsg = "The specified Reservation with ID " + reservationID + " does not exist in the plan"; LOG.error(errMsg); throw new IllegalArgumentException(errMsg); } return removeReservation(reservation); } finally { writeLock.unlock(); } } InMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy,
      ReservationAgent agent, Resource totalCapacity, long step,
      ResourceCalculator resCalc, Resource minAlloc, Resource maxAlloc,
      String queueName, Planner replanner, boolean getMoveOnExpiry,
      RMContext rmContext);  InMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy,
      ReservationAgent agent, Resource totalCapacity, long step,
      ResourceCalculator resCalc, Resource minAlloc, Resource maxAlloc,
      String queueName, Planner replanner, boolean getMoveOnExpiry,
      RMContext rmContext, Clock clock); @Override QueueMetrics getQueueMetrics(); Set<ReservationAllocation> getAllReservations(); @Override boolean addReservation(ReservationAllocation reservation,
      boolean isRecovering); @Override boolean updateReservation(ReservationAllocation reservation); @Override boolean deleteReservation(ReservationId reservationID); @Override void archiveCompletedReservations(long tick); @Override Set<ReservationAllocation> getReservationsAtTime(long tick); @Override long getStep(); @Override SharingPolicy getSharingPolicy(); @Override ReservationAgent getReservationAgent(); @Override RLESparseResourceAllocation getReservationCountForUserOverTime(
      String user, long start, long end); @Override RLESparseResourceAllocation getConsumptionForUserOverTime(String user,
      long start, long end); @Override Resource getTotalCommittedResources(long t); @Override ReservationAllocation getReservationById(ReservationId reservationID); @Override Resource getTotalCapacity(); @Override RLESparseResourceAllocation getAvailableResourceOverTime(String user,
      ReservationId oldId, long start, long end); @Override Resource getMinimumAllocation(); @Override void setTotalCapacity(Resource cap); long getEarliestStartTime(); @Override long getLastEndTime(); @Override ResourceCalculator getResourceCalculator(); @Override String getQueueName(); @Override Resource getMaximumAllocation(); String toCumulativeString(); @Override Planner getReplanner(); @Override boolean getMoveOnExpiry(); @Override String toString(); @Override Set<ReservationAllocation> getReservationByUserAtTime(String user,
      long t);  }
@Test public void testDeleteReservation() { Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L, resCalc, minAlloc, maxAlloc, planName, replanner, true, context); ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId(); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; Map<ReservationInterval, ReservationRequest> allocations = generateAllocation(start, alloc, true); ReservationDefinition rDef = createSimpleReservationDefinition(start, start + alloc.length, alloc.length, allocations.values()); Map<ReservationInterval, Resource> allocs = ReservationSystemUtil.toResources(allocations); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length, allocs, resCalc, minAlloc); Assert.assertNull(plan.getReservationById(reservationID)); try { plan.addReservation(rAllocation, false); } catch (PlanningException e) { Assert.fail(e.getMessage()); } doAssertions(plan, rAllocation); RLESparseResourceAllocation userCons = plan.getConsumptionForUserOverTime(user, start, start + alloc.length); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals( Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), plan.getTotalCommittedResources(start + i)); Assert.assertEquals( Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), userCons.getCapacityAtTime(start + i)); } try { plan.deleteReservation(reservationID); } catch (PlanningException e) { Assert.fail(e.getMessage()); } Assert.assertNull(plan.getReservationById(reservationID)); userCons = plan.getConsumptionForUserOverTime(user, start, start + alloc.length); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(0, 0), plan.getTotalCommittedResources(start + i)); Assert.assertEquals(Resource.newInstance(0, 0), userCons.getCapacityAtTime(start + i)); } }