@Override public int runningCloudlets() { return getCloudletExecList().size(); }
@Override public Cloudlet migrateCloudlet() { ResCloudlet rgl = getCloudletExecList().remove(0); rgl.finalizeCloudlet(); return rgl.getCloudlet(); }
/** * Gets the individual MIPS capacity available for each PE available for the scheduler, * considering that all PEs have the same capacity. * * @param mipsShare list with MIPS share of each PE available to the scheduler * @return the capacity of each PE */ protected double getCapacity(List<Double> mipsShare) { double capacity = 0.0; int cpus = 0; for (Double mips : mipsShare) { capacity += mips; if (mips > 0.0) { cpus++; } } currentCPUs = cpus; int pesInUse = 0; for (ResCloudlet rcl : getCloudletExecList()) { pesInUse += rcl.getNumberOfPes(); } if (pesInUse > currentCPUs) { capacity /= pesInUse; } else { capacity /= currentCPUs; } return capacity; }
@Override public double getTotalUtilizationOfCpu(double time) { /* * @todo */ double totalUtilization = 0; for (ResCloudlet gl : getCloudletExecList()) { totalUtilization += gl.getCloudlet().getUtilizationOfCpu(time); } return totalUtilization; }
@Override public boolean cloudletPause(int cloudletId) { boolean found = false; int position = 0; for (ResCloudlet rcl : getCloudletExecList()) { if (rcl.getCloudletId() == cloudletId) { found = true; break; } position++; } if (found) { // remove cloudlet from the exec list and put it in the paused list ResCloudlet rcl = getCloudletExecList().remove(position); if (rcl.getRemainingCloudletLength() == 0) { cloudletFinish(rcl); } else { rcl.setCloudletStatus(Cloudlet.PAUSED); getCloudletPausedList().add(rcl); } return true; } return false; }
double timeSpam = currentTime - getPreviousTime(); for (ResCloudlet rcl : getCloudletExecList()) { rcl.updateCloudletFinishedSoFar((long) (getCapacity(mipsShare) * timeSpam * rcl.getNumberOfPes() * Consts.MILLION)); if (getCloudletExecList().size() == 0) { setPreviousTime(currentTime); return 0.0; for (ResCloudlet rcl : getCloudletExecList()) { long remainingLength = rcl.getRemainingCloudletLength(); if (remainingLength == 0) {// finished: remove from the list getCloudletExecList().removeAll(toRemove); for (ResCloudlet rcl : getCloudletExecList()) { double estimatedFinishTime = currentTime + (rcl.getRemainingCloudletLength() / (getCapacity(mipsShare) * rcl.getNumberOfPes()));
@Override public int getCloudletStatus(int cloudletId) { for (ResCloudlet rcl : getCloudletExecList()) { if (rcl.getCloudletId() == cloudletId) { return rcl.getCloudletStatus(); } } for (ResCloudlet rcl : getCloudletPausedList()) { if (rcl.getCloudletId() == cloudletId) { return rcl.getCloudletStatus(); } } return -1; }
@Override public double cloudletResume(int cloudletId) { boolean found = false; int position = 0; // look for the cloudlet in the paused list for (ResCloudlet rcl : getCloudletPausedList()) { if (rcl.getCloudletId() == cloudletId) { found = true; break; } position++; } if (found) { ResCloudlet rgl = getCloudletPausedList().remove(position); rgl.setCloudletStatus(Cloudlet.INEXEC); getCloudletExecList().add(rgl); // calculate the expected time for cloudlet completion // first: how many PEs do we have? double remainingLength = rgl.getRemainingCloudletLength(); double estimatedFinishTime = CloudSim.clock() + (remainingLength / (getCapacity(getCurrentMipsShare()) * rgl.getNumberOfPes())); return estimatedFinishTime; } return 0.0; }
for (ResCloudlet rcl : getCloudletExecList()) { if (rcl.getCloudletId() == cloudletId) { found = true; ResCloudlet rcl = getCloudletExecList().remove(position); if (rcl.getRemainingCloudletLength() == 0) { cloudletFinish(rcl);
@Override public double cloudletSubmit(Cloudlet cloudlet, double fileTransferTime) { ResCloudlet rcl = new ResCloudlet(cloudlet); rcl.setCloudletStatus(Cloudlet.INEXEC); for (int i = 0; i < cloudlet.getNumberOfPes(); i++) { rcl.setMachineAndPeId(0, i); } getCloudletExecList().add(rcl); // use the current capacity to estimate the extra amount of // time to file transferring. It must be added to the cloudlet length double extraSize = getCapacity(getCurrentMipsShare()) * fileTransferTime; long length = (long) (cloudlet.getCloudletLength() + extraSize); cloudlet.setCloudletLength(length); return cloudlet.getCloudletLength() / getCapacity(getCurrentMipsShare()); }