private String generateNotFinishedCloudletsWarning(final Vm vm) { final int cloudletsNoFinished = vm.getCloudletScheduler().getCloudletList().size(); if(cloudletsNoFinished == 0) { return ""; } return String.format( "It had a total of %d cloudlets (running + waiting). %s", cloudletsNoFinished, "Some events may have been missed. Try decreasing CloudSim's minTimeBetweenEvents attribute."); }
private void checkCloudletsCompletionForGivenVm(final Vm vm) { final List<Cloudlet> nonReturnedCloudlets = vm.getCloudletScheduler().getCloudletFinishedList().stream() .map(CloudletExecution::getCloudlet) .filter(cloudlet -> !vm.getCloudletScheduler().isCloudletReturned(cloudlet)) .collect(toList()); nonReturnedCloudlets.forEach(this::returnFinishedCloudletToBroker); }
private CloudletTaskScheduler getVmPacketScheduler(Vm vm) { return vm.getCloudletScheduler().getTaskScheduler(); }
/** * Processes a Cloudlet pause request. * * @param cloudlet cloudlet to be paused * @param ack indicates if the event's sender expects to receive an * acknowledge message when the event finishes to be processed */ protected void processCloudletPause(final Cloudlet cloudlet, final boolean ack) { cloudlet.getVm().getCloudletScheduler().cloudletPause(cloudlet); sendAck(ack, cloudlet, CloudSimTags.CLOUDLET_PAUSE_ACK); }
private void processCloudletFail(final SimEvent evt){ final Cloudlet cloudlet = (Cloudlet)evt.getData(); cloudlet.getVm().getCloudletScheduler().cloudletFail(cloudlet); }
/** * Clones each Cloudlet associated to a given VM. The method is called when * a VM is destroyed due to a Host failure and a snapshot from that VM (a * clone) is started into another Host. In this case, all the Cloudlets * which were running inside the destroyed VM will be recreated from scratch * into the VM clone, re-starting their execution from the beginning. * * @param sourceVm the VM to clone its Cloudlets * @return the List of cloned Cloudlets. * @see #createFaultInjectionForHosts(org.cloudbus.cloudsim.datacenters.Datacenter) */ private List<Cloudlet> cloneCloudlets(final Vm sourceVm) { final List<Cloudlet> sourceVmCloudlets = sourceVm.getCloudletScheduler().getCloudletList(); final List<Cloudlet> clonedCloudlets = new ArrayList<>(sourceVmCloudlets.size()); for (Cloudlet cl : sourceVmCloudlets) { clonedCloudlets.add(cloneCloudlet(cl, cl.getLength() - cl.getFinishedLengthSoFar())); } return clonedCloudlets; }
private void setPacketScheduler(final Vm vm) { final CloudletScheduler scheduler = vm.getCloudletScheduler(); if(!scheduler.isThereTaskScheduler()){ scheduler.setTaskScheduler(new CloudletTaskSchedulerSimple()); } }
/** * 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 processCloudletCancel(final SimEvent evt){ final Cloudlet cloudlet = (Cloudlet)evt.getData(); logCloudletStatusChange(cloudlet, "cancel execution of"); cloudlet.getVm().getCloudletScheduler().cloudletCancel(cloudlet); }
/** * Processes a Cloudlet cancel request. * * @param cloudlet cloudlet to be canceled */ protected void processCloudletCancel(final Cloudlet cloudlet) { cloudlet.getVm().getCloudletScheduler().cloudletCancel(cloudlet); sendNow(cloudlet.getBroker(), CloudSimTags.CLOUDLET_CANCEL, cloudlet); }
/** * Cancel a Cloudlet if it has already executed 50% of its total MIPS length. * @param e the event information about Cloudlet processing */ private void cancelCloudletIfHalfExecuted(final CloudletVmEventInfo e) { final Cloudlet cloudlet = e.getCloudlet(); if(cloudlet.getFinishedLengthSoFar() >= CLOUDLET_LENGTH / 2){ System.out.printf( "\n# %.2f: Intentionally cancelling %s execution after it has executed half of its length.\n", e.getTime(), cloudlet); cloudlet.getVm().getCloudletScheduler().cloudletCancel(cloudlet); } }
private void processCloudletPause(final SimEvent evt){ final Cloudlet cloudlet = (Cloudlet)evt.getData(); logCloudletStatusChange(cloudlet, "deschedule (pause)"); cloudlet.getVm().getCloudletScheduler().cloudletPause(cloudlet); }
/** * Notifies the broker about the end of execution of a given Cloudlet, * by returning the Cloudlet to it. * * @param cloudlet the Cloudlet to return to broker in order to notify it about the Cloudlet execution end */ private void returnFinishedCloudletToBroker(final Cloudlet cloudlet) { sendNow(cloudlet.getBroker(), CloudSimTags.CLOUDLET_RETURN, cloudlet); cloudlet.getVm().getCloudletScheduler().addCloudletToReturnedList(cloudlet); }
/** * Calculates the cost price of resources (processing, bw, memory, storage) * of each or all of the Datacenter VMs() * */ double getTotalCostPrice() { VmCost vmCost; double totalCost = 0.0; for (Vm vm : getVmList()) { if (vm.getCloudletScheduler().hasFinishedCloudlets()) { vmCost = new VmCost(vm); totalCost += vmCost.getTotalCost(); } else { System.out.printf( "\t%s didn't execute any Cloudlet.\n", vm); } } return totalCost; }
/** * 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 public void addUtilizationHistory(double time) { if (!enabled || isNotTimeToAddHistory(time)) { return; } final double utilization = vm.getCpuPercentUsage(vm.getCloudletScheduler().getPreviousTime()); time = vm.isIdle() ? time : (int)time; addUtilizationHistoryValue(time, utilization); this.previousTime = time; }
/** * Processes the end of execution of a given cloudlet inside a Vm. * * @param evt the cloudlet that has just finished to execute and was returned to the broker */ private void processCloudletReturn(final SimEvent evt) { final Cloudlet cloudlet = (Cloudlet) evt.getData(); cloudletsFinishedList.add(cloudlet); LOGGER.info("{}: {}: {} finished and returned to broker.", getSimulation().clock(), getName(), cloudlet); if (cloudlet.getVm().getCloudletScheduler().isEmpty()) { requestIdleVmDestruction(cloudlet.getVm()); return; } requestVmDestructionAfterAllCloudletsFinished(); }
/** * Sets the status of a received Cloudlet to {@link Cloudlet.Status#READY} * so that the Cloudlet can be selected to start running as soon as possible * by a {@link CloudletScheduler}. * * <p>This tag is commonly used when Cloudlets are created * from a trace file such as a {@link GoogleTaskEventsTraceReader Google Cluster Trace}.</p> * * @param evt the event data */ private void processCloudletReady(final SimEvent evt){ final Cloudlet cloudlet = (Cloudlet)evt.getData(); if(cloudlet.getStatus() == Cloudlet.Status.PAUSED) logCloudletStatusChange(cloudlet, "resume execution of"); else logCloudletStatusChange(cloudlet, "start executing"); cloudlet.getVm().getCloudletScheduler().cloudletReady(cloudlet); }
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()); } }
/** * Processes a Cloudlet resume request. * * @param cloudlet cloudlet to be resumed * @param ack indicates if the event's sender expects to receive an * acknowledge message when the event finishes to be processed */ protected void processCloudletResume(final Cloudlet cloudlet, final boolean ack) { final double estimatedFinishTime = cloudlet.getVm() .getCloudletScheduler().cloudletResume(cloudlet); if (estimatedFinishTime > 0.0 && estimatedFinishTime > getSimulation().clock()) { schedule(this, getCloudletProcessingUpdateInterval(estimatedFinishTime), CloudSimTags.VM_UPDATE_CLOUDLET_PROCESSING); } sendAck(ack, cloudlet, CloudSimTags.CLOUDLET_RESUME_ACK); }