Changeset 1207 for DCWoRMS/branches/coolemall/src/dcworms
- Timestamp:
- 11/26/13 11:56:07 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java
r1191 r1207 5 5 import schedframe.scheduling.tasks.TaskInterface; 6 6 import schedframe.scheduling.tasks.phases.ResourceConsumption; 7 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 7 8 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 8 9 … … 15 16 public List<String> getVisitedResources(); 16 17 18 public ResourceConsumptionProfile getResourceConsumptionProfile(); 17 19 public ResourceConsumption getCurrentResourceConsumption(); 18 20 } -
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java
r1157 r1207 2 2 3 3 4 import example.energy.coolemall.CoolEmAllTestbedMeasurements; 4 5 import gridsim.GridSim; 5 6 import gridsim.dcworms.DCWormsTags; … … 7 8 import java.util.ArrayList; 8 9 import java.util.HashMap; 10 import java.util.LinkedList; 9 11 import java.util.List; 10 12 import java.util.Map; … … 14 16 import org.joda.time.DateTimeUtilsExt; 15 17 import org.joda.time.ReadableDuration; 18 import org.qcg.broker.schemas.resreqs.ResourceConsumptionProfileType; 19 import org.qcg.broker.schemas.resreqs.ResourceConsumptionType; 20 import org.qcg.broker.schemas.resreqs.StringParameterType; 16 21 17 22 import qcg.shared.constants.BrokerConstants; 18 23 19 24 import schedframe.resources.computing.ComputingResource; 25 import schedframe.resources.units.PEUnit; 20 26 import schedframe.resources.units.ProcessingElements; 21 27 import schedframe.resources.units.StandardResourceUnitName; … … 30 36 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 31 37 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 38 import simulator.stats.implementation.ResourceUsefulWorkStats; 32 39 33 40 /** … … 60 67 protected double finishTime; 61 68 69 private ResourceConsumptionProfile resourceConsumptionProfile; 70 62 71 public Executable(Task t){ 63 72 this.task = t; … … 83 92 this.submissionTime = currentTime; 84 93 this.totalCompletionTime = 0.0; 94 preparePhases(null); 85 95 } 86 96 … … 168 178 169 179 if(status == DCWormsTags.INEXEC){ 180 loadResourceConsumptionProfile(); 170 181 task.setStatus((int) BrokerConstants.TASK_STATUS_RUNNING); 171 182 } else if(status == DCWormsTags.QUEUED){ … … 202 213 for (ComputingResource resource : pes) { 203 214 204 trackResource(resource.get Name());215 trackResource(resource.getFullName()); 205 216 206 217 ComputingResource parent = resource.getParent(); 207 218 List<String> visitedResource = getVisitedResources(); 208 219 String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]); 209 while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.get Name())) {210 trackResource(parent.get Name());220 while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getFullName())) { 221 trackResource(parent.getFullName()); 211 222 parent = parent.getParent(); 212 223 } … … 218 229 status = DCWormsTags.INEXEC; 219 230 setCompletionPercentage(0); 220 task.getResourceConsumptionProfile().setCurrentPhase(task.getResourceConsumptionProfile().getCurrentPhase() + 1);231 resourceConsumptionProfile.setCurrentPhase(resourceConsumptionProfile.getCurrentPhase() + 1); 221 232 222 233 DateTime currentDateTime = new DateTime(); … … 386 397 387 398 public ResourceConsumptionProfile getResourceConsumptionProfile(){ 388 return task.getResourceConsumptionProfile();399 return resourceConsumptionProfile; 389 400 } 390 401 391 402 public ResourceConsumption getCurrentResourceConsumption(){ 392 return task.getResourceConsumptionProfile().getCurrentResourceConsumption();403 return resourceConsumptionProfile.getCurrentResourceConsumption(); 393 404 } 394 405 … … 396 407 return task.getApplicationName(); 397 408 } 398 409 410 private void preparePhases(String resourceType) { 411 LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>(); 412 413 long usefulWork = -1; 414 415 if(task.getDescription().getExecution() == null || task.getDescription().getExecution().getResourceConsumptionProfile() == null 416 || task.getDescription().getExecution().getResourceConsumptionProfile().length == 0 ){ 417 ResourceConsumption resConsumption = null; 418 try { 419 resConsumption = new ResourceConsumption(getLength(), task.getComputingResourceRequirements()); 420 } catch (NoSuchFieldException e) { 421 // TODO Auto-generated catch block 422 e.printStackTrace(); 423 } 424 resourceConsumptionList.add(resConsumption); 425 }else{ 426 boolean found = false; 427 if(resourceType != null){ 428 for(ResourceConsumptionProfileType resConsumptioProfile: task.getDescription().getExecution().getResourceConsumptionProfile()){ 429 if(resConsumptioProfile.getType() != null && resConsumptioProfile.getType().equals(resourceType)){ 430 for(ResourceConsumptionType resConsumption: resConsumptioProfile.getResourceConsumption()){ 431 ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption); 432 resourceConsumptionList.add(resourceConsumption); 433 } 434 for(StringParameterType prop: resConsumptioProfile.getProperties()){ 435 if(prop.getName().equals("usefulWork")){ 436 usefulWork = Double.valueOf(prop.getContent()).longValue(); 437 break; 438 } 439 } 440 found = true; 441 break; 442 } 443 } 444 } 445 if(!found){ 446 for(ResourceConsumptionType resConsumption: task.getDescription().getExecution().getResourceConsumptionProfile()[0].getResourceConsumption()){ 447 ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption); 448 resourceConsumptionList.add(resourceConsumption); 449 } 450 451 for(StringParameterType prop: task.getDescription().getExecution().getResourceConsumptionProfile()[0].getProperties()){ 452 if(prop.getName().equals("usefulWork")){ 453 usefulWork = Double.valueOf(prop.getContent()).longValue(); 454 break; 455 } 456 } 457 } 458 } 459 460 usefulWork = (usefulWork != -1) ? usefulWork : this.getLength(); 461 this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList); 462 this.resourceConsumptionProfile.setUsefulWork(usefulWork); 463 464 } 465 466 private boolean loadResourceConsumptionProfile(){ 467 468 PEUnit peUnit = (PEUnit)getUsedResources().getLast().getResourceUnits() 469 .get(StandardResourceUnitName.PE); 470 if(peUnit instanceof ProcessingElements){ 471 ProcessingElements pes = (ProcessingElements) peUnit; 472 for (ComputingResource resource : pes) { 473 while(resource != null && resource.getResourceCharacteristic().getParameters().get("product") == null){ 474 resource = resource.getParent(); 475 } 476 if(resource != null) { 477 String productName = resource.getResourceCharacteristic().getParameters().get("product").get(0).getContent(); 478 if(productName.equals("Fusion G - T40N")) 479 preparePhases("amdf"); 480 else if(productName.equals("Atom - D510")) 481 preparePhases("atom64"); 482 else if(productName.equals("Atom - N2600")) 483 preparePhases("atom64"); 484 else if(productName.equals("Core i7 - 2715QE")) 485 preparePhases("i7-2715QE"); 486 else if(productName.equals("Core i7 - 3615QE")) 487 preparePhases("i7-3615QE"); 488 } 489 return true; 490 } 491 } 492 return false; 493 494 } 399 495 }
Note: See TracChangeset
for help on using the changeset viewer.