- Timestamp:
- 06/03/14 15:12:11 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java
r1207 r1362 1 1 package dcworms.schedframe.scheduling; 2 2 3 import java.util.Li st;3 import java.util.LinkedList; 4 4 5 import schedframe.scheduling.ExecutionHistoryItem; 6 import schedframe.scheduling.ResourceHistoryItem; 5 7 import schedframe.scheduling.tasks.TaskInterface; 6 8 import schedframe.scheduling.tasks.phases.ResourceConsumption; 7 import schedframe.scheduling.tasks.phases. ResourceConsumptionProfile;9 import schedframe.scheduling.tasks.phases.ExecutionProfile; 8 10 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 9 11 … … 12 14 public boolean expectSpecificResource(ResourceParameterName resourceName); 13 15 public Object getExpectedSpecificResource(ResourceParameterName resourceName); 14 15 public void trackResource(String resName);16 public List<String> getVisitedResources();17 16 18 public ResourceConsumptionProfile getResourceConsumptionProfile(); 17 public LinkedList<ExecutionHistoryItem> getExecHistory(); 18 public LinkedList<ResourceHistoryItem> getAllocatedResources(); 19 20 public ExecutionProfile getResourceConsumptionProfile(); 19 21 public ResourceConsumption getCurrentResourceConsumption(); 22 23 public String getSchedulerName(); 20 24 } -
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java
r1315 r1362 5 5 import gridsim.dcworms.DCWormsTags; 6 6 7 import java.util.ArrayList;8 7 import java.util.HashMap; 9 8 import java.util.LinkedList; … … 11 10 import java.util.Map; 12 11 13 import org.apache.commons.lang.ArrayUtils;14 12 import org.joda.time.DateTime; 15 13 import org.joda.time.DateTimeUtilsExt; … … 25 23 import schedframe.resources.units.ProcessingElements; 26 24 import schedframe.resources.units.StandardResourceUnitName; 25 import schedframe.scheduling.ExecutionHistoryItem; 27 26 import schedframe.scheduling.ResourceHistoryItem; 28 import schedframe.scheduling.UsedResourcesList;29 27 import schedframe.scheduling.WorkloadUnitHandler; 30 28 import schedframe.scheduling.manager.tasks.JobRegistryImpl; … … 33 31 import schedframe.scheduling.tasks.Task; 34 32 import schedframe.scheduling.tasks.phases.ResourceConsumption; 35 import schedframe.scheduling.tasks.phases. ResourceConsumptionProfile;33 import schedframe.scheduling.tasks.phases.ExecutionProfile; 36 34 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 37 35 … … 53 51 54 52 protected int estimatedDuration; 55 //TO DO remove and benefit from visitedResources56 53 protected String schedName; 57 protected UsedResourcesList usedResources;58 //TO DO consider removing59 protected List<String> visitedResources;60 54 61 55 protected double submissionTime; 62 56 protected double arrivalTime; 63 protected double execStartTime 57 protected double execStartTime; 64 58 protected double totalCompletionTime; 65 59 protected double finishTime; 66 60 67 private ResourceConsumptionProfile resourceConsumptionProfile; 61 private boolean firstTime = true; 62 protected double execStartTimeFirst; 63 64 protected ExecutionProfile execProfile; 65 66 protected LinkedList<ExecutionHistoryItem> execHistory;; 67 protected LinkedList<ResourceHistoryItem> allocatedResources; 68 68 69 69 public Executable(Task t){ 70 70 this.task = t; 71 71 this.status = DCWormsTags.CREATED; 72 73 this. usedResources = new UsedResourcesList();74 this. visitedResources = new ArrayList<String>();72 73 this.allocatedResources = new LinkedList<ResourceHistoryItem>(); 74 this.execHistory = new LinkedList<ExecutionHistoryItem>(); 75 75 init(); 76 76 } … … 81 81 this.processesSetId = procesesSet.getId(); 82 82 83 this. usedResources = new UsedResourcesList();84 this. visitedResources = new ArrayList<String>();83 this.allocatedResources = new LinkedList<ResourceHistoryItem>(); 84 this.execHistory = new LinkedList<ExecutionHistoryItem>(); 85 85 init(); 86 86 } … … 88 88 protected void init() { 89 89 double currentTime = DateTimeUtilsExt.currentTimeMillis() / 1000; 90 this.arrivalTime = currentTime; 90 91 this.submissionTime = currentTime; 91 92 this.totalCompletionTime = 0.0; … … 168 169 } 169 170 170 if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags. NEW_EXEC_PHASE) {171 if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.FAILED) { 171 172 throw new Exception("Executable.setStatuts() : Error - " + 172 "Invalid integer range for Exec iutable status.");173 "Invalid integer range for Executable status."); 173 174 } 174 175 … … 189 190 } 190 191 191 if(newStatus == DCWormsTags.SUBMITTED){192 /*if(newStatus == DCWormsTags.SUBMITTED){ 192 193 arrivalTime = GridSim.clock(); 193 } 194 195 if (prevStatus == DCWormsTags.INEXEC) { 196 if (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED || 197 status == DCWormsTags.SUCCESS) { 194 }*/ 195 196 if ((prevStatus == DCWormsTags.INEXEC) && (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED || 197 status == DCWormsTags.SUCCESS)){ 198 198 totalCompletionTime += (currentTime - execStartTime); 199 execStartTime = execStartTimeFirst; 200 } 201 202 /*if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) { 203 totalCompletionTime += (currentTime - execStartTime); 204 }*/ 205 206 if(prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED){ 207 208 } 209 if (status == DCWormsTags.INEXEC) { 210 211 execStartTime = currentTime; 212 if (firstTime){ 213 execStartTimeFirst = currentTime; 214 firstTime = false; 199 215 } 200 216 } 201 202 if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) {203 totalCompletionTime += (currentTime - execStartTime);204 }205 206 if (status == DCWormsTags.INEXEC ||207 (prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED) ) {208 execStartTime = currentTime;209 210 ProcessingElements pes = (ProcessingElements) getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);211 for (ComputingResource resource : pes) {212 213 LinkedList<ComputingResource> toExamine = new LinkedList<ComputingResource>();214 toExamine.push(resource);215 216 while (!toExamine.isEmpty()) {217 ComputingResource compResource = toExamine.pop();218 List<ComputingResource> resources = compResource.getChildren();219 int numberOfRes = resources.size();220 for (int i = 0; i < numberOfRes; i++) {221 ComputingResource resourceChild = resources.get(i);222 trackResource(resourceChild.getFullName());223 toExamine.addLast(resourceChild);224 }225 }226 227 228 trackResource(resource.getFullName());229 230 ComputingResource parent = resource.getParent();231 List<String> visitedResource = getVisitedResources();232 String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]);233 while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getFullName())) {234 trackResource(parent.getFullName());235 parent = parent.getParent();236 }237 }238 }239 217 240 if(status == DCWormsTags.NEW_EXEC_PHASE){ 241 if(prevStatus == DCWormsTags.INEXEC){ 242 status = DCWormsTags.INEXEC; 243 setCompletionPercentage(0); 244 resourceConsumptionProfile.setCurrentPhase(resourceConsumptionProfile.getCurrentPhase() + 1); 245 246 DateTime currentDateTime = new DateTime(); 247 248 if(getUsedResources().getLast().getTimeStamp().getMillis() == currentDateTime.getMillis()){ 249 return; 250 } 251 ResourceHistoryItem resHistItem = new ResourceHistoryItem(getUsedResources().getLast().getResourceUnits(), currentDateTime); 252 resHistItem.setCompletionPercentage(0); 253 addUsedResources(resHistItem); 254 } 255 } 218 if(status == DCWormsTags.NEW_EXEC_PHASE && prevStatus == DCWormsTags.INEXEC){ 219 status = DCWormsTags.INEXEC; 220 completionPercentage = 0; 221 execProfile.setCurrentPhase(execProfile.getCurrentPhase() + 1); 222 } 223 256 224 } 257 225 … … 295 263 } 296 264 297 public void addUsedResources(ResourceHistoryItem usedResources){298 this.usedResources.add(usedResources);299 }300 301 public UsedResourcesList getUsedResources(){302 return this.usedResources;303 }304 305 265 public void setSchedulerName(int resourceId){ 306 266 this.schedName = GridSim.getEntityName(resourceId); 307 267 } 268 269 public void setSchedulerName(String resourceId){ 270 this.schedName = resourceId; 271 } 308 272 309 273 public String getSchedulerName(){ … … 326 290 task.register(jobRegistry); 327 291 } 328 329 public void trackResource(String resName){ 330 visitedResources.add(resName); 331 } 332 333 public List<String> getVisitedResources(){ 334 return visitedResources; 335 } 336 292 337 293 public ReadableDuration getExpectedDuration() throws NoSuchFieldException { 338 294 return task.getExpectedDuration(); … … 410 366 }*/ 411 367 412 public ResourceConsumptionProfile getResourceConsumptionProfile(){413 return resourceConsumptionProfile;368 public ExecutionProfile getResourceConsumptionProfile(){ 369 return execProfile; 414 370 } 415 371 416 372 public ResourceConsumption getCurrentResourceConsumption(){ 417 return resourceConsumptionProfile.getCurrentResourceConsumption();373 return execProfile.getCurrentResourceConsumption(); 418 374 } 419 375 … … 437 393 } 438 394 resourceConsumptionList.add(resConsumption); 439 } else{395 } else { 440 396 boolean found = false; 441 397 if(resourceType != null){ … … 473 429 474 430 usefulWork = (usefulWork != -1) ? usefulWork : this.getLength(); 475 this. resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList);476 this. resourceConsumptionProfile.setUsefulWork(usefulWork);431 this.execProfile = new ExecutionProfile(resourceConsumptionList); 432 this.execProfile.setUsefulWork(usefulWork); 477 433 478 434 } … … 480 436 private boolean loadResourceConsumptionProfile(){ 481 437 482 PEUnit peUnit = (PEUnit)get UsedResources().getLast().getResourceUnits()438 PEUnit peUnit = (PEUnit)getAllocatedResources().getLast().getResourceUnits() 483 439 .get(StandardResourceUnitName.PE); 484 440 if(peUnit instanceof ProcessingElements){ … … 513 469 514 470 } 471 472 public LinkedList<ExecutionHistoryItem> getExecHistory() { 473 return execHistory; 474 } 475 476 public void addExecHistory(ExecutionHistoryItem execHistoryItem) { 477 this.execHistory.add(execHistoryItem); 478 } 479 480 public LinkedList<ResourceHistoryItem> getAllocatedResources() { 481 return allocatedResources; 482 } 483 484 public void addAllocatedResources(ResourceHistoryItem allocatedResourcesItem) { 485 this.allocatedResources.add(allocatedResourcesItem); 486 } 515 487 }
Note: See TracChangeset
for help on using the changeset viewer.