/** * Compare this Vm with another one based on {@link #getTotalMipsCapacity()}. * * @param o the Vm to compare to * @return {@inheritDoc} */ @Override public int compareTo(final Vm o) { return Double.compare(getTotalMipsCapacity(), o.getTotalMipsCapacity()); }
@Override public double getRequestedCpuPercentUtilization(final double time) { return cloudletExecList.stream() .map(CloudletExecution::getCloudlet) .mapToDouble(cloudlet -> getAbsoluteCloudletCpuUtilizationForAllPes(time, cloudlet)) .sum() / vm.getTotalMipsCapacity(); }
/** * Receives a Vm {@link UtilizationHistory} and returns a {@link Function} that * requires a map entry from the history (representing a VM's CPU utilization for a given time), * and returns the percentage of the Host CPU capacity that Vm is using at that time. * This way, the value that represents how much of the VM's CPU is being used * will be converted to how much that VM is using from the Host's CPU. * * @param utilizationHistory the VM {@link UtilizationHistory} with the history entries * @return */ private Function<Entry<Double, Double>, Double> vmUtilizationMapper(final UtilizationHistory utilizationHistory) { final double totalMipsCapacity = getTotalMipsCapacity(); return entry -> entry.getValue() * utilizationHistory.getVm().getTotalMipsCapacity() / totalMipsCapacity; }
public VmSchedulerTimeSharedOverSubscriptionExample1() { /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ //Log.setLevel(ch.qos.logback.classic.Level.WARN); simulation = new CloudSim(); hostList = new ArrayList<>(HOSTS); vmList = new ArrayList<>(VMS); cloudletList = new ArrayList<>(CLOUDLETS); createDatacenter(); //Creates a broker that is a software acting on behalf a cloud customer to manage his/her VMs and Cloudlets broker0 = new DatacenterBrokerSimple(simulation); createVms(); createCloudlets(); broker0.submitVmList(vmList); broker0.submitCloudletList(cloudletList); simulation.start(); new CloudletsTableBuilder(broker0.getCloudletFinishedList()) .addColumn(5, new TextTableColumn("Host MIPS", "total"), c -> c.getVm().getHost().getTotalMipsCapacity()) .addColumn(8, new TextTableColumn("VM MIPS", "total"), c -> c.getVm().getTotalMipsCapacity()) .addColumn(9, new TextTableColumn(" VM MIPS", "requested"), this::getVmRequestedMips) .addColumn(10, new TextTableColumn(" VM MIPS", "allocated"), this::getVmAllocatedMips) .build(); System.out.println("\nHosts CPU usage History"); hostList.forEach(this::printHostHistory); }