use of org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator in project hadoop by apache.
the class TestInMemoryReservationAllocation method setUp.
@Before
public void setUp() {
resCalc = new DefaultResourceCalculator();
minAlloc = Resource.newInstance(1, 1);
}
use of org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator in project hadoop by apache.
the class TestNoOverCommitPolicy method setup.
@Before
public void setup() throws Exception {
// 1 sec step
step = 1000L;
initTime = System.currentTimeMillis();
minAlloc = Resource.newInstance(1024, 1);
res = new DefaultResourceCalculator();
maxAlloc = Resource.newInstance(1024 * 8, 8);
mAgent = mock(ReservationAgent.class);
String reservationQ = ReservationSystemTestUtil.getFullReservationQueueName();
QueueMetrics rootQueueMetrics = mock(QueueMetrics.class);
Resource clusterResource = ReservationSystemTestUtil.calculateClusterResource(totCont);
ReservationSchedulerConfiguration conf = mock(ReservationSchedulerConfiguration.class);
NoOverCommitPolicy policy = new NoOverCommitPolicy();
policy.init(reservationQ, conf);
RMContext context = ReservationSystemTestUtil.createMockRMContext();
plan = new InMemoryPlan(rootQueueMetrics, policy, mAgent, clusterResource, step, res, minAlloc, maxAlloc, "dedicated", null, true, context);
}
use of org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator in project hadoop by apache.
the class TestRLESparseResourceAllocation method testRangeOverlapping.
@Test
public void testRangeOverlapping() {
ResourceCalculator resCalc = new DefaultResourceCalculator();
RLESparseResourceAllocation r = new RLESparseResourceAllocation(resCalc);
int[] alloc = { 10, 10, 10, 10, 10, 10 };
int start = 100;
Set<Entry<ReservationInterval, Resource>> inputs = generateAllocation(start, alloc, false).entrySet();
for (Entry<ReservationInterval, Resource> ip : inputs) {
r.addInterval(ip.getKey(), ip.getValue());
}
long s = r.getEarliestStartTime();
long d = r.getLatestNonNullTime();
// tries to trigger "out-of-range" bug
r = r.getRangeOverlapping(s, d);
r = r.getRangeOverlapping(s - 1, d - 1);
r = r.getRangeOverlapping(s + 1, d + 1);
}
use of org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator in project hadoop by apache.
the class TestRLESparseResourceAllocation method testBlocks.
@Test
public void testBlocks() {
ResourceCalculator resCalc = new DefaultResourceCalculator();
RLESparseResourceAllocation rleSparseVector = new RLESparseResourceAllocation(resCalc);
int[] alloc = { 10, 10, 10, 10, 10, 10 };
int start = 100;
Set<Entry<ReservationInterval, Resource>> inputs = generateAllocation(start, alloc, false).entrySet();
for (Entry<ReservationInterval, Resource> ip : inputs) {
rleSparseVector.addInterval(ip.getKey(), ip.getValue());
}
LOG.info(rleSparseVector.toString());
Assert.assertFalse(rleSparseVector.isEmpty());
Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(99));
Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(start + alloc.length + 1));
for (int i = 0; i < alloc.length; i++) {
Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rleSparseVector.getCapacityAtTime(start + i));
}
Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(start + alloc.length + 2));
for (Entry<ReservationInterval, Resource> ip : inputs) {
rleSparseVector.removeInterval(ip.getKey(), ip.getValue());
}
LOG.info(rleSparseVector.toString());
for (int i = 0; i < alloc.length; i++) {
Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(start + i));
}
Assert.assertTrue(rleSparseVector.isEmpty());
}
use of org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator in project hadoop by apache.
the class TestRLESparseResourceAllocation method testMergeMax.
@Test
public void testMergeMax() throws PlanningException {
TreeMap<Long, Resource> a = new TreeMap<>();
TreeMap<Long, Resource> b = new TreeMap<>();
setupArrays(a, b);
RLESparseResourceAllocation rleA = new RLESparseResourceAllocation(a, new DefaultResourceCalculator());
RLESparseResourceAllocation rleB = new RLESparseResourceAllocation(b, new DefaultResourceCalculator());
RLESparseResourceAllocation out = RLESparseResourceAllocation.merge(new DefaultResourceCalculator(), Resource.newInstance(100 * 128 * 1024, 100 * 32), rleA, rleB, RLEOperator.max, 0, 60);
System.out.println(out);
long[] time = { 10, 20, 30, 40, 50, 60 };
int[] alloc = { 5, 10, 15, 20, 10 };
validate(out, time, alloc);
}
Aggregations