/** * 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; } }
/** * Get am Unique Identifier (UID) of the cloudlet. * * @return The UID */ public String getUid() { return getUserId() + "-" + getCloudletId(); }
/** * Finds the index of a ResCloudlet inside a list. * This method needs a combination of Cloudlet Id * and User Id because each Cloud User might have exactly the same Cloudlet Id. * * @param cloudletId a Cloudlet Id * @param userId an User Id * @param list the list of ResCloudlets * @return the index in this list of the first occurrence of the specified Cloudlet, or * <code>-1</code> if the list does not contain the Cloudlet. * @pre cloudletId >= 0 * @pre userId >= 0 * @post $none */ public static <T extends ResCloudlet> int indexOf(List<T> list, int cloudletId, int userId) { int i = 0; for (T rcl : list) { if (rcl.getCloudletId() == cloudletId && rcl.getUserId() == userId) { return i; } i++; } return -1; }
/** * Gets a {@link ResCloudlet} with a given id and owned by a given user. * This method needs a combination of Cloudlet Id and User Id because * each Cloud User might have exactly the same Cloudlet Id. * * @param cloudletId a Cloudlet Id * @param userId an User Id * @param list the list of ResCloudlet * @return a Cloudlet or null if not found * @pre cloudletId >= 0 * @pre userId >= 0 * @post $none * * @todo The second phrase of the class documentation is not clear. */ public static <T extends ResCloudlet> ResCloudlet getByIdAndUserId( List<T> list, int cloudletId, int userId) { for (T rcl : list) { if (rcl.getCloudletId() == cloudletId && rcl.getUserId() == userId) { return rcl; } } return null; }
@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 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(); } } for (ResCloudlet rcl : getCloudletWaitingList()) { if (rcl.getCloudletId() == cloudletId) { return rcl.getCloudletStatus(); } } return -1; }
@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(); } } for (ResCloudlet rcl : getCloudletWaitingList()) { if (rcl.getCloudletId() == cloudletId) { return rcl.getCloudletStatus(); } } return -1; }
/** * Gets the status of a cloudlet. * * @param cloudletId ID of the cloudlet * @return status of the cloudlet, -1 if cloudlet not found * @pre $none * @post $none */ @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; }
if (rcl.getCloudletId() == cloudletId) { getCloudletFinishedList().remove(rcl); return rcl.getCloudlet(); if (rcl.getCloudletId() == cloudletId) { getCloudletExecList().remove(rcl); if (rcl.getRemainingCloudletLength() == 0) { if (rcl.getCloudletId() == cloudletId) { getCloudletPausedList().remove(rcl); return rcl.getCloudlet(); if (rcl.getCloudletId() == cloudletId) { rcl.setCloudletStatus(Cloudlet.CANCELED); getCloudletWaitingList().remove(rcl);
@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; }
if (rcl.getCloudletId() == cloudletId) { getCloudletFinishedList().remove(rcl); return rcl.getCloudlet(); if (rcl.getCloudletId() == cloudletId) { getCloudletExecList().remove(rcl); if (rcl.getRemainingCloudletLength() == 0.0) { if (rcl.getCloudletId() == cloudletId) { getCloudletPausedList().remove(rcl); return rcl.getCloudlet(); if (rcl.getCloudletId() == cloudletId) { rcl.setCloudletStatus(Cloudlet.CANCELED); getCloudletWaitingList().remove(rcl);
if (rcl.getCloudletId() == cloudletId) { found = true; break;
if (rcl.getCloudletId() == cloudletId) { found = true; break; found = false; for (ResCloudlet rcl : getCloudletWaitingList()) { if (rcl.getCloudletId() == cloudletId) { found = true; break;
if (rcl.getCloudletId() == cloudletId) { found = true; break; found = false; for (ResCloudlet rcl : getCloudletWaitingList()) { if (rcl.getCloudletId() == cloudletId) { found = true; break;
if (rcl.getCloudletId() == cloudletId) { found = true; break; if (rcl.getCloudletId() == cloudletId) { found = true; break; position=0; for (ResCloudlet rcl : getCloudletPausedList()) { if (rcl.getCloudletId() == cloudletId) { found = true; rcl.setCloudletStatus(Cloudlet.CANCELED);
if (rcl.getCloudletId() == cloudletId) { found = true; break; if (rcl.getCloudletId() == cloudletId) { found = true; break; position = 0; for (ResCloudlet rcl : getCloudletPausedList()) { if (rcl.getCloudletId() == cloudletId) { found = true; rcl.setCloudletStatus(Cloudlet.CANCELED);
@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; }
if (rcl.getCloudletId() == cloudletId) { found = true; break;
if (rcl.getCloudletId() == cloudletId) { found = true; break;
if (rcl.getCloudletId() == cloudletId) { found = true; break;