private long getVmSize(final Cloudlet cloudlet) { return cloudlet.getVm().getStorage().getCapacity(); }
@Override public void destroyAllVms() { deallocateResourcesOfAllVms(); for (final Vm vm : vmList) { vm.setCreated(false); storage.deallocateResource(vm.getStorage()); } vmList.clear(); }
/** * Gets the total monetary cost of the VM's allocated storage. * * @return getStorageCost */ public double getStorageCost() { return getDcCharacteristics().getCostPerStorage() * vm.getStorage().getCapacity(); }
/** * Deallocate all resources that a VM was using. * * @param vm the VM */ protected void deallocateResourcesOfVm(final Vm vm) { vm.setCreated(false); ramProvisioner.deallocateResourceForVm(vm); bwProvisioner.deallocateResourceForVm(vm); vmScheduler.deallocatePesFromVm(vm); storage.deallocateResource(vm.getStorage()); }
private void allocateResourcesForVm(Vm vm) { ramProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedRam()); bwProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedBw()); vmScheduler.allocatePesForVm(vm, vm.getCurrentRequestedMips()); storage.allocateResource(vm.getStorage()); }
private boolean hasEnoughResources(final Vm vm) { return vmScheduler.isSuitableForVm(vm, vm.getCurrentRequestedMips()) && ramProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedRam()) && bwProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedBw()) && storage.isAmountAvailable(vm.getStorage()); }
/** * Try to allocate all resources that a VM requires (Storage, RAM, BW and MIPS) to be placed at this Host. * * @param vm the VM to try allocating resources to * @param inMigration If the VM is migrating into the Host or it is being just created for the first time * @return true if the Vm was placed into the host, false if the Host doesn't have enough resources to allocate the Vm */ private boolean allocateResourcesForVm(final Vm vm, final boolean inMigration){ if (!storage.isAmountAvailable(vm.getStorage())) { logAllocationError(vm, inMigration, "MB", this.getStorage(), vm.getStorage()); return false; } if (!ramProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedRam())) { logAllocationError(vm, inMigration, "MB", this.getRam(), vm.getRam()); return false; } if (!bwProvisioner.isSuitableForVm(vm, vm.getCurrentRequestedBw())) { logAllocationError(vm, inMigration, "Mbps", this.getBw(), vm.getBw()); return false; } if (!vmScheduler.isSuitableForVm(vm, true)) { return false; } vm.setInMigration(inMigration); allocateResourcesForVm(vm); return true; }
/** * Clones a VM by creating another one with the same configurations of a * given VM. * * @param vm the VM to be cloned * @return the cloned (new) VM. * * @see #createFaultInjectionForHosts(org.cloudbus.cloudsim.datacenters.Datacenter) */ private Vm cloneVm(Vm vm) { Vm clone = new VmSimple((long) vm.getMips(), (int) vm.getNumberOfPes()); /*It' not required to set an ID for the clone. It is being set here just to make it easy to relate the ID of the vm to its clone, since the clone ID will be 10 times the id of its source VM.*/ clone.setId(vm.getId() * 10); clone.setDescription("Clone of VM " + vm.getId()); clone .setSize(vm.getStorage().getCapacity()) .setBw(vm.getBw().getCapacity()) .setRam(vm.getBw().getCapacity()) .setCloudletScheduler(new CloudletSchedulerTimeShared()); System.out.printf("\n\n# Cloning %s - MIPS %.2f Number of Pes: %d\n", vm, clone.getMips(), clone.getNumberOfPes()); return clone; }
/** * Clones a VM by creating another one with the same configurations of a * given VM. * * @param vm the VM to be cloned * @return the cloned (new) VM. * @see #createFaultInjectionForHosts(org.cloudbus.cloudsim.datacenters.Datacenter) */ private Vm cloneVm(final Vm vm) { final Vm clone = new VmSimple((long) vm.getMips(), (int) vm.getNumberOfPes()); /* It' not required to set an ID for the clone. It is being set here just to make it easy to relate the ID of the vm to its clone, since the clone ID will be 10 times the id of its source VM. */ clone.setId(vm.getId() * 10); clone.setDescription("Clone of VM " + vm.getId()); clone .setSize(vm.getStorage().getCapacity()) .setBw(vm.getBw().getCapacity()) .setRam(vm.getBw().getCapacity()) .setCloudletScheduler(new CloudletSchedulerTimeShared()); System.out.printf("\n\n#Cloning VM %d from Host %d\n\tMips %.2f Number of Pes: %d\n", vm.getId(), vm.getHost().getId(), clone.getMips(), clone.getNumberOfPes()); return clone; }