VmSchedulerTimeShared extends VmScheduler { @Override public boolean allocatePesForVm(Vm vm, List<Double> mipsShareRequested) { if (vm.isInMigration()) { if (!getVmsMigratingIn().contains(vm.getUid()) && !getVmsMigratingOut().contains(vm.getUid())) { getVmsMigratingOut().add(vm.getUid()); } } else { if (getVmsMigratingOut().contains(vm.getUid())) { getVmsMigratingOut().remove(vm.getUid()); } } boolean result = allocatePesForVm(vm.getUid(), mipsShareRequested); updatePeProvisioning(); return result; } VmSchedulerTimeShared(List<? extends Pe> pelist); @Override boolean allocatePesForVm(Vm vm, List<Double> mipsShareRequested); @Override void deallocatePesForVm(Vm vm); @Override void deallocatePesForAllVms(); @Override double getMaxAvailableMips();  }
@Test public void testAllocatePesForVm() { List<Double> mipsShare1 = new ArrayList<Double>(); mipsShare1.add(MIPS / 4); assertTrue(vmScheduler.allocatePesForVm(vm1, mipsShare1)); assertEquals(PeList.getTotalMips(peList) - MIPS / 4, vmScheduler.getAvailableMips(), 0); assertEquals(PeList.getTotalMips(peList) - MIPS / 4, vmScheduler.getMaxAvailableMips(), 0); assertEquals(MIPS / 4, vmScheduler.getTotalAllocatedMipsForVm(vm1), 0); List<Double> mipsShare2 = new ArrayList<Double>(); mipsShare2.add(MIPS / 2); mipsShare2.add(MIPS / 8); assertTrue(vmScheduler.allocatePesForVm(vm2, mipsShare2)); assertEquals( PeList.getTotalMips(peList) - MIPS / 4 - MIPS / 2 - MIPS / 8, vmScheduler.getAvailableMips(), 0); assertEquals( PeList.getTotalMips(peList) - MIPS / 4 - MIPS / 2 - MIPS / 8, vmScheduler.getMaxAvailableMips(), 0); assertEquals(MIPS / 2 + MIPS / 8, vmScheduler.getTotalAllocatedMipsForVm(vm2), 0); vmScheduler.deallocatePesForAllVms(); assertEquals(PeList.getTotalMips(peList), vmScheduler.getAvailableMips(), 0); assertEquals(PeList.getTotalMips(peList), vmScheduler.getMaxAvailableMips(), 0); assertEquals(0, vmScheduler.getTotalAllocatedMipsForVm(vm2), 0); }