/** * Get the estimated completion time of a given cloudlet. * * @param rcl the cloudlet * @param time the time * @return the estimated finish time */ public double getEstimatedFinishTime(ResCloudlet rcl, double time) { return time + ((rcl.getRemainingCloudletLength()) / getTotalCurrentAllocatedMipsForCloudlet(rcl, time)); }
@Override public void cloudletFinish(ResCloudlet rcl) { rcl.setCloudletStatus(Cloudlet.SUCCESS); rcl.finalizeCloudlet(); getCloudletFinishedList().add(rcl); usedPes -= rcl.getNumberOfPes(); }
@Override public Cloudlet migrateCloudlet() { ResCloudlet rgl = getCloudletExecList().remove(0); rgl.finalizeCloudlet(); return rgl.getCloudlet(); }
/** * Get am Unique Identifier (UID) of the cloudlet. * * @return The UID */ public String getUid() { return getUserId() + "-" + getCloudletId(); }
if (rcl.getCloudletId() == cloudletId) { found = true; break; if ((currentCpus - usedPes) >= rcl.getNumberOfPes()) { rcl.setCloudletStatus(Cloudlet.INEXEC); for (int i = 0; i < rcl.getNumberOfPes(); i++) { rcl.setMachineAndPeId(0, i); long size = rcl.getRemainingCloudletLength(); size *= rcl.getNumberOfPes(); rcl.getCloudlet().setCloudletLength(size); usedPes += rcl.getNumberOfPes(); capacity /= cpus; long remainingLength = rcl.getRemainingCloudletLength(); double estimatedFinishTime = CloudSim.clock() + (remainingLength / (capacity * rcl.getNumberOfPes())); rcl.setCloudletStatus(Cloudlet.QUEUED); long size = rcl.getRemainingCloudletLength(); size *= rcl.getNumberOfPes(); rcl.getCloudlet().setCloudletLength(size);
if (rcl.getCloudletId() == cloudletId) { getCloudletFinishedList().remove(rcl); return rcl.getCloudlet(); if (rcl.getCloudletId() == cloudletId) { getCloudletExecList().remove(rcl); if (rcl.getRemainingCloudletLength() == 0) { cloudletFinish(rcl); } else { rcl.setCloudletStatus(Cloudlet.CANCELED); return rcl.getCloudlet(); if (rcl.getCloudletId() == cloudletId) { getCloudletPausedList().remove(rcl); return rcl.getCloudlet(); if (rcl.getCloudletId() == cloudletId) { rcl.setCloudletStatus(Cloudlet.CANCELED); getCloudletWaitingList().remove(rcl); return rcl.getCloudlet();
@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; }
@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()); }
@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; }
rcl.updateCloudletFinishedSoFar( (long) (capacity * timeSpam * rcl.getNumberOfPes() * Consts.MILLION)); for (ResCloudlet rcl : getCloudletExecList()) { if (rcl.getRemainingCloudletLength() == 0) { toRemove.add(rcl); cloudletFinish(rcl); toRemove.clear(); for (ResCloudlet rcl : getCloudletWaitingList()) { if ((currentCpus - usedPes) >= rcl.getNumberOfPes()) { rcl.setCloudletStatus(Cloudlet.INEXEC); for (int k = 0; k < rcl.getNumberOfPes(); k++) { rcl.setMachineAndPeId(0, i); usedPes += rcl.getNumberOfPes(); toRemove.add(rcl); break; double remainingLength = rcl.getRemainingCloudletLength(); double estimatedFinishTime = currentTime + (remainingLength / (capacity * rcl.getNumberOfPes())); if (estimatedFinishTime - currentTime < CloudSim.getMinTimeBetweenEvents()) { estimatedFinishTime = currentTime + CloudSim.getMinTimeBetweenEvents();
rcl.updateCloudletFinishedSoFar((long) (getCapacity(mipsShare) * timeSpam * rcl.getNumberOfPes() * Consts.MILLION)); List<ResCloudlet> toRemove = new ArrayList<ResCloudlet>(); for (ResCloudlet rcl : getCloudletExecList()) { long remainingLength = rcl.getRemainingCloudletLength(); if (remainingLength == 0) {// finished: remove from the list toRemove.add(rcl); + (rcl.getRemainingCloudletLength() / (getCapacity(mipsShare) * rcl.getNumberOfPes())); if (estimatedFinishTime - currentTime < CloudSim.getMinTimeBetweenEvents()) { estimatedFinishTime = currentTime + CloudSim.getMinTimeBetweenEvents();
rcl.updateCloudletFinishedSoFar((long) (timeSpan if (rcl.getRemainingCloudletLength() == 0) { // finished: remove from the list cloudletsToFinish.add(rcl); continue;
@Override public Cloudlet getNextFinishedCloudlet() { if (getCloudletFinishedList().size() > 0) { return getCloudletFinishedList().remove(0).getCloudlet(); } return null; }
@Override public void cloudletFinish(ResCloudlet rcl) { rcl.setCloudletStatus(Cloudlet.SUCCESS); rcl.finalizeCloudlet(); getCloudletFinishedList().add(rcl); }
@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 getTotalCurrentAvailableMipsForCloudlet(ResCloudlet rcl, List<Double> mipsShare) { double totalCurrentMips = 0.0; if (mipsShare != null) { int neededPEs = rcl.getNumberOfPes(); for (double mips : mipsShare) { totalCurrentMips += mips; neededPEs--; if (neededPEs <= 0) { break; } } } return totalCurrentMips; }
/** * Update under allocated mips for cloudlet. * * @param rcl the rgl * @param mips the mips */ public void updateUnderAllocatedMipsForCloudlet(ResCloudlet rcl, double mips) { if (getUnderAllocatedMips().containsKey(rcl.getUid())) { mips += getUnderAllocatedMips().get(rcl.getUid()); } getUnderAllocatedMips().put(rcl.getUid(), mips); }
/** * Allocates a new ResCloudlet object upon the arrival of a Cloudlet object. The arriving time * is determined by {@link gridsim.CloudSim#clock()}. * * @param cloudlet a cloudlet object * @see gridsim.CloudSim#clock() * @pre cloudlet != null * @post $none */ public ResCloudlet(Cloudlet cloudlet) { // when a new ResCloudlet is created, then it will automatically set // the submission time and other properties, such as remaining length this.cloudlet = cloudlet; startTime = 0; reservId = NOT_FOUND; duration = 0; init(); }
/** * Gets the position of a ResCloudlet with a given id. * * @param cloudletList the list of cloudlets. * @param id the cloudlet id * @return the position of the cloudlet with that id, or -1 if not found. */ public static <T extends ResCloudlet> int getPositionById(List<T> cloudletList, int id) { int i = 0 ; for (T cloudlet : cloudletList) { if (cloudlet.getCloudletId() == id) { return i; } i++; } return -1; } }
if (rcl.getCloudletId() == cloudletId) { found = true; break; if ((currentCpus - usedPes) >= rcl.getNumberOfPes()) { rcl.setCloudletStatus(Cloudlet.INEXEC); for (int i = 0; i < rcl.getNumberOfPes(); i++) { rcl.setMachineAndPeId(0, i); long size = rcl.getRemainingCloudletLength(); size *= rcl.getNumberOfPes(); rcl.getCloudlet().setCloudletLength(size); usedPes += rcl.getNumberOfPes(); capacity /= cpus; long remainingLength = rcl.getRemainingCloudletLength(); double estimatedFinishTime = CloudSim.clock() + (remainingLength / (capacity * rcl.getNumberOfPes())); rcl.setCloudletStatus(Cloudlet.QUEUED); long size = rcl.getRemainingCloudletLength(); size *= rcl.getNumberOfPes(); rcl.getCloudlet().setCloudletLength(size);