/** * Adds number used PEs for a Vm to the map between each VM and the number of PEs used. * @param vm the VM to add the number of used PEs to the map */ protected void addUsedPes(final Vm vm) { usedPes.put(vm, vm.getNumberOfPes()); }
/** * Sets the list of current mips share available for the VM using the * scheduler. * * @param currentMipsShare the new current mips share * @see #getCurrentMipsShare() */ protected void setCurrentMipsShare(final List<Double> currentMipsShare) { if(currentMipsShare.size() > vm.getNumberOfPes()){ LOGGER.warn("Requested {} PEs but {} has just {}", currentMipsShare.size(), vm, vm.getNumberOfPes()); } this.currentMipsShare = currentMipsShare; }
/** * Gets a List of VMs that have any PE from the {@link #lastFailedHost}. * @return */ private List<Vm> getVmsWithPEsFromFailedHost() { return lastFailedHost .getVmList() .stream() .filter(vm -> vm.getNumberOfPes() > 0) .collect(toList()); }
/** * Gets the number of PEs required by a given VM and sets the status of the same * number of physical PEs in its Host to a given status. * * @param vm the VM to set its the status of its used physical PEs * @param peList the list of physical PEs from which the corresponding virtual PEs will have the status changed * @param status the status to set */ private void setHostPesStatusForVmUsedPes(final Vm vm, final List<Pe> peList, final Pe.Status status) { setHostPesStatusForVmUsedPes(peList, status, vm.getNumberOfPes()); }
/** * Computes the cost of all Cloudlets hosted by a given Vm. * The cost is based on the number of PEs from the VM that * will be idle or overloaded. * * @param vm the VM to compute the cost to host some Cloudlets * @param cloudlets the list of Cloudlets to be hosted by the VM in order to compute the cost * @return the VM cost to host the Cloudlets */ public double getVmCost(final Vm vm, final List<Cloudlet> cloudlets) { return Math.abs(vm.getNumberOfPes() - getTotalCloudletsPes(cloudlets)); }
@Override public void deallocatePesFromVm(final Vm vm) { deallocatePesFromVm(vm, (int)vm.getNumberOfPes()); }
/** * Gets the expected amount of free PEs for a VM * * @param vm the VM to get the amount of free PEs * @return the number of PEs that are free or a negative value that indicate * there aren't free PEs (this negative number indicates the amount of * overloaded PEs) */ private long getExpectedNumberOfFreeVmPes(Vm vm) { final long totalPesNumberForCloudletsOfVm = vm.getBroker().getCloudletCreatedList().stream() .filter(c -> c.getVm().equals(vm)) .mapToLong(Cloudlet::getNumberOfPes) .sum(); return vm.getNumberOfPes() - totalPesNumberForCloudletsOfVm; }
@Override public void deallocatePesFromVm(final Vm vm, final int pesToRemove) { if(pesToRemove <= 0 || vm.getNumberOfPes() == 0){ return; } deallocatePesFromVmInternal(vm, pesToRemove); freeUsedPes(); }
private void printSolution(String title, CloudletToVmMappingSolution solution, boolean showIndividualCloudletFitness) { System.out.printf("%s (cost %.2f fitness %.6f)\n", title, solution.getCost(), solution.getFitness()); if(!showIndividualCloudletFitness) return; for(Map.Entry<Cloudlet, Vm> e: solution.getResult().entrySet()){ System.out.printf( "Cloudlet %3d (%d PEs, %6d MI) mapped to Vm %3d (%d PEs, %6.0f MIPS)\n", e.getKey().getId(), e.getKey().getNumberOfPes(), e.getKey().getLength(), e.getValue().getId(), e.getValue().getNumberOfPes(), e.getValue().getMips()); } System.out.println(); }
@Override public final boolean allocatePesForVm(final Vm vm) { final List<Double> mipsShareRequested = LongStream.range(0, vm.getNumberOfPes()) .mapToObj(idx -> vm.getMips()) .collect(toList()); return allocatePesForVm(vm, mipsShareRequested); }
@SuppressWarnings("ConstantConditions") @Override public boolean allocateHostForVm(final Vm vm, final Host host) { if (host.createVm(vm)) { addUsedPes(vm); getHostFreePesMap().compute(host, (h, previousFreePes) -> previousFreePes - vm.getNumberOfPes()); LOGGER.info( "{}: {}: {} has been allocated to {}", vm.getSimulation().clock(), getClass().getSimpleName(), vm, host); return true; } LOGGER.error("{}: Creation of {} on {} failed", vm.getSimulation().clock(), vm, host); return false; }
/** * Gets the total monetary cost of processing power allocated from the PM hosting the VM. * * @return */ public double getProcessingCost() { final double hostMips = vm.getHost().getPeList().stream() .findFirst() .map(Pe::getCapacity) .orElse(0L); final double costPerMI = hostMips > 0 ? getDcCharacteristics().getCostPerSecond()/hostMips : 0.0; return costPerMI * getVm().getMips() * getVm().getNumberOfPes(); }
/** * Shows updates every time the simulation clock advances. * @param evt information about the event happened (that for this Listener is just the simulation time) */ private void onClockTickListener(EventInfo evt) { vmList.forEach(vm -> System.out.printf( "\t\tTime %6.1f: Vm %d CPU Usage: %6.2f%% (%2d vCPUs. Running Cloudlets: #%d). RAM usage: %.2f%% (%d MB)\n", evt.getTime(), vm.getId(), vm.getCpuPercentUsage()*100.0, vm.getNumberOfPes(), vm.getCloudletScheduler().getCloudletExecList().size(), vm.getRam().getPercentUtilization()*100, vm.getRam().getAllocatedResource()) ); }
private Cloudlet createCloudlet(Vm vm) { return new CloudletSimple(10000, vm.getNumberOfPes()) .setFileSize(300) .setOutputSize(300) .setUtilizationModel(new UtilizationModelFull()) .setVm(vm); }
private Cloudlet createCloudlet(Vm vm) { UtilizationModel utilization = new UtilizationModelFull(); return new CloudletSimple(CLOUDLET_LENGTH, vm.getNumberOfPes()) .setFileSize(1024) .setOutputSize(1024) .setUtilizationModel(utilization) .setVm(vm); } }
private Cloudlet createCloudlet(DatacenterBroker broker, Vm vm) { final long length = 10000; //in Million Structions (MI) final long numberOfCpuCores = vm.getNumberOfPes(); //cloudlet will use all the VM's CPU cores return new CloudletSimple( numberOfCreatedCloudlets++, length, numberOfCpuCores) .setFileSize(300) .setOutputSize(300) .setUtilizationModel(new UtilizationModelFull()) .setVm(vm); } }
private Cloudlet createCloudlet(DatacenterBroker broker, Vm vm) { long fileSize = 300; //Size (in bytes) before execution long outputSize = 300; //Size (in bytes) after execution long numberOfCpuCores = vm.getNumberOfPes(); //cloudlet will use all the VM's CPU cores //Defines how CPU, RAM and Bandwidth resources are used //Sets the same utilization model for all these resources. UtilizationModel utilization = new UtilizationModelFull(); return new CloudletSimple(numberOfCreatedCloudlets++, CLOUDLET_LENGTH, numberOfCpuCores) .setFileSize(fileSize) .setOutputSize(outputSize) .setUtilizationModel(utilization) .setVm(vm); }
private Cloudlet createCloudlet(Vm vm) { return new CloudletSimple(10000, vm.getNumberOfPes()) .setFileSize(300) .setOutputSize(300) .setUtilizationModel(new UtilizationModelFull()) .setVm(vm); }
private Cloudlet createCloudlet(DatacenterBroker broker, Vm vm) { long fileSize = 300; //Size (in bytes) before execution long outputSize = 300; //Size (in bytes) after execution long numberOfCpuCores = vm.getNumberOfPes(); //cloudlet will use all the VM's CPU cores //Defines how CPU, RAM and Bandwidth resources are used //Sets the same utilization model for all these resources. UtilizationModel utilization = new UtilizationModelFull(); return new CloudletSimple(numberOfCreatedCloudlets++, CLOUDLET_LENGTH, numberOfCpuCores) .setFileSize(fileSize) .setOutputSize(outputSize) .setUtilizationModel(utilization) .setVm(vm); }
private Cloudlet createCloudlet(DatacenterBroker broker, Vm vm) { long length = 10000; //in Million Structions (MI) long fileSize = 300; //Size (in bytes) before execution long outputSize = 300; //Size (in bytes) after execution long numberOfCpuCores = vm.getNumberOfPes(); //cloudlet will use all the VM's CPU cores //Defines how CPU, RAM and Bandwidth resources are used //Sets the same utilization model for all these resources. UtilizationModel utilization = new UtilizationModelFull(); return new CloudletSimple( numberOfCreatedCloudlets++, length, numberOfCpuCores) .setFileSize(fileSize) .setOutputSize(outputSize) .setUtilizationModel(utilization) .setVm(vm); }