@Override public double cloudletSubmit(Cloudlet cl) { return cloudletSubmit(cl, 0); }
@Override public List<Double> getCurrentRequestedMips() { if (getCachePreviousTime() == getPreviousTime()) { return getCacheCurrentRequestedMips(); } List<Double> currentMips = new ArrayList<Double>(); double totalMips = getTotalUtilizationOfCpu(getPreviousTime()) * getTotalMips(); double mipsForPe = totalMips / getNumberOfPes(); for (int i = 0; i < getNumberOfPes(); i++) { currentMips.add(mipsForPe); } setCachePreviousTime(getPreviousTime()); setCacheCurrentRequestedMips(currentMips); return currentMips; }
@Override public double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl, double time) { double totalCurrentRequestedMips = getTotalCurrentRequestedMipsForCloudlet(rcl, time); double totalCurrentAvailableMips = getTotalCurrentAvailableMipsForCloudlet(rcl, getCurrentMipsShare()); if (totalCurrentRequestedMips > totalCurrentAvailableMips) { return totalCurrentAvailableMips; } return totalCurrentRequestedMips; }
/** * Instantiates a new VM scheduler * * @param mips The individual MIPS capacity of each PE allocated to the VM using the scheduler, * considering that all PEs have the same capacity. * @param numberOfPes The number of PEs allocated to the VM using the scheduler. */ public CloudletSchedulerDynamicWorkload(double mips, int numberOfPes) { super(); setMips(mips); setNumberOfPes(numberOfPes); /*@todo There shouldn't be a setter to total mips, considering that it is computed from number of PEs and mips. If the number of pes of mips is set any time after here, the total mips will be wrong. Just the getTotalMips is enough, and it have to compute there the total, instead of storing into an attribute.*/ setTotalMips(getNumberOfPes() * getMips()); setUnderAllocatedMips(new HashMap<String, Double>()); setCachePreviousTime(-1); }
@Override public double updateVmProcessing(double currentTime, List<Double> mipsShare) { setCurrentMipsShare(mipsShare); double timeSpan = currentTime - getPreviousTime(); double nextEvent = Double.MAX_VALUE; List<ResCloudlet> cloudletsToFinish = new ArrayList<ResCloudlet>(); for (ResCloudlet rcl : getCloudletExecList()) { rcl.updateCloudletFinishedSoFar((long) (timeSpan * getTotalCurrentAllocatedMipsForCloudlet(rcl, getPreviousTime()) * Consts.MILLION)); continue; } else { // not finish: estimate the finish time double estimatedFinishTime = getEstimatedFinishTime(rcl, currentTime); if (estimatedFinishTime - currentTime < CloudSim.getMinTimeBetweenEvents()) { estimatedFinishTime = currentTime + CloudSim.getMinTimeBetweenEvents(); getCloudletExecList().remove(rgl); cloudletFinish(rgl); setPreviousTime(currentTime); if (getCloudletExecList().isEmpty()) { return 0;
@Override public double cloudletSubmit(Cloudlet cl, double fileTransferTime) { ResCloudlet rcl = new ResCloudlet(cl); rcl.setCloudletStatus(Cloudlet.INEXEC); for (int i = 0; i < cl.getNumberOfPes(); i++) { rcl.setMachineAndPeId(0, i); } getCloudletExecList().add(rcl); return getEstimatedFinishTime(rcl, getPreviousTime()); }
/** * Gets the total current mips available for the VM using the scheduler. * The total is computed from the {@link #getCurrentMipsShare()} * * @return the total current mips */ public int getTotalCurrentMips() { int totalCurrentMips = 0; for (double mips : getCurrentMipsShare()) { totalCurrentMips += mips; } return totalCurrentMips; }
/** * Creates the vm list. * * @param brokerId the broker id * @param vmsNumber the vms number * * @return the list< vm> */ public static List<Vm> createVmList(int brokerId, int vmsNumber) { List<Vm> vms = new ArrayList<Vm>(); for (int i = 0; i < vmsNumber; i++) { int vmType = i / (int) Math.ceil((double) vmsNumber / Constants.VM_TYPES); vms.add(new PowerVm( i, brokerId, Constants.VM_MIPS[vmType], Constants.VM_PES[vmType], Constants.VM_RAM[vmType], Constants.VM_BW, Constants.VM_SIZE, 1, "Xen", new CloudletSchedulerDynamicWorkload(Constants.VM_MIPS[vmType], Constants.VM_PES[vmType]), Constants.SCHEDULING_INTERVAL)); } return vms; }
@Override public void cloudletFinish(ResCloudlet rcl) { rcl.setCloudletStatus(Cloudlet.SUCCESS); rcl.finalizeCloudlet(); getCloudletFinishedList().add(rcl); }
@Override public double getTotalUtilizationOfCpu(double time) { double totalUtilization = 0; for (ResCloudlet rcl : getCloudletExecList()) { totalUtilization += rcl.getCloudlet().getUtilizationOfCpu(time); } return totalUtilization; }