private Resource getUnallocatedReservedResources( ReservationAllocation reservation) { Resource resResource; Resource reservationResource = planFollower.getReservationQueueResourceIfExists(plan, reservation.getReservationId()); if (reservationResource != null) { resResource = Resources.subtract(reservation.getResourcesAtTime(now), reservationResource); } else { resResource = reservation.getResourcesAtTime(now); } return resResource; }
private Resource getUnallocatedReservedResources( ReservationAllocation reservation) { Resource resResource; Resource reservationResource = planFollower .getReservationQueueResourceIfExists (plan, reservation.getReservationId()); if (reservationResource != null) { resResource = Resources.subtract( reservation.getResourcesAtTime(now), reservationResource); } else { resResource = reservation.getResourcesAtTime(now); } return resResource; }
private Resource getUnallocatedReservedResources( ReservationAllocation reservation) { Resource resResource; Resource reservationResource = planFollower .getReservationQueueResourceIfExists (plan, reservation.getReservationId()); if (reservationResource != null) { resResource = Resources.subtract( reservation.getResourcesAtTime(now), reservationResource); } else { resResource = reservation.getResourcesAtTime(now); } return resResource; }
protected int getReservedResources(long now, Set<ReservationAllocation> currentReservations, Set<String> curReservationNames, Resource reservedResources) { int numRes = 0; if (currentReservations != null) { numRes = currentReservations.size(); for (ReservationAllocation reservation : currentReservations) { curReservationNames.add(reservation.getReservationId().toString()); Resources.addTo(reservedResources, reservation.getResourcesAtTime(now)); } } return numRes; }
protected int getReservedResources(long now, Set<ReservationAllocation> currentReservations, Set<String> curReservationNames, Resource reservedResources) { int numRes = 0; if (currentReservations != null) { numRes = currentReservations.size(); for (ReservationAllocation reservation : currentReservations) { curReservationNames.add(reservation.getReservationId().toString()); Resources.addTo(reservedResources, reservation.getResourcesAtTime(now)); } } return numRes; }
protected int getReservedResources(long now, Set<ReservationAllocation> currentReservations, Set<String> curReservationNames, Resource reservedResources) { int numRes = 0; if (currentReservations != null) { numRes = currentReservations.size(); for (ReservationAllocation reservation : currentReservations) { curReservationNames.add(reservation.getReservationId().toString()); Resources.addTo(reservedResources, reservation.getResourcesAtTime(now)); } } return numRes; }
private boolean check(ReservationAllocation alloc, long start, long end, int containers, int mem, int cores) { Resource expectedResources = Resource.newInstance(mem * containers, cores * containers); // Verify that all allocations in [start,end) equal containers * (mem,cores) for (long i = start; i < end; i++) { if (!Resources.equals(alloc.getResourcesAtTime(i), expectedResources)) { return false; } } return true; }
private boolean check(ReservationAllocation cs, long start, long end, int containers, int mem, int cores) { boolean res = true; for (long i = start; i < end; i++) { res = res && Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(mem * containers, cores * containers)); } return res; }
private boolean check(ReservationAllocation cs, long start, long end, int containers, int mem, int cores) { boolean res = true; for (long i = start; i < end; i++) { res = res && Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(mem * containers, cores * containers)); } return res; }
Resource currNewAlloc = reservation.getResourcesAtTime(t); Resource currOldAlloc = Resource.newInstance(0, 0); if (oldReservation != null) { oldReservation.getResourcesAtTime(t);
@Test public void testBlocks() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationDefinition rDef = createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length); Map<ReservationInterval, ReservationRequest> allocations = generateAllocation(start, alloc, false, false); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertFalse(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rAllocation.getResourcesAtTime(start + i)); } }
@Test public void testGangAlloaction() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationDefinition rDef = createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length); Map<ReservationInterval, ReservationRequest> allocations = generateAllocation(start, alloc, false, true); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertTrue(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rAllocation.getResourcesAtTime(start + i)); } }
@Test public void testSkyline() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 0, 5, 10, 10, 5, 0 }; int start = 100; ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition( start, start + alloc.length + 1, alloc.length); Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, true, false); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertFalse(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals( Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), rAllocation.getResourcesAtTime(start + i)); } }
@Test public void testGangAlloaction() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition( start, start + alloc.length + 1, alloc.length); boolean isGang = true; Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, false, isGang); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc, isGang); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertTrue(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rAllocation.getResourcesAtTime(start + i)); } }
@Test public void testBlocks() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition( start, start + alloc.length + 1, alloc.length); Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, false, false); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertFalse(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rAllocation.getResourcesAtTime(start + i)); } }
@Test public void testSteps() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationDefinition rDef = createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length); Map<ReservationInterval, ReservationRequest> allocations = generateAllocation(start, alloc, true, false); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertFalse(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals( Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), rAllocation.getResourcesAtTime(start + i)); } }
@Test public void testSkyline() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 0, 5, 10, 10, 5, 0 }; int start = 100; ReservationDefinition rDef = createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length); Map<ReservationInterval, ReservationRequest> allocations = generateAllocation(start, alloc, true, false); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertFalse(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals( Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), rAllocation.getResourcesAtTime(start + i)); } }
@Test public void testSteps() { ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong()); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition( start, start + alloc.length + 1, alloc.length); Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, true, false); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc); doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc); Assert.assertFalse(rAllocation.containsGangs()); for (int i = 0; i < alloc.length; i++) { Assert.assertEquals( Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), rAllocation.getResourcesAtTime(start + i)); } }
assertTrue( "Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 10, 2 * 10))); assertTrue( "Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 10, 2 * 10)));
assertTrue( "Agent-based allocation unexpected", Resources.equals(cs.getResourcesAtTime(i), Resource.newInstance(2048 * 10, 2 * 10)));