@Test public void testNonExceedingBudget() { String[] cuts = new String[] { NoBranches.class.getName(), Trivial.class.getName(), MoreBranches.class.getName() }; ProjectAnalyzer analyzer = new ProjectAnalyzer(cuts); ProjectStaticData data = analyzer.analyze(); int cores = 2; int memory = 1400; int budget = 10; CtgConfiguration conf = new CtgConfiguration(memory, cores, budget, 1, false, AvailableSchedule.BUDGET); JobScheduler scheduler = new JobScheduler(data, conf); List<JobDefinition> jobs = scheduler.createNewSchedule(); Assert.assertNotNull(jobs); Assert.assertEquals(3, jobs.size()); for (JobDefinition job : jobs) { Assert.assertEquals(700, job.memoryInMB); } Assert.assertEquals(MoreBranches.class.getName(), jobs.get(0).cut); Assert.assertEquals(Trivial.class.getName(), jobs.get(1).cut); Assert.assertEquals(NoBranches.class.getName(), jobs.get(2).cut); long dif01 = jobs.get(0).seconds - jobs.get(1).seconds; long dif12 = jobs.get(1).seconds - jobs.get(2).seconds; Assert.assertTrue("" + dif01, dif01 > 0); Assert.assertTrue("" + dif12, dif12 > 0); int sum = jobs.get(0).seconds + jobs.get(1).seconds + jobs.get(2).seconds; Assert.assertTrue("wrong value " + sum, sum <= (cores * budget * 60)); for(JobDefinition job : jobs){ Assert.assertTrue("wrong "+job.seconds, job.seconds <= budget * 60); } }
public List<JobDefinition> createNewSchedule(){ if(!canExecuteMore()){ logger.info("Cannot schedule more jobs"); return null; } logger.info("Creating new schedule with "+currentSchedule.getClass().getSimpleName()); List<JobDefinition> jobs = currentSchedule.createNewSchedule(); for (JobDefinition job : jobs) { ClassInfo classInfo = this.projectData.getClassInfo(job.cut); classInfo.setTimeBudgetInSeconds(job.seconds); classInfo.setMemoryInMB(job.memoryInMB); } return jobs; }
JobScheduler { public List<JobDefinition> createNewSchedule(){ if(!canExecuteMore()){ logger.info("Cannot schedule more jobs"); return null; } logger.info("Creating new schedule with "+currentSchedule.getClass().getSimpleName()); List<JobDefinition> jobs = currentSchedule.createNewSchedule(); for (JobDefinition job : jobs) { ClassInfo classInfo = this.projectData.getClassInfo(job.cut); classInfo.setTimeBudgetInSeconds(job.seconds); classInfo.setMemoryInMB(job.memoryInMB); } return jobs; } }
JobScheduler { public List<JobDefinition> createNewSchedule(){ if(!canExecuteMore()){ logger.info("Cannot schedule more jobs"); return null; } logger.info("Creating new schedule with "+currentSchedule.getClass().getSimpleName()); List<JobDefinition> jobs = currentSchedule.createNewSchedule(); for (JobDefinition job : jobs) { ClassInfo classInfo = this.projectData.getClassInfo(job.cut); classInfo.setTimeBudgetInSeconds(job.seconds); classInfo.setMemoryInMB(job.memoryInMB); } return jobs; } JobScheduler(ProjectStaticData projectData,
			CtgConfiguration conf); }
JobScheduler { public List<JobDefinition> createNewSchedule(){ if(!canExecuteMore()){ logger.info("Cannot schedule more jobs"); return null; } logger.info("Creating new schedule with "+currentSchedule.getClass().getSimpleName()); List<JobDefinition> jobs = currentSchedule.createNewSchedule(); for (JobDefinition job : jobs) { ClassInfo classInfo = this.projectData.getClassInfo(job.cut); classInfo.setTimeBudgetInSeconds(job.seconds); classInfo.setMemoryInMB(job.memoryInMB); } return jobs; } JobScheduler(ProjectStaticData projectData,
			CtgConfiguration conf); void chooseScheduleType(AvailableSchedule schedule); List<JobDefinition> createNewSchedule(); boolean canExecuteMore(); ProjectStaticData getProjectData(); CtgConfiguration getConfiguration(); }
JobScheduler { public List<JobDefinition> createNewSchedule(){ if(!canExecuteMore()){ logger.info("Cannot schedule more jobs"); return null; } logger.info("Creating new schedule with "+currentSchedule.getClass().getSimpleName()); List<JobDefinition> jobs = currentSchedule.createNewSchedule(); for (JobDefinition job : jobs) { ClassInfo classInfo = this.projectData.getClassInfo(job.cut); classInfo.setTimeBudgetInSeconds(job.seconds); classInfo.setMemoryInMB(job.memoryInMB); } return jobs; } JobScheduler(ProjectStaticData projectData,
			CtgConfiguration conf); void chooseScheduleType(AvailableSchedule schedule); List<JobDefinition> createNewSchedule(); boolean canExecuteMore(); ProjectStaticData getProjectData(); CtgConfiguration getConfiguration();  }