out.println("</allocations>");
out.close();
scheduler.getPoolManager().reloadAllocs();
JobInProgress job1 = submitJob(JobStatus.RUNNING, 10, 10);
JobInfo info1 = scheduler.infos.get(job1);
// Check scheduler variables
assertEquals(0, info1.runningMaps);
assertEquals(0, info1.runningReduces);
assertEquals(10, info1.neededMaps);
assertEquals(10, info1.neededReduces);
assertEquals(0, info1.mapDeficit);
assertEquals(0, info1.reduceDeficit);
assertEquals(4.0, info1.mapFairShare);
assertEquals(4.0, info1.reduceFairShare);
// Advance time 200ms and submit job 2
advanceTime(200);
assertEquals(800, info1.mapDeficit);
assertEquals(800, info1.reduceDeficit);
JobInProgress job2 = submitJob(JobStatus.RUNNING, 10, 10, "poolA");
JobInfo info2 = scheduler.infos.get(job2);
// Check that minimum and fair shares have been allocated
assertEquals(0, info1.minMaps);
assertEquals(0, info1.minReduces);
assertEquals(2.0, info1.mapFairShare);
assertEquals(2.0, info1.reduceFairShare);
assertEquals(2, info2.minMaps);
assertEquals(2, info2.minReduces);
assertEquals(2.0, info2.mapFairShare);
assertEquals(2.0, info2.reduceFairShare);
// Advance time 100ms and submit job 3
advanceTime(100);
assertEquals(1000, info1.mapDeficit);
assertEquals(1000, info1.reduceDeficit);
assertEquals(200, info2.mapDeficit);
assertEquals(200, info2.reduceDeficit);
JobInProgress job3 = submitJob(JobStatus.RUNNING, 10, 10, "poolA");
JobInfo info3 = scheduler.infos.get(job3);
// Check that minimum and fair shares have been allocated
assertEquals(0, info1.minMaps);
assertEquals(0, info1.minReduces);
assertEquals(2, info1.mapFairShare, 0.1);