public Vm getVmById(final int id) { return broker.getVmWaitingList().stream() .filter(vm -> vm.getId() == id) .findFirst().orElse(Vm.NULL); }
private String getVmIds(final List<? extends Vm> vmList) { return vmList.stream().map(vm -> String.valueOf(vm.getId())).collect(Collectors.joining(", ")); }
@Override public Vm getVm(final int vmId, final int brokerId) { return vmList.stream() .filter(vm -> vm.getId() == vmId && vm.getBroker().getId() == brokerId) .findFirst().orElse(Vm.NULL); }
/** * After a VM finishes executing, creates another one * if the number of created VMs is less than {@link #TOTAL_NUMBER_OF_VMS}. * By this way, it allows the sequential execution of several VMs into a host * that doesn't have enough PEs to execute them all simultaneously. */ private void createNextVmIfNotReachedMaxNumberOfVms() { if(numberOfFinishedVms < TOTAL_NUMBER_OF_VMS) { Vm vm = createAndSubmitVmForNewBroker(); System.out.printf("\tCreated VM %d at time %.0f\n", vm.getId(), simulation.clock()); } }
/** * Creates cloudlets and submit them to the broker. * @param vm Vm to run the cloudlets to be created * * @see #createCloudlet(long, Vm, long) */ private void createAndSubmitCloudlets(Vm vm) { long cloudletId; long length = 10000; for(int i = 0; i < NUMBER_OF_CLOUDLETS; i++){ cloudletId = vm.getId() + i; Cloudlet cloudlet = createCloudlet(cloudletId, vm, length); this.cloudletList.add(cloudlet); } this.broker.submitCloudletList(cloudletList); }
/** * Creates cloudlets and submit them to the broker. * @param vm Vm to run the cloudlets to be created * * @see #createCloudlet(long, Vm, long) */ private void createAndSubmitCloudlets(Vm vm) { long cloudletId; long length = 10000; for(int i = 0; i < NUMBER_OF_CLOUDLETS; i++){ cloudletId = vm.getId() + i; Cloudlet cloudlet = createCloudlet(cloudletId, vm, length*(i+1)); this.cloudletList.add(cloudlet); } this.broker.submitCloudletList(cloudletList); }
private void printVmsCpuUsage(EventInfo eventInfo) { DatacenterBroker broker0 = getFirstBroker(); broker0.getVmExecList().sort(Comparator.comparingLong(Vm::getId)); broker0.getVmExecList().forEach(vm -> System.out.printf("#### Time %.0f: Vm %d CPU usage: %.2f. SLA: %.2f.\n", eventInfo.getTime(), vm.getId(), vm.getCpuPercentUsage(), getCustomerMaxCpuUtilization()) ); }
/** * A Listener function that will be called every time a cloudlet * starts running into a VM. All cloudlets will use this same listener. * * @param eventInfo information about the happened event * @see #createCloudlet(long, Vm, long) */ private void onCloudletStartListener(CloudletVmEventInfo eventInfo) { System.out.printf( "\n\t#EventListener: Cloudlet %d just started running at Vm %d at time %.2f\n", eventInfo.getCloudlet().getId(), eventInfo.getVm().getId(), eventInfo.getTime()); }
/** * A Listener function that will be called every time a cloudlet * finishes running into a VM. All cloudlets will use this same listener. * * @param eventInfo information about the happened event * @see #createCloudlet(long, Vm, long) */ private void onCloudletFinishListener(CloudletVmEventInfo eventInfo) { System.out.printf( "\n\t#EventListener: Cloudlet %d finished running at Vm %d at time %.2f\n", eventInfo.getCloudlet().getId(), eventInfo.getVm().getId(), eventInfo.getTime()); }
private void printSimulationResults() { final List<Cloudlet> finishedCloudlets = broker0.getCloudletFinishedList(); final Comparator<Cloudlet> sortByVmId = comparingDouble(c -> c.getVm().getId()); final Comparator<Cloudlet> sortByStartTime = comparingDouble(Cloudlet::getExecStartTime); finishedCloudlets.sort(sortByVmId.thenComparing(sortByStartTime)); new CloudletsTableBuilder(finishedCloudlets).build(); }
private void printSimulationResults() { final List<Cloudlet> finishedCloudlets = broker0.getCloudletFinishedList(); final Comparator<Cloudlet> sortByVmId = comparingDouble(c -> c.getVm().getId()); final Comparator<Cloudlet> sortByStartTime = comparingDouble(Cloudlet::getExecStartTime); finishedCloudlets.sort(sortByVmId.thenComparing(sortByStartTime)); new CloudletsTableBuilder(finishedCloudlets).build(); }
protected final void printBrokerFinishedCloudlets(final DatacenterBroker broker) { final List<Cloudlet> finishedCloudlets = broker.getCloudletFinishedList(); final Comparator<Cloudlet> sortByVmId = comparingDouble(c -> c.getVm().getId()); final Comparator<Cloudlet> sortByStartTime = comparingDouble(Cloudlet::getExecStartTime); finishedCloudlets.sort(sortByVmId.thenComparing(sortByStartTime)); new CloudletsTableBuilder(finishedCloudlets).build(); }
private void printSimulationResults() { final List<Cloudlet> finishedCloudlets = broker0.getCloudletFinishedList(); final Comparator<Cloudlet> sortByVmId = comparingDouble(c -> c.getVm().getId()); final Comparator<Cloudlet> sortByStartTime = comparingDouble(Cloudlet::getExecStartTime); finishedCloudlets.sort(sortByVmId.thenComparing(sortByStartTime)); new CloudletsTableBuilder(finishedCloudlets).build(); }
/** * 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: #%02d) Upper Threshold: %.2f History Entries: %d\n", evt.getTime(), vm.getId(), vm.getCpuPercentUsage()*100.0, vm.getNumberOfPes(), vm.getCloudletScheduler().getCloudletExecList().size(), vm.getPeVerticalScaling().getUpperThresholdFunction().apply(vm), vm.getUtilizationHistory().getHistory().size()); }); }
private void printSimulationResults() { List<Cloudlet> finishedCloudlets = broker0.getCloudletFinishedList(); Comparator<Cloudlet> sortByVmId = comparingDouble(c -> c.getVm().getId()); Comparator<Cloudlet> sortByStartTime = comparingDouble(c -> c.getExecStartTime()); finishedCloudlets.sort(sortByVmId.thenComparing(sortByStartTime)); new CloudletsTableBuilder(finishedCloudlets).build(); }
/** * 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()) ); }
@Override protected boolean requestUpScaling(final double time) { if(!haveNewCloudletsArrived()){ return false; } final double vmCpuUsagePercent = getVm().getCpuPercentUsage() * 100; final Vm newVm = getVmSupplier().get(); LOGGER.info( "{}: {}{}: Requesting creation of {} to receive new Cloudlets in order to balance load of {}. {} CPU usage is {}%", time, getClass().getSimpleName(), getVm(), newVm, getVm(), getVm().getId(), vmCpuUsagePercent); getVm().getBroker().submitVm(newVm); cloudletCreationRequests = getVm().getBroker().getCloudletCreatedList().size(); return true; }
private void printResults() { for (DatacenterBroker broker : brokers) { new CloudletsTableBuilder(broker.getCloudletFinishedList()) .setTitle(broker.getName()) .build(); } System.out.println(); for (Vm vm : vmList) { System.out.printf("Vm %d Broker %d -> Start Time: %.0f Stop Time: %.0f Total Execution Time: %.0f\n", vm.getId(), vm.getBroker().getId(), vm.getStartTime(), vm.getStopTime(), vm.getTotalExecutionTime()); } System.out.println(); }
private void printResults() { for (DatacenterBroker broker : brokers) { new CloudletsTableBuilder(broker.getCloudletFinishedList()) .setTitle(broker.getName()) .build(); } System.out.println(); for (Vm vm : vmList) { System.out.printf("Vm %d Broker %d -> Start Time: %.0f Stop Time: %.0f Total Execution Time: %.0f\n", vm.getId(), vm.getBroker().getId(), vm.getStartTime(), vm.getStopTime(), vm.getTotalExecutionTime()); } System.out.println(); }
private void onClockTickListener(EventInfo eventInfo) { for (Vm vm : vmList) { System.out.printf("\t\tTime %6.1f: Vm %d Ram Usage: %6.2f%% (%4d of %4d MB)", eventInfo.getTime(), vm.getId(), vm.getRam().getPercentUtilization() * 100.0, vm.getRam().getAllocatedResource(), vm.getRam().getCapacity()); System.out.printf(" | Host Ram Allocation: %6.2f%% (%5d of %5d MB). Running Cloudlets: %d", vm.getHost().getRam().getPercentUtilization() * 100, vm.getHost().getRam().getAllocatedResource(), vm.getHost().getRam().getCapacity(), vm.getCloudletScheduler().getCloudletExecList().size()); } }