/** The main function */ @Override public void run() { for (Iterator it = getTaskList().iterator(); it.hasNext(); ) { Task task = (Task) it.next(); double duration = task.getCloudletLength() / 1000; for (int i = 0; i < task.getParentList().size(); i++) { Task parent = task.getParentList().get(i); } for (int i = 0; i < task.getChildList().size(); i++) { Task child = task.getChildList().get(i); } int vmNum = getVmList().size(); /** Randomly choose a vm */ Random random = new Random((long) duration); int vmId = random.nextInt(vmNum); CondorVM vm = (CondorVM) getVmList().get(vmId); // This shows the cpu capability of a vm double mips = vm.getMips(); task.setVmId(vm.getId()); long deadline = Parameters.getDeadline(); } }
/** Update task set dependencies */ private void updateTaskSetDependencies() { Collection sets = mTask2TaskSet.values(); for (Iterator it = sets.iterator(); it.hasNext(); ) { TaskSet set = (TaskSet) it.next(); if (!set.hasChecked) { set.hasChecked = true; set.getChildList().clear(); set.getParentList().clear(); for (Task task : set.getTaskList()) { for (Iterator tIt = task.getParentList().iterator(); tIt.hasNext(); ) { Task parent = (Task) tIt.next(); TaskSet parentSet = (TaskSet) mTask2TaskSet.get(parent); if (!set.getParentList().contains(parentSet) && set != parentSet) { set.getParentList().add(parentSet); } } for (Iterator tIt = task.getChildList().iterator(); tIt.hasNext(); ) { Task child = (Task) tIt.next(); TaskSet childSet = (TaskSet) mTask2TaskSet.get(child); if (!set.getChildList().contains(childSet) && set != childSet) { set.getChildList().add(childSet); } } } } } // within each method cleanTaskSetChecked(); }
/** Add the pair from the mRecover. */ private void recover() { for (Iterator it = mRecover.entrySet().iterator(); it.hasNext(); ) { Entry entry = (Entry) it.next(); Task set = (Task) entry.getKey(); Task children = (Task) entry.getValue(); set.getChildList().add(children); children.getParentList().add(set); } }
/** Add pairs that needs to remove to mRecover. */ private void remove() { for (Task set : this.getTaskList()) { if (set.getChildList().size() >= 2) { for (int i = 0; i < set.getChildList().size(); i++) { Task children = (Task) set.getChildList().get(i); for (int j = i + 1; j < set.getChildList().size(); j++) { Task another = (Task) set.getChildList().get(j); // avoid unnecessary checks if (children.getDepth() > another.getDepth()) { if (check(another, children)) { // remove i set.getChildList().remove(children); children.getParentList().remove(set); i--; mRecover.put(set, children); // cleanTaskSetChecked(); break; } else { // cleanTaskSetChecked(); } } if (another.getDepth() > children.getDepth()) { if (check(children, another)) { set.getChildList().remove(another); another.getParentList().remove(set); i--; mRecover.put(set, another); // cleanTaskSetChecked(); break; } else { // cleanTaskSetChecked(); } } } } } } }