private double getExpectedCloudletCompletionTime(final Cloudlet cloudlet, final Vm vm) { return cloudlet.getLength() / vm.getMips(); }
private double getExpectedCloudletCompletionTime(Cloudlet cloudlet, Vm vm) { return cloudlet.getLength() / vm.getMips(); }
@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); }
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 double getUtilizationMean() { final int maxEntries = getNumEntriesToComputeStats(); final double usagePercentMean = getHistoryLimitedStream(maxEntries) .mapToDouble(usagePercent -> usagePercent) .average() .orElse(0); return usagePercentMean * vm.getMips(); }
@Override public double getRequestedMipsForCloudlet(final CloudletExecution cle, final double time) { return getAbsoluteCloudletResourceUtilization(cle.getCloudlet().getUtilizationModelCpu(), time, vm.getMips()); }
/** * 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(); }
private boolean isNotHostPesSuitableToUpScaleVm(final VerticalVmScaling scaling) { final Vm vm = scaling.getVm(); final double numberOfPesForScaling = scaling.getResourceAmountToScale(); final List<Double> additionalVmMips = LongStream.range(0, (long)numberOfPesForScaling).mapToObj(i -> vm.getMips()).collect(toList()); return !vm.getHost().getVmScheduler().isSuitableForVm(vm, additionalVmMips); }
@Override public double getUtilizationVariance() { if (history.isEmpty()) { return 0; } final double mean = getUtilizationMean(); final int maxEntries = getNumEntriesToComputeStats(); return getHistoryLimitedStream(maxEntries) .mapToDouble(usagePercent -> usagePercent * vm.getMips()) .map(usageValue -> usageValue - mean) .map(usageValue -> usageValue * usageValue) .average().orElse(0); }
@Override public final void printResults() { final DatacenterBroker broker0 = getFirstBroker(); final List<Cloudlet> finishedCloudlets = broker0.getCloudletFinishedList(); finishedCloudlets.sort(comparingLong(Cloudlet::getId)); new CloudletsTableBuilder(finishedCloudlets) .addColumn(7, new TextTableColumn("VM ", "MIPS "), c -> (long)c.getVm().getMips()) .addColumn(new TextTableColumn("Wait Time", "Seconds"), c -> Math.ceil(c.getWaitingTime())) .build(); }
public VmsCpuUsageExample() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ //Log.setLevel(ch.qos.logback.classic.Level.WARN); System.out.println("Starting " + getClass().getSimpleName()); CloudSim simulation = new CloudSim(); @SuppressWarnings("unused") Datacenter datacenter0 = createDatacenter(simulation); broker = new DatacenterBrokerSimple(simulation); vmlist = new ArrayList<>(VMS); cloudletList = new ArrayList<>(VMS); final int mips = 1000; final int pesNumber = 2; for (int i = 1; i <= VMS; i++) { Vm vm = createVm(pesNumber*2, mips * i, i - 1); vmlist.add(vm); Cloudlet cloudlet = createCloudlet(pesNumber); cloudletList.add(cloudlet); cloudlet.setVm(vm); } cloudletList.add(createCloudlet(pesNumber)); broker.submitVmList(vmlist); broker.submitCloudletList(cloudletList); final double finishTime = simulation.start(); new CloudletsTableBuilder(broker.getCloudletFinishedList()) .addColumn(7, new TextTableColumn("VM MIPS"), cloudlet -> cloudlet.getVm().getMips()) .build(); showCpuUtilizationForAllVms(finishTime); System.out.println(getClass().getSimpleName() + " finished!"); }
new CloudletsTableBuilder(newList) .addColumn(5, new TextTableColumn("Host ", "MIPS "), cloudlet -> cloudlet.getVm().getHost().getMips()) .addColumn(7, new TextTableColumn("VM MIPS"), cloudlet -> cloudlet.getVm().getMips()) .build();
/** * 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; }