|
@@ -40,7 +40,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.reservation.planning.Planne
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.planning.ReservationAgent;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.planning.ReservationAgent;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
|
|
import org.apache.hadoop.yarn.util.Clock;
|
|
import org.apache.hadoop.yarn.util.Clock;
|
|
-import org.apache.hadoop.yarn.util.UTCClock;
|
|
|
|
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
|
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
|
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
|
|
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
|
|
import org.junit.After;
|
|
import org.junit.After;
|
|
@@ -48,10 +47,6 @@ import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
-/**
|
|
|
|
- * Testing the class {@link InMemoryPlan}.
|
|
|
|
- */
|
|
|
|
-@SuppressWarnings("checkstyle:nowhitespaceafter")
|
|
|
|
public class TestInMemoryPlan {
|
|
public class TestInMemoryPlan {
|
|
|
|
|
|
private String user = "yarn";
|
|
private String user = "yarn";
|
|
@@ -67,7 +62,6 @@ public class TestInMemoryPlan {
|
|
private ReservationAgent agent;
|
|
private ReservationAgent agent;
|
|
private Planner replanner;
|
|
private Planner replanner;
|
|
private RMContext context;
|
|
private RMContext context;
|
|
- private long maxPeriodicity;
|
|
|
|
|
|
|
|
@Before
|
|
@Before
|
|
public void setUp() throws PlanningException {
|
|
public void setUp() throws PlanningException {
|
|
@@ -78,7 +72,7 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
clock = mock(Clock.class);
|
|
clock = mock(Clock.class);
|
|
queueMetrics = mock(QueueMetrics.class);
|
|
queueMetrics = mock(QueueMetrics.class);
|
|
- policy = new NoOverCommitPolicy();
|
|
|
|
|
|
+ policy = mock(SharingPolicy.class);
|
|
replanner = mock(Planner.class);
|
|
replanner = mock(Planner.class);
|
|
|
|
|
|
when(clock.getTime()).thenReturn(1L);
|
|
when(clock.getTime()).thenReturn(1L);
|
|
@@ -101,41 +95,15 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testAddReservation() {
|
|
public void testAddReservation() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
- Assert.assertNull(plan.getReservationById(reservationID));
|
|
|
|
- try {
|
|
|
|
- plan.addReservation(rAllocation, false);
|
|
|
|
- } catch (PlanningException e) {
|
|
|
|
- Assert.fail(e.getMessage());
|
|
|
|
- }
|
|
|
|
- doAssertions(plan, rAllocation);
|
|
|
|
- checkAllocation(plan, alloc, start, 0);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testAddPeriodicReservation() throws PlanningException {
|
|
|
|
-
|
|
|
|
- maxPeriodicity = 100;
|
|
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, maxPeriodicity,
|
|
|
|
- context, new UTCClock());
|
|
|
|
-
|
|
|
|
- ReservationId reservationID =
|
|
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 50 };
|
|
|
|
- int start = 10;
|
|
|
|
- long period = 20;
|
|
|
|
- ReservationAllocation rAllocation = createReservationAllocation(
|
|
|
|
- reservationID, start, alloc, String.valueOf(period));
|
|
|
|
- // use periodicity of 1hr
|
|
|
|
- rAllocation.setPeriodicity(period);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -143,54 +111,32 @@ public class TestInMemoryPlan {
|
|
Assert.fail(e.getMessage());
|
|
Assert.fail(e.getMessage());
|
|
}
|
|
}
|
|
doAssertions(plan, rAllocation);
|
|
doAssertions(plan, rAllocation);
|
|
- checkAllocation(plan, alloc, start, period);
|
|
|
|
-
|
|
|
|
- RLESparseResourceAllocation available =
|
|
|
|
- plan.getAvailableResourceOverTime(user, reservationID, 150, 330, 50);
|
|
|
|
- System.out.println(available);
|
|
|
|
|
|
+ checkAllocation(plan, alloc, start);
|
|
}
|
|
}
|
|
|
|
|
|
- private void checkAllocation(Plan plan, int[] alloc, int start,
|
|
|
|
- long periodicity) {
|
|
|
|
- long end = start + alloc.length;
|
|
|
|
- if (periodicity > 0) {
|
|
|
|
- end = end + maxPeriodicity;
|
|
|
|
- }
|
|
|
|
|
|
+ private void checkAllocation(Plan plan, int[] alloc, int start) {
|
|
RLESparseResourceAllocation userCons =
|
|
RLESparseResourceAllocation userCons =
|
|
- plan.getConsumptionForUserOverTime(user, start, end * 3);
|
|
|
|
|
|
+ plan.getConsumptionForUserOverTime(user, start, start + alloc.length);
|
|
|
|
|
|
for (int i = 0; i < alloc.length; i++) {
|
|
for (int i = 0; i < alloc.length; i++) {
|
|
- // only one instance for non-periodic reservation
|
|
|
|
- if (periodicity <= 0) {
|
|
|
|
- Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])),
|
|
|
|
- plan.getTotalCommittedResources(start + i));
|
|
|
|
- Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])),
|
|
|
|
- userCons.getCapacityAtTime(start + i));
|
|
|
|
- } else {
|
|
|
|
- // periodic reservations should repeat
|
|
|
|
- long y = 0;
|
|
|
|
- Resource res = Resource.newInstance(1024 * (alloc[i]), (alloc[i]));
|
|
|
|
- while (y <= end * 2) {
|
|
|
|
- Assert.assertEquals("At time: " + start + i + y, res,
|
|
|
|
- plan.getTotalCommittedResources(start + i + y));
|
|
|
|
- Assert.assertEquals(" At time: " + (start + i + y), res,
|
|
|
|
- userCons.getCapacityAtTime(start + i + y));
|
|
|
|
- y = y + periodicity;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])),
|
|
|
|
+ plan.getTotalCommittedResources(start + i));
|
|
|
|
+ Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])),
|
|
|
|
+ userCons.getCapacityAtTime(start + i));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testAddEmptyReservation() {
|
|
public void testAddEmptyReservation() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
int[] alloc = {};
|
|
int[] alloc = {};
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -202,14 +148,15 @@ public class TestInMemoryPlan {
|
|
@Test
|
|
@Test
|
|
public void testAddReservationAlreadyExists() {
|
|
public void testAddReservationAlreadyExists() {
|
|
// First add a reservation
|
|
// First add a reservation
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -217,7 +164,7 @@ public class TestInMemoryPlan {
|
|
Assert.fail(e.getMessage());
|
|
Assert.fail(e.getMessage());
|
|
}
|
|
}
|
|
doAssertions(plan, rAllocation);
|
|
doAssertions(plan, rAllocation);
|
|
- checkAllocation(plan, alloc, start, 0);
|
|
|
|
|
|
+ checkAllocation(plan, alloc, start);
|
|
|
|
|
|
// Try to add it again
|
|
// Try to add it again
|
|
try {
|
|
try {
|
|
@@ -233,15 +180,16 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testUpdateReservation() {
|
|
public void testUpdateReservation() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
// First add a reservation
|
|
// First add a reservation
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -262,8 +210,8 @@ public class TestInMemoryPlan {
|
|
// Now update it
|
|
// Now update it
|
|
start = 110;
|
|
start = 110;
|
|
int[] updatedAlloc = { 0, 5, 10, 10, 5, 0 };
|
|
int[] updatedAlloc = { 0, 5, 10, 10, 5, 0 };
|
|
- rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, updatedAlloc, true);
|
|
|
|
|
|
+ rAllocation = createReservationAllocation(reservationID, start,
|
|
|
|
+ updatedAlloc, true);
|
|
try {
|
|
try {
|
|
plan.updateReservation(rAllocation);
|
|
plan.updateReservation(rAllocation);
|
|
} catch (PlanningException e) {
|
|
} catch (PlanningException e) {
|
|
@@ -271,71 +219,32 @@ public class TestInMemoryPlan {
|
|
}
|
|
}
|
|
doAssertions(plan, rAllocation);
|
|
doAssertions(plan, rAllocation);
|
|
|
|
|
|
- userCons = plan.getConsumptionForUserOverTime(user, start,
|
|
|
|
- start + updatedAlloc.length);
|
|
|
|
|
|
+ userCons =
|
|
|
|
+ plan.getConsumptionForUserOverTime(user, start, start
|
|
|
|
+ + updatedAlloc.length);
|
|
|
|
|
|
for (int i = 0; i < updatedAlloc.length; i++) {
|
|
for (int i = 0; i < updatedAlloc.length; i++) {
|
|
- Assert.assertEquals(Resource.newInstance(1024 * (updatedAlloc[i] + i),
|
|
|
|
- updatedAlloc[i] + i), plan.getTotalCommittedResources(start + i));
|
|
|
|
- Assert.assertEquals(Resource.newInstance(1024 * (updatedAlloc[i] + i),
|
|
|
|
- updatedAlloc[i] + i), userCons.getCapacityAtTime(start + i));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testUpdatePeriodicReservation() {
|
|
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
- // First add a reservation
|
|
|
|
- ReservationId reservationID =
|
|
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 20 };
|
|
|
|
- int start = 100;
|
|
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
- // use periodicity of 1hr
|
|
|
|
- long period = 3600000;
|
|
|
|
- rAllocation.getReservationDefinition()
|
|
|
|
- .setRecurrenceExpression(String.valueOf(period));
|
|
|
|
- rAllocation.setPeriodicity(period);
|
|
|
|
- Assert.assertNull(plan.getReservationById(reservationID));
|
|
|
|
- try {
|
|
|
|
- plan.addReservation(rAllocation, false);
|
|
|
|
- } catch (PlanningException e) {
|
|
|
|
- Assert.fail(e.getMessage());
|
|
|
|
- }
|
|
|
|
- System.out.println(plan.toString());
|
|
|
|
- doAssertions(plan, rAllocation);
|
|
|
|
- checkAllocation(plan, alloc, start, period);
|
|
|
|
-
|
|
|
|
- // Now update it
|
|
|
|
- start = 110;
|
|
|
|
- int[] updatedAlloc = { 30, 40, 50 };
|
|
|
|
- rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, updatedAlloc);
|
|
|
|
- rAllocation.getReservationDefinition()
|
|
|
|
- .setRecurrenceExpression(String.valueOf(period));
|
|
|
|
- rAllocation.setPeriodicity(period);
|
|
|
|
- try {
|
|
|
|
- plan.updateReservation(rAllocation);
|
|
|
|
- } catch (PlanningException e) {
|
|
|
|
- Assert.fail(e.getMessage());
|
|
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ Resource.newInstance(1024 * (updatedAlloc[i] + i), updatedAlloc[i]
|
|
|
|
+ + i), plan.getTotalCommittedResources(start + i));
|
|
|
|
+ Assert.assertEquals(
|
|
|
|
+ Resource.newInstance(1024 * (updatedAlloc[i] + i), updatedAlloc[i]
|
|
|
|
+ + i), userCons.getCapacityAtTime(start + i));
|
|
}
|
|
}
|
|
- doAssertions(plan, rAllocation);
|
|
|
|
- checkAllocation(plan, updatedAlloc, start, period);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testUpdateNonExistingReservation() {
|
|
public void testUpdateNonExistingReservation() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
// Try to update a reservation without adding
|
|
// Try to update a reservation without adding
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int start = 100;
|
|
int start = 100;
|
|
ReservationAllocation rAllocation =
|
|
ReservationAllocation rAllocation =
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ createReservationAllocation(reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.updateReservation(rAllocation);
|
|
plan.updateReservation(rAllocation);
|
|
@@ -351,14 +260,15 @@ public class TestInMemoryPlan {
|
|
@Test
|
|
@Test
|
|
public void testDeleteReservation() {
|
|
public void testDeleteReservation() {
|
|
// First add a reservation
|
|
// First add a reservation
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
int start = 100;
|
|
int start = 100;
|
|
ReservationAllocation rAllocation =
|
|
ReservationAllocation rAllocation =
|
|
- createReservationAllocation(reservationID, start, alloc, true);
|
|
|
|
|
|
+ createReservationAllocation(reservationID, start, alloc, true);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -396,47 +306,11 @@ public class TestInMemoryPlan {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
|
- public void testDeletePeriodicReservation() {
|
|
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
- // First add a reservation
|
|
|
|
- ReservationId reservationID =
|
|
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 20 };
|
|
|
|
- int start = 100;
|
|
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
- // use periodicity of 1hr
|
|
|
|
- long period = 3600000;
|
|
|
|
- rAllocation.getReservationDefinition()
|
|
|
|
- .setRecurrenceExpression(String.valueOf(period));
|
|
|
|
- rAllocation.setPeriodicity(period);
|
|
|
|
- Assert.assertNull(plan.getReservationById(reservationID));
|
|
|
|
- try {
|
|
|
|
- plan.addReservation(rAllocation, false);
|
|
|
|
- } catch (PlanningException e) {
|
|
|
|
- Assert.fail(e.getMessage());
|
|
|
|
- }
|
|
|
|
- System.out.println(plan.toString());
|
|
|
|
- doAssertions(plan, rAllocation);
|
|
|
|
- checkAllocation(plan, alloc, start, period);
|
|
|
|
-
|
|
|
|
- // Now delete it
|
|
|
|
- try {
|
|
|
|
- plan.deleteReservation(reservationID);
|
|
|
|
- } catch (PlanningException e) {
|
|
|
|
- Assert.fail(e.getMessage());
|
|
|
|
- }
|
|
|
|
- Assert.assertNull(plan.getReservationById(reservationID));
|
|
|
|
- System.out.print(plan);
|
|
|
|
- checkAllocation(plan, new int[] { 0, 0 }, start, period);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Test
|
|
@Test
|
|
public void testDeleteNonExistingReservation() {
|
|
public void testDeleteNonExistingReservation() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
// Try to delete a reservation without adding
|
|
// Try to delete a reservation without adding
|
|
@@ -454,9 +328,8 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testArchiveCompletedReservations() {
|
|
public void testArchiveCompletedReservations() {
|
|
- SharingPolicy sharingPolicy = mock(SharingPolicy.class);
|
|
|
|
Plan plan =
|
|
Plan plan =
|
|
- new InMemoryPlan(queueMetrics, sharingPolicy, agent, totalCapacity, 1L,
|
|
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID1 =
|
|
ReservationId reservationID1 =
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
@@ -464,7 +337,7 @@ public class TestInMemoryPlan {
|
|
int[] alloc1 = { 10, 10, 10, 10, 10, 10 };
|
|
int[] alloc1 = { 10, 10, 10, 10, 10, 10 };
|
|
int start = 100;
|
|
int start = 100;
|
|
ReservationAllocation rAllocation =
|
|
ReservationAllocation rAllocation =
|
|
- createReservationAllocation(reservationID1, start, alloc1);
|
|
|
|
|
|
+ createReservationAllocation(reservationID1, start, alloc1);
|
|
Assert.assertNull(plan.getReservationById(reservationID1));
|
|
Assert.assertNull(plan.getReservationById(reservationID1));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -472,14 +345,15 @@ public class TestInMemoryPlan {
|
|
Assert.fail(e.getMessage());
|
|
Assert.fail(e.getMessage());
|
|
}
|
|
}
|
|
doAssertions(plan, rAllocation);
|
|
doAssertions(plan, rAllocation);
|
|
- checkAllocation(plan, alloc1, start, 0);
|
|
|
|
|
|
+ checkAllocation(plan, alloc1, start);
|
|
|
|
+
|
|
|
|
|
|
// Now add another one
|
|
// Now add another one
|
|
ReservationId reservationID2 =
|
|
ReservationId reservationID2 =
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
ReservationSystemTestUtil.getNewReservationId();
|
|
int[] alloc2 = { 0, 5, 10, 5, 0 };
|
|
int[] alloc2 = { 0, 5, 10, 5, 0 };
|
|
rAllocation =
|
|
rAllocation =
|
|
- createReservationAllocation(reservationID2, start, alloc2, true);
|
|
|
|
|
|
+ createReservationAllocation(reservationID2, start, alloc2, true);
|
|
Assert.assertNull(plan.getReservationById(reservationID2));
|
|
Assert.assertNull(plan.getReservationById(reservationID2));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -493,18 +367,16 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
for (int i = 0; i < alloc2.length; i++) {
|
|
for (int i = 0; i < alloc2.length; i++) {
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
- Resource.newInstance(1024 * (alloc1[i] + alloc2[i] + i),
|
|
|
|
- alloc1[i] + alloc2[i] + i),
|
|
|
|
- plan.getTotalCommittedResources(start + i));
|
|
|
|
|
|
+ Resource.newInstance(1024 * (alloc1[i] + alloc2[i] + i), alloc1[i]
|
|
|
|
+ + alloc2[i] + i), plan.getTotalCommittedResources(start + i));
|
|
Assert.assertEquals(
|
|
Assert.assertEquals(
|
|
- Resource.newInstance(1024 * (alloc1[i] + alloc2[i] + i),
|
|
|
|
- alloc1[i] + alloc2[i] + i),
|
|
|
|
- userCons.getCapacityAtTime(start + i));
|
|
|
|
|
|
+ Resource.newInstance(1024 * (alloc1[i] + alloc2[i] + i), alloc1[i]
|
|
|
|
+ + alloc2[i] + i), userCons.getCapacityAtTime(start + i));
|
|
}
|
|
}
|
|
|
|
|
|
// Now archive completed reservations
|
|
// Now archive completed reservations
|
|
when(clock.getTime()).thenReturn(106L);
|
|
when(clock.getTime()).thenReturn(106L);
|
|
- when(sharingPolicy.getValidWindow()).thenReturn(1L);
|
|
|
|
|
|
+ when(policy.getValidWindow()).thenReturn(1L);
|
|
try {
|
|
try {
|
|
// will only remove 2nd reservation as only that has fallen out of the
|
|
// will only remove 2nd reservation as only that has fallen out of the
|
|
// archival window
|
|
// archival window
|
|
@@ -514,7 +386,7 @@ public class TestInMemoryPlan {
|
|
}
|
|
}
|
|
Assert.assertNotNull(plan.getReservationById(reservationID1));
|
|
Assert.assertNotNull(plan.getReservationById(reservationID1));
|
|
Assert.assertNull(plan.getReservationById(reservationID2));
|
|
Assert.assertNull(plan.getReservationById(reservationID2));
|
|
- checkAllocation(plan, alloc1, start, 0);
|
|
|
|
|
|
+ checkAllocation(plan, alloc1, start);
|
|
|
|
|
|
when(clock.getTime()).thenReturn(107L);
|
|
when(clock.getTime()).thenReturn(107L);
|
|
try {
|
|
try {
|
|
@@ -539,14 +411,15 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testGetReservationsById() {
|
|
public void testGetReservationsById() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
+ int[] alloc = {10, 10, 10, 10, 10, 10};
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -556,30 +429,31 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
// Verify that get by reservation id works.
|
|
// Verify that get by reservation id works.
|
|
Set<ReservationAllocation> rAllocations =
|
|
Set<ReservationAllocation> rAllocations =
|
|
- plan.getReservations(reservationID, null, "");
|
|
|
|
|
|
+ plan.getReservations(reservationID, null, "");
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
- Assert.assertTrue(rAllocation
|
|
|
|
- .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
+ Assert.assertTrue(rAllocation.compareTo(
|
|
|
|
+ (ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
// Verify that get by reservation id works even when time range
|
|
// Verify that get by reservation id works even when time range
|
|
// and user is invalid.
|
|
// and user is invalid.
|
|
ReservationInterval interval = new ReservationInterval(0, 0);
|
|
ReservationInterval interval = new ReservationInterval(0, 0);
|
|
rAllocations = plan.getReservations(reservationID, interval, "invalid");
|
|
rAllocations = plan.getReservations(reservationID, interval, "invalid");
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
- Assert.assertTrue(rAllocation
|
|
|
|
- .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
+ Assert.assertTrue(rAllocation.compareTo(
|
|
|
|
+ (ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testGetReservationsByInvalidId() {
|
|
public void testGetReservationsByInvalidId() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
+ int[] alloc = {10, 10, 10, 10, 10, 10};
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -589,22 +463,23 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
// If reservationId is null, then nothing is returned.
|
|
// If reservationId is null, then nothing is returned.
|
|
ReservationId invalidReservationID =
|
|
ReservationId invalidReservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
Set<ReservationAllocation> rAllocations =
|
|
Set<ReservationAllocation> rAllocations =
|
|
- plan.getReservations(invalidReservationID, null, "");
|
|
|
|
|
|
+ plan.getReservations(invalidReservationID, null, "");
|
|
Assert.assertTrue(rAllocations.size() == 0);
|
|
Assert.assertTrue(rAllocations.size() == 0);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testGetReservationsByTimeInterval() {
|
|
public void testGetReservationsByTimeInterval() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
+ int[] alloc = {10, 10, 10, 10, 10, 10};
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -614,24 +489,23 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
// Verify that get by time interval works if the selection interval
|
|
// Verify that get by time interval works if the selection interval
|
|
// completely overlaps with the allocation.
|
|
// completely overlaps with the allocation.
|
|
- ReservationInterval interval = new ReservationInterval(
|
|
|
|
- rAllocation.getStartTime(), rAllocation.getEndTime());
|
|
|
|
|
|
+ ReservationInterval interval = new ReservationInterval(rAllocation
|
|
|
|
+ .getStartTime(), rAllocation.getEndTime());
|
|
Set<ReservationAllocation> rAllocations =
|
|
Set<ReservationAllocation> rAllocations =
|
|
- plan.getReservations(null, interval, "");
|
|
|
|
|
|
+ plan.getReservations(null, interval, "");
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
- Assert.assertTrue(rAllocation
|
|
|
|
- .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
+ Assert.assertTrue(rAllocation.compareTo(
|
|
|
|
+ (ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
// Verify that get by time interval works if the selection interval
|
|
// Verify that get by time interval works if the selection interval
|
|
// falls within the allocation
|
|
// falls within the allocation
|
|
long duration = rAllocation.getEndTime() - rAllocation.getStartTime();
|
|
long duration = rAllocation.getEndTime() - rAllocation.getStartTime();
|
|
- interval = new ReservationInterval(
|
|
|
|
- rAllocation.getStartTime() + duration * (long) 0.3,
|
|
|
|
- rAllocation.getEndTime() - duration * (long) 0.3);
|
|
|
|
|
|
+ interval = new ReservationInterval(rAllocation.getStartTime() + duration
|
|
|
|
+ * (long)0.3, rAllocation.getEndTime() - duration * (long)0.3);
|
|
rAllocations = plan.getReservations(null, interval, "");
|
|
rAllocations = plan.getReservations(null, interval, "");
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
- Assert.assertTrue(rAllocation
|
|
|
|
- .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
+ Assert.assertTrue(rAllocation.compareTo(
|
|
|
|
+ (ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
// Verify that get by time interval selects 1 allocation if the end
|
|
// Verify that get by time interval selects 1 allocation if the end
|
|
// time of the selection interval falls right at the start of the
|
|
// time of the selection interval falls right at the start of the
|
|
@@ -639,13 +513,13 @@ public class TestInMemoryPlan {
|
|
interval = new ReservationInterval(0, rAllocation.getStartTime());
|
|
interval = new ReservationInterval(0, rAllocation.getStartTime());
|
|
rAllocations = plan.getReservations(null, interval, "");
|
|
rAllocations = plan.getReservations(null, interval, "");
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
- Assert.assertTrue(rAllocation
|
|
|
|
- .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
+ Assert.assertTrue(rAllocation.compareTo(
|
|
|
|
+ (ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
// Verify that get by time interval selects no reservations if the start
|
|
// Verify that get by time interval selects no reservations if the start
|
|
// time of the selection interval falls right at the end of the allocation.
|
|
// time of the selection interval falls right at the end of the allocation.
|
|
- interval =
|
|
|
|
- new ReservationInterval(rAllocation.getEndTime(), Long.MAX_VALUE);
|
|
|
|
|
|
+ interval = new ReservationInterval(rAllocation
|
|
|
|
+ .getEndTime(), Long.MAX_VALUE);
|
|
rAllocations = plan.getReservations(null, interval, "");
|
|
rAllocations = plan.getReservations(null, interval, "");
|
|
Assert.assertTrue(rAllocations.size() == 0);
|
|
Assert.assertTrue(rAllocations.size() == 0);
|
|
|
|
|
|
@@ -658,14 +532,15 @@ public class TestInMemoryPlan {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testGetReservationsAtTime() {
|
|
public void testGetReservationsAtTime() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
+ int[] alloc = {10, 10, 10, 10, 10, 10};
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -674,22 +549,23 @@ public class TestInMemoryPlan {
|
|
}
|
|
}
|
|
|
|
|
|
Set<ReservationAllocation> rAllocations =
|
|
Set<ReservationAllocation> rAllocations =
|
|
- plan.getReservationsAtTime(rAllocation.getStartTime());
|
|
|
|
|
|
+ plan.getReservationsAtTime(rAllocation.getStartTime());
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
- Assert.assertTrue(rAllocation
|
|
|
|
- .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
+ Assert.assertTrue(rAllocation.compareTo(
|
|
|
|
+ (ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testGetReservationsWithNoInput() {
|
|
public void testGetReservationsWithNoInput() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
ReservationId reservationID =
|
|
ReservationId reservationID =
|
|
- ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
- int[] alloc = { 10, 10, 10, 10, 10, 10 };
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId();
|
|
|
|
+ int[] alloc = {10, 10, 10, 10, 10, 10};
|
|
int start = 100;
|
|
int start = 100;
|
|
- ReservationAllocation rAllocation =
|
|
|
|
- createReservationAllocation(reservationID, start, alloc);
|
|
|
|
|
|
+ ReservationAllocation rAllocation = createReservationAllocation
|
|
|
|
+ (reservationID, start, alloc);
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
Assert.assertNull(plan.getReservationById(reservationID));
|
|
try {
|
|
try {
|
|
plan.addReservation(rAllocation, false);
|
|
plan.addReservation(rAllocation, false);
|
|
@@ -700,21 +576,22 @@ public class TestInMemoryPlan {
|
|
// Verify that getReservations defaults to getting all reservations if no
|
|
// Verify that getReservations defaults to getting all reservations if no
|
|
// reservationID, time interval, and user is provided,
|
|
// reservationID, time interval, and user is provided,
|
|
Set<ReservationAllocation> rAllocations =
|
|
Set<ReservationAllocation> rAllocations =
|
|
- plan.getReservations(null, null, "");
|
|
|
|
|
|
+ plan.getReservations(null, null, "");
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
Assert.assertTrue(rAllocations.size() == 1);
|
|
- Assert.assertTrue(rAllocation
|
|
|
|
- .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
|
|
|
|
+ Assert.assertTrue(rAllocation.compareTo(
|
|
|
|
+ (ReservationAllocation) rAllocations.toArray()[0]) == 0);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testGetReservationsWithNoReservation() {
|
|
public void testGetReservationsWithNoReservation() {
|
|
- Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
- resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
|
|
|
|
+ Plan plan =
|
|
|
|
+ new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L,
|
|
|
|
+ resCalc, minAlloc, maxAlloc, planName, replanner, true, context);
|
|
// Verify that get reservation returns no entries if no queries are made.
|
|
// Verify that get reservation returns no entries if no queries are made.
|
|
|
|
|
|
ReservationInterval interval = new ReservationInterval(0, Long.MAX_VALUE);
|
|
ReservationInterval interval = new ReservationInterval(0, Long.MAX_VALUE);
|
|
Set<ReservationAllocation> rAllocations =
|
|
Set<ReservationAllocation> rAllocations =
|
|
- plan.getReservations(null, interval, "");
|
|
|
|
|
|
+ plan.getReservations(null, interval, "");
|
|
Assert.assertTrue(rAllocations.size() == 0);
|
|
Assert.assertTrue(rAllocations.size() == 0);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -723,9 +600,7 @@ public class TestInMemoryPlan {
|
|
Assert.assertNotNull(plan.getReservationById(reservationID));
|
|
Assert.assertNotNull(plan.getReservationById(reservationID));
|
|
Assert.assertEquals(rAllocation, plan.getReservationById(reservationID));
|
|
Assert.assertEquals(rAllocation, plan.getReservationById(reservationID));
|
|
Assert.assertTrue(((InMemoryPlan) plan).getAllReservations().size() == 1);
|
|
Assert.assertTrue(((InMemoryPlan) plan).getAllReservations().size() == 1);
|
|
- if (rAllocation.getPeriodicity() <= 0) {
|
|
|
|
- Assert.assertEquals(rAllocation.getEndTime(), plan.getLastEndTime());
|
|
|
|
- }
|
|
|
|
|
|
+ Assert.assertEquals(rAllocation.getEndTime(), plan.getLastEndTime());
|
|
Assert.assertEquals(totalCapacity, plan.getTotalCapacity());
|
|
Assert.assertEquals(totalCapacity, plan.getTotalCapacity());
|
|
Assert.assertEquals(minAlloc, plan.getMinimumAllocation());
|
|
Assert.assertEquals(minAlloc, plan.getMinimumAllocation());
|
|
Assert.assertEquals(maxAlloc, plan.getMaximumAllocation());
|
|
Assert.assertEquals(maxAlloc, plan.getMaximumAllocation());
|
|
@@ -735,8 +610,7 @@ public class TestInMemoryPlan {
|
|
}
|
|
}
|
|
|
|
|
|
private ReservationDefinition createSimpleReservationDefinition(long arrival,
|
|
private ReservationDefinition createSimpleReservationDefinition(long arrival,
|
|
- long deadline, long duration, Collection<ReservationRequest> resources,
|
|
|
|
- String recurrenceExpression) {
|
|
|
|
|
|
+ long deadline, long duration, Collection<ReservationRequest> resources) {
|
|
// create a request with a single atomic ask
|
|
// create a request with a single atomic ask
|
|
ReservationDefinition rDef = new ReservationDefinitionPBImpl();
|
|
ReservationDefinition rDef = new ReservationDefinitionPBImpl();
|
|
ReservationRequests reqs = new ReservationRequestsPBImpl();
|
|
ReservationRequests reqs = new ReservationRequestsPBImpl();
|
|
@@ -745,7 +619,6 @@ public class TestInMemoryPlan {
|
|
rDef.setReservationRequests(reqs);
|
|
rDef.setReservationRequests(reqs);
|
|
rDef.setArrival(arrival);
|
|
rDef.setArrival(arrival);
|
|
rDef.setDeadline(deadline);
|
|
rDef.setDeadline(deadline);
|
|
- rDef.setRecurrenceExpression(recurrenceExpression);
|
|
|
|
return rDef;
|
|
return rDef;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -760,43 +633,31 @@ public class TestInMemoryPlan {
|
|
} else {
|
|
} else {
|
|
numContainers = alloc[i];
|
|
numContainers = alloc[i];
|
|
}
|
|
}
|
|
- ReservationRequest rr = ReservationRequest
|
|
|
|
- .newInstance(Resource.newInstance(1024, 1), (numContainers));
|
|
|
|
|
|
+ ReservationRequest rr =
|
|
|
|
+ ReservationRequest.newInstance(Resource.newInstance(1024, 1),
|
|
|
|
+ (numContainers));
|
|
req.put(new ReservationInterval(startTime + i, startTime + i + 1), rr);
|
|
req.put(new ReservationInterval(startTime + i, startTime + i + 1), rr);
|
|
}
|
|
}
|
|
return req;
|
|
return req;
|
|
}
|
|
}
|
|
|
|
|
|
- private ReservationAllocation createReservationAllocation(
|
|
|
|
- ReservationId reservationID, int start, int[] alloc) {
|
|
|
|
- return createReservationAllocation(reservationID, start, alloc, false, "0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private ReservationAllocation createReservationAllocation(
|
|
|
|
- ReservationId reservationID, int start, int[] alloc, boolean isStep) {
|
|
|
|
- return createReservationAllocation(reservationID, start, alloc, isStep,
|
|
|
|
- "0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private ReservationAllocation createReservationAllocation(
|
|
|
|
- ReservationId reservationID, int start, int[] alloc,
|
|
|
|
- String recurrenceExp) {
|
|
|
|
- return createReservationAllocation(reservationID, start, alloc, false,
|
|
|
|
- recurrenceExp);
|
|
|
|
|
|
+ private ReservationAllocation createReservationAllocation(ReservationId
|
|
|
|
+ reservationID, int start, int[] alloc) {
|
|
|
|
+ return createReservationAllocation(reservationID, start, alloc, false);
|
|
}
|
|
}
|
|
|
|
|
|
- private ReservationAllocation createReservationAllocation(
|
|
|
|
- ReservationId reservationID, int start, int[] alloc, boolean isStep,
|
|
|
|
- String recurrenceExp) {
|
|
|
|
|
|
+ private ReservationAllocation createReservationAllocation(ReservationId
|
|
|
|
+ reservationID, int start, int[] alloc, boolean isStep) {
|
|
Map<ReservationInterval, ReservationRequest> allocations =
|
|
Map<ReservationInterval, ReservationRequest> allocations =
|
|
- generateAllocation(start, alloc, isStep);
|
|
|
|
|
|
+ generateAllocation(start, alloc, isStep);
|
|
ReservationDefinition rDef =
|
|
ReservationDefinition rDef =
|
|
- createSimpleReservationDefinition(start, start + alloc.length,
|
|
|
|
- alloc.length, allocations.values(), recurrenceExp);
|
|
|
|
|
|
+ createSimpleReservationDefinition(start, start + alloc.length,
|
|
|
|
+ alloc.length, allocations.values());
|
|
Map<ReservationInterval, Resource> allocs =
|
|
Map<ReservationInterval, Resource> allocs =
|
|
- ReservationSystemUtil.toResources(allocations);
|
|
|
|
|
|
+ ReservationSystemUtil.toResources(allocations);
|
|
return new InMemoryReservationAllocation(reservationID, rDef, user,
|
|
return new InMemoryReservationAllocation(reservationID, rDef, user,
|
|
- planName, start, start + alloc.length, allocs, resCalc, minAlloc);
|
|
|
|
|
|
+ planName,
|
|
|
|
+ start, start + alloc.length, allocs, resCalc, minAlloc);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|