/** * Gets the pes allocated for a vm. * * @param vm the vm * @return the pes allocated for the given vm */ public List<Pe> getPesAllocatedForVM(Vm vm) { return getPeMap().get(vm.getUid()); }
@Override public Host getHost(Vm vm) { return getVmTable().get(vm.getUid()); }
/** * Returns the MIPS share of each host's Pe that is allocated to a given VM. * * @param vm the vm * @return an array containing the amount of MIPS of each pe that is available to the VM * @pre $none * @post $none */ public List<Double> getAllocatedMipsForVm(Vm vm) { return getMipsMap().get(vm.getUid()); }
@Override public Host getHost(int vmId, int userId) { return getVmTable().get(Vm.getUid(userId, vmId)); }
@Override public Host getHost(int vmId, int userId) { return getVmTable().get(Vm.getUid(userId, vmId)); }
@Override public Host getHost(Vm vm) { return getVmTable().get(vm.getUid()); }
@Override public void deallocatePesForVm(Vm vm) { getFreePes().addAll(getPeAllocationMap().get(vm.getUid())); getPeAllocationMap().remove(vm.getUid()); double totalMips = 0; for (double mips : getMipsMap().get(vm.getUid())) { totalMips += mips; } setAvailableMips(getAvailableMips() + totalMips); getMipsMap().remove(vm.getUid()); }
@Override public void deallocateHostForVm(Vm vm) { Host host = getVmTable().remove(vm.getUid()); if (host != null) { host.vmDestroy(vm); } }
/** * Removes a migrating in vm. * * @param vm the vm */ public void removeMigratingInVm(Vm vm) { vmDeallocate(vm); getVmsMigratingIn().remove(vm); getVmList().remove(vm); getVmScheduler().getVmsMigratingIn().remove(vm.getUid()); vm.setInMigration(false); }
@Override public boolean allocateBwForVm(Vm vm, long bw) { deallocateBwForVm(vm); if (getAvailableBw() >= bw) { setAvailableBw(getAvailableBw() - bw); getBwTable().put(vm.getUid(), bw); vm.setCurrentAllocatedBw(getAllocatedBwForVm(vm)); return true; } vm.setCurrentAllocatedBw(getAllocatedBwForVm(vm)); return false; }