@Override public int compareTo(ReservationAllocation other) { // reverse order of acceptance if (this.getAcceptanceTime() > other.getAcceptanceTime()) { return -1; } if (this.getAcceptanceTime() < other.getAcceptanceTime()) { return 1; } return 0; }
@Override public boolean updateReservation(ReservationId reservationId, String user, Plan plan, ReservationDefinition contract) throws PlanningException { return computeAllocation(reservationId, user, plan, contract, plan.getReservationById(reservationId)); }
@Override public Set<ReservationAllocation> getReservationsAtTime(long tick) { return getReservations(null, new ReservationInterval(tick, tick), ""); }
@Test(expected = MismatchedUserException.class) public void testUserMismatch() throws IOException, PlanningException { // generate allocation from single tenant that exceed capacity int[] f = generateData(3600, (int) (0.5 * totCont)); ReservationId rid = ReservationSystemTestUtil.getNewReservationId(); plan.addReservation(new InMemoryReservationAllocation(rid, null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil .generateAllocation(initTime, step, f), res, minAlloc)); // trying to update a reservation with a mismatching user plan.updateReservation(new InMemoryReservationAllocation(rid, null, "u2", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil .generateAllocation(initTime, step, f), res, minAlloc)); }
@Override public void init(String reservationQueuePath, ReservationSchedulerConfiguration conf) { this.conf = conf; validWindow = this.conf.getReservationWindow(reservationQueuePath); maxInst = this.conf.getInstantaneousMaxCapacity(reservationQueuePath) / 100; maxAvg = this.conf.getAverageCapacity(reservationQueuePath) / 100; };
private void addFixedAllocation(long start, long step, int[] f) throws PlanningException { ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition( start, start + f.length * step, f.length * step); assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), rDef, "user_fixed", "dedicated", start, start + f.length * step, ReservationSystemTestUtil.generateAllocation(start, step, f), res, minAlloc), false)); }
@Override public SharingPolicy getInitializedPolicy() { String reservationQ = ReservationSystemTestUtil.getFullReservationQueueName(); conf = new CapacitySchedulerConfiguration(); SharingPolicy policy = new NoOverCommitPolicy(); policy.init(reservationQ, conf); return policy; }
private FairScheduler initializeFairScheduler() throws IOException { Configuration conf = createFSConfiguration(); ReservationSystemTestUtil.setupFSAllocationFile(ALLOC_FILE); // Setup mockRMContext = ReservationSystemTestUtil.createRMContext(conf); return ReservationSystemTestUtil .setupFairScheduler(mockRMContext, conf, 10); } }
@Override public void init(String planQueueName, ReservationSchedulerConfiguration conf) { this.lengthOfCheckZone = conf.getEnforcementWindow(planQueueName); }
private ReservationInterval computeReservationInterval( long stageEarliestStart, long stageDeadline, long dur) { ReservationInterval reservationInt; if (allocateLeft) { reservationInt = new ReservationInterval(stageEarliestStart, stageEarliestStart + dur); } else { reservationInt = new ReservationInterval(stageDeadline - dur, stageDeadline); } return reservationInt; }
public AbstractReservationSystem configureReservationSystem() { switch (getSchedulerType()) { case CAPACITY: return new CapacityReservationSystem(); case FAIR: return new FairReservationSystem(); } return null; }
public void updateSchedulerConf(Configuration conf, String newQ) throws IOException { switch (getSchedulerType()) { case CAPACITY: ReservationSystemTestUtil.updateQueueConfiguration( (CapacitySchedulerConfiguration) conf, newQ); case FAIR: ReservationSystemTestUtil.updateFSAllocationFile(ALLOC_FILE); } }
@SuppressWarnings("rawtypes") public AbstractYarnScheduler initializeScheduler() throws IOException { switch (getSchedulerType()) { case CAPACITY: return initializeCapacityScheduler(); case FAIR: return initializeFairScheduler(); } return null; }
@Override protected Queue getDefaultQueue() { return getReservationQueue("dedicated" + ReservationConstants.DEFAULT_QUEUE_SUFFIX); }
private Plan getPlanFromQueue(ReservationSystem reservationSystem, String queue, String auditConstant) throws YarnException { String nullQueueErrorMessage = "The queue is not specified." + " Please try again with a valid reservable queue."; String nullPlanErrorMessage = "The specified queue: " + queue + " is not managed by reservation system." + " Please try again with a valid reservable queue."; return getPlanFromQueue(reservationSystem, queue, auditConstant, nullQueueErrorMessage, nullPlanErrorMessage); }
public static ReservationDefinition createSimpleReservationDefinition( long arrival, long deadline, long duration, int parallelism) { return createSimpleReservationDefinition(arrival, deadline, duration, parallelism, null); }
private ReservationAllocation createReservationAllocation( ReservationId reservationID, int start, int[] alloc, String recurrenceExp) { return createReservationAllocation(reservationID, start, alloc, false, recurrenceExp); }
@Test(expected = ResourceOverCommitException.class) public void testSingleFail() throws IOException, PlanningException { // generate allocation from single tenant that exceed capacity int[] f = generateData(3600, (int) (1.1 * totCont)); plan.addReservation(new InMemoryReservationAllocation( ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil .generateAllocation(initTime, step, f), res, minAlloc)); }
@Override public int compareTo(ReservationAllocation other) { // reverse order of acceptance if (this.getAcceptanceTime() > other.getAcceptanceTime()) { return -1; } if (this.getAcceptanceTime() < other.getAcceptanceTime()) { return 1; } return 0; }
@Override public boolean updateReservation(ReservationId reservationId, String user, Plan plan, ReservationDefinition contract) throws PlanningException { return computeAllocation(reservationId, user, plan, contract, plan.getReservationById(reservationId)); }