plan.getResourceCalculator()); used = RLESparseResourceAllocation.merge(plan.getResourceCalculator(), Resources.clone(plan.getTotalCapacity()), used, old.getResourcesOverTime(start, end), RLEOperator.subtract, start, .merge(plan.getResourceCalculator(), planTotalCapacity, instRLEQuota, used, RLEOperator.subtract, start, end); .merge(plan.getResourceCalculator(), planTotalCapacity, available, instRLEQuota, RLEOperator.min, start, end);
@Before public void setUp() { clock = mock(Clock.class); plan = mock(Plan.class); rSystem = mock(ReservationSystem.class); plans.put(PLAN_NAME, plan); rrValidator = new ReservationInputValidator(clock); when(clock.getTime()).thenReturn(1L); ResourceCalculator rCalc = new DefaultResourceCalculator(); Resource resource = Resource.newInstance(10240, 10); when(plan.getResourceCalculator()).thenReturn(rCalc); when(plan.getTotalCapacity()).thenReturn(resource); when(plan.getMaximumPeriodicity()).thenReturn( YarnConfiguration.DEFAULT_RM_RESERVATION_SYSTEM_MAX_PERIODICITY); when(rSystem.getQueueForReservation(any(ReservationId.class))).thenReturn( PLAN_NAME); when(rSystem.getPlan(PLAN_NAME)).thenReturn(plan); }
@Before public void setUp() { clock = mock(Clock.class); plan = mock(Plan.class); rSystem = mock(ReservationSystem.class); plans.put(PLAN_NAME, plan); rrValidator = new ReservationInputValidator(clock); when(clock.getTime()).thenReturn(1L); ResourceCalculator rCalc = new DefaultResourceCalculator(); Resource resource = Resource.newInstance(10240, 10); when(plan.getResourceCalculator()).thenReturn(rCalc); when(plan.getTotalCapacity()).thenReturn(resource); when(rSystem.getQueueForReservation(any(ReservationId.class))).thenReturn( PLAN_NAME); when(rSystem.getPlan(PLAN_NAME)).thenReturn(plan); }
ResourceCalculator resCalc = plan.getResourceCalculator(); Resource totCap = plan.getTotalCapacity(); long now = clock.getTime();
ResourceCalculator resCalc = plan.getResourceCalculator(); Resource totCap = plan.getTotalCapacity(); long now = clock.getTime();
ResourceCalculator resCalc = plan.getResourceCalculator(); Resource totCap = plan.getTotalCapacity(); long now = clock.getTime();
RLESparseResourceAllocation.merge(plan.getResourceCalculator(), plan.getTotalCapacity(), netAvailable, planModifications, RLEOperator.subtract, stageEarliestStart, stageDeadline); (int) Math.floor(Resources.divide(plan.getResourceCalculator(), totalCapacity, netAvailableRes, gang));
protected void initialize(Plan plan, ReservationId reservationId, ReservationDefinition reservation) throws PlanningException { // Get plan step & capacity capacity = plan.getTotalCapacity(); step = plan.getStep(); // Get job parameters (type, arrival time & deadline) jobType = reservation.getReservationRequests().getInterpreter(); jobArrival = stepRoundUp(reservation.getArrival(), step); jobDeadline = stepRoundDown(reservation.getDeadline(), step); // Initialize the plan modifications planModifications = new RLESparseResourceAllocation(plan.getResourceCalculator()); // Dirty read of plan load // planLoads are not used by other StageAllocators... and don't deal // well with huge reservation ranges planLoads = plan.getCumulativeLoadOverTime(jobArrival, jobDeadline); ReservationAllocation oldRes = plan.getReservationById(reservationId); if (oldRes != null) { planLoads = RLESparseResourceAllocation.merge( plan.getResourceCalculator(), plan.getTotalCapacity(), planLoads, oldRes.getResourcesOverTime(jobArrival, jobDeadline), RLEOperator.subtract, jobArrival, jobDeadline); } }
new RLESparseResourceAllocation(plan.getResourceCalculator());
private void validateInput(Plan plan, ReservationRequest rr, Resource totalCapacity) throws ContractValidationException { if (rr.getConcurrency() < 1) { throw new ContractValidationException("Gang Size should be >= 1"); } if (rr.getNumContainers() <= 0) { throw new ContractValidationException("Num containers should be >= 0"); } // check that gangSize and numContainers are compatible if (rr.getNumContainers() % rr.getConcurrency() != 0) { throw new ContractValidationException( "Parallelism must be an exact multiple of gang size"); } // check that the largest container request does not exceed // the cluster-wide limit for container sizes if (Resources.greaterThan(plan.getResourceCalculator(), totalCapacity, rr.getCapability(), plan.getMaximumAllocation())) { throw new ContractValidationException("Individual" + " capability requests should not exceed cluster's maxAlloc"); } }
private void validateInputStage(Plan plan, ReservationRequest rr) throws ContractValidationException { // Validate concurrency if (rr.getConcurrency() < 1) { throw new ContractValidationException("Gang Size should be >= 1"); } // Validate number of containers if (rr.getNumContainers() <= 0) { throw new ContractValidationException("Num containers should be > 0"); } // Check that gangSize and numContainers are compatible if (rr.getNumContainers() % rr.getConcurrency() != 0) { throw new ContractValidationException( "Parallelism must be an exact multiple of gang size"); } // Check that the largest container request does not exceed the cluster-wide // limit for container sizes if (Resources.greaterThan(plan.getResourceCalculator(), capacity, rr.getCapability(), plan.getMaximumAllocation())) { throw new ContractValidationException( "Individual capability requests should not exceed cluster's " + "maxAlloc"); } }
private void validateInput(Plan plan, ReservationRequest rr, Resource totalCapacity) throws ContractValidationException { if (rr.getConcurrency() < 1) { throw new ContractValidationException("Gang Size should be >= 1"); } if (rr.getNumContainers() <= 0) { throw new ContractValidationException("Num containers should be >= 0"); } // check that gangSize and numContainers are compatible if (rr.getNumContainers() % rr.getConcurrency() != 0) { throw new ContractValidationException( "Parallelism must be an exact multiple of gang size"); } // check that the largest container request does not exceed // the cluster-wide limit for container sizes if (Resources.greaterThan(plan.getResourceCalculator(), totalCapacity, rr.getCapability(), plan.getMaximumAllocation())) { throw new ContractValidationException("Individual" + " capability requests should not exceed cluster's maxAlloc"); } }
@Override public void validate(Plan plan, ReservationAllocation reservation) throws PlanningException { RLESparseResourceAllocation available = plan.getAvailableResourceOverTime( reservation.getUser(), reservation.getReservationId(), reservation.getStartTime(), reservation.getEndTime(), reservation.getPeriodicity()); // test the reservation does not exceed what is available try { RLESparseResourceAllocation ask = reservation.getResourcesOverTime( reservation.getStartTime(), reservation.getEndTime()); RLESparseResourceAllocation .merge(plan.getResourceCalculator(), plan.getTotalCapacity(), available, ask, RLESparseResourceAllocation.RLEOperator.subtractTestNonNegative, reservation.getStartTime(), reservation.getEndTime()); } catch (PlanningException p) { throw new ResourceOverCommitException( "Resources at time " + reservation.getStartTime() + " would be overcommitted by accepting reservation: " + reservation.getReservationId(), p); } }
if (Resources.greaterThan(plan.getResourceCalculator(), plan .getTotalCapacity(), Resources.subtract( Resources.add(currExistingAllocTot, currNewAlloc), currOldAlloc),
if (Resources.greaterThan(plan.getResourceCalculator(), plan .getTotalCapacity(), Resources.subtract( Resources.add(currExistingAllocTot, currNewAlloc), currOldAlloc),
plan.getResourceCalculator(), // Resource calculator
Resources.max(plan.getResourceCalculator(), plan.getTotalCapacity(), maxGangSize, Resources.multiply(rr.getCapability(), rr.getConcurrency())); if (Resources.greaterThan(plan.getResourceCalculator(), plan.getTotalCapacity(), maxGangSize, plan.getTotalCapacity()) && type != ReservationRequestInterpreter.R_ANY) {
Resources.max(plan.getResourceCalculator(), plan.getTotalCapacity(), maxGangSize, Resources.multiply(rr.getCapability(), rr.getConcurrency())); if (Resources.greaterThan(plan.getResourceCalculator(), plan.getTotalCapacity(), maxGangSize, plan.getTotalCapacity()) && type != ReservationRequestInterpreter.R_ANY) {
private void doAssertions(Plan plan, ReservationAllocation rAllocation) { ReservationId reservationID = rAllocation.getReservationId(); Assert.assertNotNull(plan.getReservationById(reservationID)); Assert.assertEquals(rAllocation, plan.getReservationById(reservationID)); Assert.assertTrue(((InMemoryPlan) plan).getAllReservations().size() == 1); Assert.assertEquals(rAllocation.getEndTime(), plan.getLastEndTime()); Assert.assertEquals(totalCapacity, plan.getTotalCapacity()); Assert.assertEquals(minAlloc, plan.getMinimumAllocation()); Assert.assertEquals(maxAlloc, plan.getMaximumAllocation()); Assert.assertEquals(resCalc, plan.getResourceCalculator()); Assert.assertEquals(planName, plan.getQueueName()); Assert.assertTrue(plan.getMoveOnExpiry()); }
private void doAssertions(Plan plan, ReservationAllocation rAllocation) { ReservationId reservationID = rAllocation.getReservationId(); Assert.assertNotNull(plan.getReservationById(reservationID)); assertEquals(rAllocation, plan.getReservationById(reservationID)); Assert.assertTrue(((InMemoryPlan) plan).getAllReservations().size() == 1); if (rAllocation.getPeriodicity() <= 0) { assertEquals(rAllocation.getEndTime(), plan.getLastEndTime()); } assertEquals(totalCapacity, plan.getTotalCapacity()); assertEquals(minAlloc, plan.getMinimumAllocation()); assertEquals(maxAlloc, plan.getMaximumAllocation()); assertEquals(resCalc, plan.getResourceCalculator()); assertEquals(planName, plan.getQueueName()); Assert.assertTrue(plan.getMoveOnExpiry()); }