|
@@ -24,8 +24,10 @@ import java.io.IOException;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.TreeMap;
|
|
import java.util.TreeMap;
|
|
|
|
|
|
|
|
+import org.apache.hadoop.yarn.api.records.ReservationDefinition;
|
|
import org.apache.hadoop.yarn.api.records.ReservationRequest;
|
|
import org.apache.hadoop.yarn.api.records.ReservationRequest;
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningQuotaException;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningQuotaException;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.ResourceOverCommitException;
|
|
import org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.ResourceOverCommitException;
|
|
@@ -82,11 +84,12 @@ public class TestCapacityOverTimePolicy {
|
|
instConstraint, avgConstraint);
|
|
instConstraint, avgConstraint);
|
|
CapacityOverTimePolicy policy = new CapacityOverTimePolicy();
|
|
CapacityOverTimePolicy policy = new CapacityOverTimePolicy();
|
|
policy.init(reservationQ, conf);
|
|
policy.init(reservationQ, conf);
|
|
|
|
+ RMContext context = ReservationSystemTestUtil.createMockRMContext();
|
|
|
|
|
|
plan =
|
|
plan =
|
|
new InMemoryPlan(rootQueueMetrics, policy, mAgent,
|
|
new InMemoryPlan(rootQueueMetrics, policy, mAgent,
|
|
clusterResource, step, res, minAlloc, maxAlloc,
|
|
clusterResource, step, res, minAlloc, maxAlloc,
|
|
- "dedicated", null, true);
|
|
|
|
|
|
+ "dedicated", null, true, context);
|
|
}
|
|
}
|
|
|
|
|
|
public int[] generateData(int length, int val) {
|
|
public int[] generateData(int length, int val) {
|
|
@@ -101,9 +104,13 @@ public class TestCapacityOverTimePolicy {
|
|
public void testSimplePass() throws IOException, PlanningException {
|
|
public void testSimplePass() throws IOException, PlanningException {
|
|
// generate allocation that simply fit within all constraints
|
|
// generate allocation that simply fit within all constraints
|
|
int[] f = generateData(3600, (int) Math.ceil(0.2 * totCont));
|
|
int[] f = generateData(3600, (int) Math.ceil(0.2 * totCont));
|
|
|
|
+
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + f.length + 1, f.length);
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
@@ -115,9 +122,12 @@ public class TestCapacityOverTimePolicy {
|
|
// fit within
|
|
// fit within
|
|
// max instantanesou
|
|
// max instantanesou
|
|
int[] f = generateData(3600, (int) Math.ceil(0.69 * totCont));
|
|
int[] f = generateData(3600, (int) Math.ceil(0.69 * totCont));
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + f.length + 1, f.length);
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
@@ -127,10 +137,13 @@ public class TestCapacityOverTimePolicy {
|
|
public void testMultiTenantPass() throws IOException, PlanningException {
|
|
public void testMultiTenantPass() throws IOException, PlanningException {
|
|
// generate allocation from multiple tenants that barely fit in tot capacity
|
|
// generate allocation from multiple tenants that barely fit in tot capacity
|
|
int[] f = generateData(3600, (int) Math.ceil(0.25 * totCont));
|
|
int[] f = generateData(3600, (int) Math.ceil(0.25 * totCont));
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + f.length + 1, f.length);
|
|
for (int i = 0; i < 4; i++) {
|
|
for (int i = 0; i < 4; i++) {
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u" + i,
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u" + i,
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
@@ -141,10 +154,13 @@ public class TestCapacityOverTimePolicy {
|
|
public void testMultiTenantFail() throws IOException, PlanningException {
|
|
public void testMultiTenantFail() throws IOException, PlanningException {
|
|
// generate allocation from multiple tenants that exceed tot capacity
|
|
// generate allocation from multiple tenants that exceed tot capacity
|
|
int[] f = generateData(3600, (int) Math.ceil(0.25 * totCont));
|
|
int[] f = generateData(3600, (int) Math.ceil(0.25 * totCont));
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + f.length + 1, f.length);
|
|
for (int i = 0; i < 5; i++) {
|
|
for (int i = 0; i < 5; i++) {
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u" + i,
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u" + i,
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
@@ -155,9 +171,12 @@ public class TestCapacityOverTimePolicy {
|
|
public void testInstFail() throws IOException, PlanningException {
|
|
public void testInstFail() throws IOException, PlanningException {
|
|
// generate allocation that exceed the instantaneous cap single-show
|
|
// generate allocation that exceed the instantaneous cap single-show
|
|
int[] f = generateData(3600, (int) Math.ceil(0.71 * totCont));
|
|
int[] f = generateData(3600, (int) Math.ceil(0.71 * totCont));
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + f.length + 1, f.length);
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
@@ -168,23 +187,25 @@ public class TestCapacityOverTimePolicy {
|
|
public void testInstFailBySum() throws IOException, PlanningException {
|
|
public void testInstFailBySum() throws IOException, PlanningException {
|
|
// generate allocation that exceed the instantaneous cap by sum
|
|
// generate allocation that exceed the instantaneous cap by sum
|
|
int[] f = generateData(3600, (int) Math.ceil(0.3 * totCont));
|
|
int[] f = generateData(3600, (int) Math.ceil(0.3 * totCont));
|
|
-
|
|
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + f.length + 1, f.length);
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
try {
|
|
try {
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + f.length,
|
|
"dedicated", initTime, initTime + f.length,
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
ReservationSystemTestUtil.generateAllocation(initTime, step, f),
|
|
res, minAlloc)));
|
|
res, minAlloc)));
|
|
@@ -205,10 +226,12 @@ public class TestCapacityOverTimePolicy {
|
|
ReservationSystemUtil.toResource(
|
|
ReservationSystemUtil.toResource(
|
|
ReservationRequest.newInstance(Resource.newInstance(1024, 1),
|
|
ReservationRequest.newInstance(Resource.newInstance(1024, 1),
|
|
cont)));
|
|
cont)));
|
|
-
|
|
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + win, win);
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + win, req, res, minAlloc)));
|
|
"dedicated", initTime, initTime + win, req, res, minAlloc)));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -222,9 +245,12 @@ public class TestCapacityOverTimePolicy {
|
|
req.put(new ReservationInterval(initTime, initTime + win),
|
|
req.put(new ReservationInterval(initTime, initTime + win),
|
|
ReservationSystemUtil.toResource(ReservationRequest.newInstance(Resource
|
|
ReservationSystemUtil.toResource(ReservationRequest.newInstance(Resource
|
|
.newInstance(1024, 1), cont)));
|
|
.newInstance(1024, 1), cont)));
|
|
|
|
+ ReservationDefinition rDef =
|
|
|
|
+ ReservationSystemTestUtil.createSimpleReservationDefinition(
|
|
|
|
+ initTime, initTime + win, win);
|
|
assertTrue(plan.toString(),
|
|
assertTrue(plan.toString(),
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
plan.addReservation(new InMemoryReservationAllocation(
|
|
- ReservationSystemTestUtil.getNewReservationId(), null, "u1",
|
|
|
|
|
|
+ ReservationSystemTestUtil.getNewReservationId(), rDef, "u1",
|
|
"dedicated", initTime, initTime + win, req, res, minAlloc)));
|
|
"dedicated", initTime, initTime + win, req, res, minAlloc)));
|
|
|
|
|
|
try {
|
|
try {
|