Changeset 1207 for DCWoRMS/branches/coolemall/src
- Timestamp:
- 11/26/13 11:56:07 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src
- Files:
-
- 43 added
- 1 deleted
- 86 edited
- 3 copied
- 3 moved
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 } -
DCWoRMS/branches/coolemall/src/example/energy/BaseEnergyEstimationPlugin.java
r751 r1207 3 3 import schedframe.Parameters; 4 4 import schedframe.PluginConfiguration; 5 import schedframe.resources.computing.ComputingResource;6 5 import schedframe.resources.computing.profiles.energy.EnergyEvent; 7 6 import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; 7 import schedframe.resources.devices.PhysicalResource; 8 8 import schedframe.scheduling.manager.tasks.JobRegistry; 9 9 … … 17 17 18 18 @Override 19 public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {19 public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 20 20 throw new RuntimeException("Not implemented."); 21 21 } 22 22 23 23 @Override 24 public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResourceresource) {24 public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 25 25 throw new RuntimeException("Not implemented."); 26 26 } -
DCWoRMS/branches/coolemall/src/example/energy/DataCenterEnergyEstimationPlugin.java
r520 r1207 2 2 3 3 import schedframe.resources.computing.ComputingNode; 4 import schedframe.resources.computing.ComputingResource;5 4 import schedframe.resources.computing.DataCenter; 6 5 import schedframe.resources.computing.profiles.energy.EnergyEvent; 7 6 import schedframe.resources.computing.profiles.energy.power.PowerUsage; 7 import schedframe.resources.devices.PhysicalResource; 8 8 import schedframe.scheduling.manager.tasks.JobRegistry; 9 9 … … 12 12 @Override 13 13 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 14 ComputingResource resource) {14 PhysicalResource resource) { 15 15 double power = 0; 16 16 DataCenter dataCenter = (DataCenter)resource; -
DCWoRMS/branches/coolemall/src/example/energy/DefaultEnergyEstimationPlugin.java
r546 r1207 3 3 import schedframe.resources.computing.ComputingResource; 4 4 import schedframe.resources.computing.profiles.energy.EnergyEvent; 5 import schedframe.resources.devices.PhysicalResource; 5 6 import schedframe.scheduling.manager.tasks.JobRegistry; 6 7 … … 9 10 10 11 11 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {12 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 12 13 double powerConsumption = 0; 13 14 try { … … 17 18 } 18 19 19 powerConsumption = powerConsumption + getChildrenPowerConsumption(resource); 20 21 for(ComputingResource child:resource.getChildren()){ 22 try { 23 //powerConsumption = powerConsumption + child.getPowerInterface().getRecentPowerUsage().getValue(); 24 } catch (Exception e) { 20 ComputingResource cr = (ComputingResource) resource; 21 powerConsumption = powerConsumption + getChildrenPowerConsumption(cr); 25 22 26 }27 }28 23 return powerConsumption; 29 24 } -
DCWoRMS/branches/coolemall/src/example/energy/NodeEnergyEstimationPlugin.java
r532 r1207 2 2 3 3 import schedframe.resources.computing.ComputingNode; 4 import schedframe.resources.computing.ComputingResource;5 4 import schedframe.resources.computing.Processor; 6 5 import schedframe.resources.computing.profiles.energy.EnergyEvent; 6 import schedframe.resources.devices.Device; 7 import schedframe.resources.devices.PhysicalResource; 7 8 import schedframe.scheduling.manager.tasks.JobRegistry; 8 9 9 public class ComputingNodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {10 public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { 10 11 11 12 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 12 ComputingResource resource) {13 PhysicalResource resource) { 13 14 double powerConsumption = 0; 14 15 ComputingNode node = (ComputingNode) resource; … … 22 23 try { 23 24 powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); 25 for(Device dev: node.getResourceCharacteristic().getDevices()){ 26 powerConsumption = powerConsumption + dev.getPowerInterface().getRecentPowerUsage().getValue(); 27 } 24 28 } catch (NoSuchFieldException e) { 25 29 } -
DCWoRMS/branches/coolemall/src/example/energy/ProcessorEnergyEstimationPlugin.java
r901 r1207 2 2 3 3 import schedframe.resources.ResourceStatus; 4 import schedframe.resources.computing.ComputingResource;5 4 import schedframe.resources.computing.Processor; 6 5 import schedframe.resources.computing.profiles.energy.EnergyEvent; 7 6 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 7 import schedframe.resources.devices.PhysicalResource; 8 8 import schedframe.scheduling.manager.tasks.JobRegistry; 9 9 … … 11 11 12 12 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 13 ComputingResource resource) {13 PhysicalResource resource) { 14 14 double powerConsumption; 15 15 16 Processor cpu = (Processor)resource; 16 17 if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) -
DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java
r913 r1207 1 1 package example.energy.coolemall; 2 2 3 import schedframe. Parameter;4 import schedframe.resources.computing. ComputingResource;3 import schedframe.resources.computing.coolemall.ComputeBox1; 4 import schedframe.resources.computing.coolemall.NodeGroup; 5 5 import schedframe.resources.computing.profiles.energy.EnergyEvent; 6 import schedframe.resources.computing.recs.ComputeBox1; 7 import schedframe.resources.computing.recs.NodeGroup; 6 import schedframe.resources.devices.PhysicalResource; 8 7 import schedframe.scheduling.manager.tasks.JobRegistry; 9 8 import example.energy.BaseEnergyEstimationPlugin; … … 12 11 13 12 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 14 ComputingResource resource) {13 PhysicalResource resource) { 15 14 double powerConsumption = 0; 16 15 ComputeBox1 computeBox1 = (ComputeBox1)resource; … … 22 21 } 23 22 } 24 25 try { 26 powerConsumption = powerConsumption + computeBox1.getPowerInterface().getPowerConsumption(computeBox1.getPowerInterface().getPowerState()); 27 } catch (NoSuchFieldException e) { 28 Parameter param = computeBox1.getResourceCharacteristic().getParameters().get("maxPower"); 29 if(param != null) 30 powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent()); 31 } 32 33 23 powerConsumption = (powerConsumption + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION)/CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY; 34 24 return powerConsumption; 35 25 } -
DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java
r1146 r1207 1 1 package example.energy.coolemall; 2 2 3 import schedframe.Parameter;4 import schedframe.events.scheduling.EventReason;5 import schedframe.resources.computing.ComputingResource;6 3 import schedframe.resources.computing.Processor; 4 import schedframe.resources.computing.coolemall.Node; 7 5 import schedframe.resources.computing.profiles.energy.EnergyEvent; 8 import schedframe.resources.computing.recs.Node; 6 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 7 import schedframe.resources.devices.Device; 8 import schedframe.resources.devices.PhysicalResource; 9 9 import schedframe.scheduling.manager.tasks.JobRegistry; 10 import testbed_hpc.Node_Fan_Mapping; 10 11 import example.energy.BaseEnergyEstimationPlugin; 11 12 12 13 public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { 13 14 14 private static int OUT_START_ID = 0;15 private static int OUT_END_ID = 8;15 //private static int OUT_START_ID = 0; 16 //private static int OUT_END_ID = 8; 16 17 17 18 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 18 ComputingResource resource) {19 PhysicalResource resource) { 19 20 double powerConsumption = 0; 20 21 Node node = (Node) resource; … … 26 27 } 27 28 } 28 try { 29 powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); 30 } catch (NoSuchFieldException e) { 31 Parameter param = node.getResourceCharacteristic().getParameters().get("maxPower"); 32 if(param != null) 33 powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent()); 34 } 29 if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){ 30 //powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; 31 for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ 32 if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){ 33 if(device.getPowerInterface().getRecentPowerUsage().getValue() == -1){ 34 powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; 35 }else 36 powerConsumption = powerConsumption + device.getPowerInterface().getRecentPowerUsage().getValue(); 37 break; 38 } 39 } 40 } 41 35 42 36 43 return powerConsumption; 37 44 } 38 45 39 public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {46 /*public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 40 47 41 48 double airThroughput = 0; … … 44 51 return airThroughput; 45 52 //airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF); 46 else 53 else { 47 54 airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState()); 55 //airThroughput = computingResource.getResourceCharacteristic().getDevices().get(0).getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState()); 56 //airThroughput = 0.28; 57 } 48 58 } catch (NoSuchFieldException e) { 49 59 // TODO Auto-generated catch block … … 51 61 } 52 62 53 Integer resId = Integer.parseInt(resource.getName().split("_")[1]); 63 //Integer resId = Integer.parseInt(resource.getName().split("_")[1]); 64 //ComputingResource computingResource = (ComputingResource) resource; 54 65 //we estimate the air flow related to the outlets (nodes placed in the outlet row of RECS) 55 if(resId >= OUT_START_ID && resId <= OUT_END_ID){56 for(ComputingResource compResource: resource.getParent().getChildren()){57 Integer id = Integer.parseInt(compResource.getName().split("_")[1]);58 //we take into account the inlet air flow (nodes placed "behind" the given node)59 if(id - resId == 9 || id - resId == -9){60 try {61 airThroughput = airThroughput + compResource.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2;62 } catch (NoSuchFieldException e) {63 64 }65 }66 }67 }66 //if(resId >= OUT_START_ID && resId <= OUT_END_ID){ 67 // for(ComputingResource compResource: computingResource.getParent().getChildren()){ 68 // Integer id = Integer.parseInt(compResource.getName().split("_")[1]); 69 // //we take into account the inlet air flow (nodes placed "behind" the given node) 70 // if(id - resId == 9 || id - resId == -9){ 71 // try { 72 // airThroughput = airThroughput + compResource.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2; 73 // } catch (NoSuchFieldException e) { 74 // 75 // } 76 // } 77 // } 78 //} 68 79 69 80 return airThroughput; 70 } 81 }*/ 71 82 72 public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {83 /*public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 73 84 double tout = 0; 74 85 double tin = 21.3; … … 83 94 Integer resId = Integer.parseInt(resource.getName().split("_")[1]); 84 95 96 ComputingResource computingResource = (ComputingResource) resource; 97 85 98 //we estimate outlet temperature (related to the temperature of the nodes placed in outlet row) 86 for(ComputingResource compResource: resource.getParent().getChildren()){99 for(ComputingResource compResource: computingResource.getParent().getChildren()){ 87 100 Integer id = Integer.parseInt(compResource.getName().split("_")[1]); 88 101 //we take into account the power of nodes placed "behind" the given nodes … … 98 111 tout = tin + delta1 * (power1/(Q * C * ro)) + delta2 * (power2/(Q * C * ro));; 99 112 return tout; 100 } 113 }*/ 101 114 102 115 } -
DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeGroupEnergyEstimationPlugin.java
r913 r1207 1 1 package example.energy.coolemall; 2 2 3 import schedframe. Parameter;4 import schedframe.resources.computing. ComputingResource;3 import schedframe.resources.computing.coolemall.Node; 4 import schedframe.resources.computing.coolemall.NodeGroup; 5 5 import schedframe.resources.computing.profiles.energy.EnergyEvent; 6 import schedframe.resources.computing.recs.Node; 7 import schedframe.resources.computing.recs.NodeGroup; 6 import schedframe.resources.devices.PhysicalResource; 8 7 import schedframe.scheduling.manager.tasks.JobRegistry; 9 8 import example.energy.BaseEnergyEstimationPlugin; … … 12 11 13 12 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 14 ComputingResource resource) { 13 PhysicalResource resource) { 14 15 15 double powerConsumption = 0; 16 16 NodeGroup nodeGroup = (NodeGroup)resource; 17 for(Node cn: nodeGroup.getNodes()){17 for(Node node: nodeGroup.getNodes()){ 18 18 try{ 19 powerConsumption = powerConsumption + cn.getPowerInterface().getRecentPowerUsage().getValue();19 powerConsumption = powerConsumption + node.getPowerInterface().getRecentPowerUsage().getValue(); 20 20 } catch (Exception e){ 21 22 21 } 23 }24 try {25 powerConsumption = powerConsumption + nodeGroup.getPowerInterface().getPowerConsumption(nodeGroup.getPowerInterface().getPowerState());26 } catch (NoSuchFieldException e) {27 Parameter param = nodeGroup.getResourceCharacteristic().getParameters().get("maxPower");28 if(param != null)29 powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent());30 22 } 31 23 -
DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java
r913 r1207 1 1 package example.energy.coolemall; 2 2 3 import schedframe.Parameter;3 import dcworms.schedframe.scheduling.ExecTask; 4 4 import schedframe.resources.ResourceStatus; 5 import schedframe.resources.computing.Co mputingResource;5 import schedframe.resources.computing.Core; 6 6 import schedframe.resources.computing.Processor; 7 7 import schedframe.resources.computing.profiles.energy.EnergyEvent; 8 8 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 9 import schedframe.resources.devices.PhysicalResource; 9 10 import schedframe.scheduling.manager.tasks.JobRegistry; 11 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 12 import schedframe.scheduling.tasks.phases.PhaseBehaviour; 10 13 import example.energy.BaseEnergyEstimationPlugin; 11 14 … … 13 16 14 17 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 15 ComputingResource resource) { 16 double powerConsumption = 0; 18 PhysicalResource resource) { 19 20 /*double powerConsumption = 0; 17 21 Processor cpu = (Processor)resource; 18 22 if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) … … 38 42 } 39 43 } 44 return powerConsumption;*/ 45 double powerConsumption = 0; 46 Processor proc = (Processor)resource; 47 if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) 48 return 0; 49 else { 50 double processorLoad; 51 double sumCoresLoad = 0; 52 53 int nrOfThreadsOnCpu = 1; 54 55 if(proc.getResourceCharacteristic().getParameters().get("product") != null){ 56 String productName = proc.getResourceCharacteristic().getParameters().get("product").get(0).getContent(); 57 if(productName.equals("Fusion G - T40N")) 58 nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Fusion_G_T40N_NR_OF_THREADS; 59 else if(productName.equals("Atom - D510")) 60 nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_D510_NR_OF_THREADS; 61 else if(productName.equals("Atom - N2600")) 62 nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_N2600_NR_OF_THREADS; 63 else if(productName.equals("Core i7 - 2715QE")) 64 nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_2715QE_NR_OF_THREADS; 65 else if(productName.equals("Core i7 - 3615QE")) 66 nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_3615QE_NR_OF_THREADS; 67 } 68 69 for(Core core: proc.getCores()){ 70 71 if(core.getStatus().equals(ResourceStatus.BUSY)){ 72 JobRegistry jr = new JobRegistryImpl(core.getFullName()); 73 for(ExecTask task: jr.getRunningTasks()){ 74 double cpuUsage = 100; 75 double nrOfThreadsOfApplciation = 1; 76 for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){ 77 if(pb.getResouceName().equals("PM_CPU_Usage")){ 78 cpuUsage = pb.getUtilization(); 79 } 80 if(pb.getResouceName().equals("PM_Threads")){ 81 nrOfThreadsOfApplciation = pb.getUtilization(); 82 break; 83 } 84 } 85 sumCoresLoad = sumCoresLoad + cpuUsage * (nrOfThreadsOnCpu / nrOfThreadsOfApplciation); 86 } 87 } 88 } 89 processorLoad = 100 * sumCoresLoad/proc.getCores().size(); 90 double lowestLoadLevel = 100; 91 double highestLoadLevel = 0; 92 if(proc.getPowerInterface().getPState().getLoadPowerUsage().containsKey(new Double(processorLoad))){ 93 powerConsumption = proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(processorLoad)); 94 //System.out.println("power from profile: " + powerConsumption); 95 } else { 96 for(Double load: proc.getPowerInterface().getPState().getLoadPowerUsage().keySet()){ 97 if(lowestLoadLevel > load){ 98 lowestLoadLevel = load; 99 } 100 if(highestLoadLevel < load){ 101 highestLoadLevel = load; 102 } 103 } 104 if(processorLoad == 0){ 105 try{ 106 powerConsumption = proc.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage(); 107 //System.out.println("load = 0; power = idle power usage: " + powerConsumption); 108 } catch (Exception e){ 109 powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel)); 110 //System.out.println("error load = 0; power = 0.7 max power: " + powerConsumption); 111 } 112 } else { 113 114 double lowerLoadLevel = lowestLoadLevel; 115 double higherLoadLevel = highestLoadLevel; 116 117 try{ 118 119 for(Double load: proc.getPowerInterface().getPState().getLoadPowerUsage().keySet()){ 120 if(processorLoad > load){ 121 lowerLoadLevel = load; 122 } 123 else if(processorLoad < load){ 124 higherLoadLevel = load; 125 break; 126 } 127 } 128 double powerBelow; 129 double powerAbove; 130 double a; 131 double b; 132 if(lowerLoadLevel != higherLoadLevel) 133 { 134 powerBelow = proc.getPowerInterface().getPState().getLoadPowerUsage().get(lowerLoadLevel); 135 powerAbove = proc.getPowerInterface().getPState().getLoadPowerUsage().get(higherLoadLevel); 136 a = (powerAbove - powerBelow)/(higherLoadLevel - lowerLoadLevel); 137 b = powerAbove - a * higherLoadLevel; 138 } else { 139 powerBelow = proc.getPowerInterface().getPState().getLoadPowerUsage().get(lowestLoadLevel); 140 powerAbove = proc.getPowerInterface().getPState().getLoadPowerUsage().get(highestLoadLevel); 141 a = (powerAbove - powerBelow)/(highestLoadLevel - lowestLoadLevel); 142 b = powerAbove - a * highestLoadLevel; 143 } 144 powerConsumption = a * processorLoad + b; 145 /*System.out.println("a" +lowestLoadLevel + ";" +highestLoadLevel); 146 System.out.println("b" +lowerLoadLevel + ";" +higherLoadLevel); 147 System.out.println("c" +powerBelow + ";" +powerAbove); 148 System.out.println(resource.getFullName() + "load: " + processorLoad + "linear power estimation " + powerConsumption);*/ 149 150 } catch (Exception e){ 151 powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel)); 152 //System.out.println("error; power = 0.7 max power: " + powerConsumption); 153 } 154 } 155 } 156 } 157 158 159 powerConsumption = powerConsumption - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; 160 //System.out.println("estiamted power consumption: " + powerConsumption); 40 161 return powerConsumption; 41 162 } -
DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java
r575 r1207 145 145 List<ComputingResource> nodes; 146 146 Properties properties = new Properties(); 147 properties.setProperty("type", StandardResourceType. ComputingNode.getName());147 properties.setProperty("type", StandardResourceType.Node.getName()); 148 148 // properties.setProperty("status", ResourceStatus.FREE.toString()); 149 149 nodes = (List<ComputingResource>) unitsManager.filterResources(properties); 150 150 151 151 //always return the same node from the list 152 return nodes.get(0).get Name();152 return nodes.get(0).getFullName(); 153 153 } 154 154 -
DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java
r574 r1207 98 98 } 99 99 } 100 ProcessingElements result = new ProcessingElements(node.get Name());100 ProcessingElements result = new ProcessingElements(node.getFullName()); 101 101 result.addAll(choosenResources); 102 102 map.put(StandardResourceUnitName.PE, result); -
DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java
r778 r1207 8 8 9 9 import schedframe.events.scheduling.SchedulingEvent; 10 import schedframe.resources.StandardResourceType; 10 11 import schedframe.resources.computing.ComputingNode; 11 12 import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName; 12 13 import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName; 14 import schedframe.resources.devices.Device; 13 15 import schedframe.scheduling.manager.resources.ClusterResourceManager; 14 16 import schedframe.scheduling.manager.resources.ResourceManager; … … 54 56 if (node != null) { 55 57 //if there are two or more tasks ( running on the given node then 56 if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 0) 57 node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 58 else 59 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 58 if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 0){ 59 List<Device> devices = node.getResourceCharacteristic().getDevices(); 60 for(Device dev : devices){ 61 if(dev.getType().equals(StandardResourceType.Fan)){ 62 dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 63 } 64 } 65 } 66 else { 67 List<Device> devices = node.getResourceCharacteristic().getDevices(); 68 for(Device dev : devices){ 69 if(dev.getType().equals(StandardResourceType.Fan)){ 70 dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON); 71 } 72 } 73 } 60 74 notSelectedNodes.remove(node); 61 addToSchedulingPlan(plan, task, node.get Name());75 addToSchedulingPlan(plan, task, node.getFullName()); 62 76 } 63 77 } … … 98 112 private void adjustOtherFans(List<ComputingNode> nodes){ 99 113 for(ComputingNode node : nodes){ 114 List<Device> devices = node.getResourceCharacteristic().getDevices(); 100 115 if(node.getFreeProcessorsNumber() == node.getProcessorsNumber()){ 101 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF); 102 } else if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 1) 103 node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 104 else 105 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 116 for(Device dev : devices){ 117 if(dev.getType().equals(StandardResourceType.Fan)){ 118 dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.OFF); 119 } 120 } 121 } else if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 1){ 122 for(Device dev : devices){ 123 if(dev.getType().equals(StandardResourceType.Fan)){ 124 dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 125 } 126 } 127 } 128 else { 129 for(Device dev : devices){ 130 if(dev.getType().equals(StandardResourceType.Fan)){ 131 dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON); 132 } 133 } 134 } 106 135 } 107 136 } -
DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java
r531 r1207 90 90 } 91 91 } 92 ProcessingElements result = new ProcessingElements(nodes.get(0).get Name());92 ProcessingElements result = new ProcessingElements(nodes.get(0).getFullName()); 93 93 result.addAll(choosenResources); 94 94 map.put(StandardResourceUnitName.PE, result); -
DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java
r574 r1207 61 61 List<ComputingNode> nodes = resourceManager.getComputingNodes(); 62 62 int nodeIdx = rand.nextInt(nodes.size()); 63 return nodes.get(nodeIdx).get Name();63 return nodes.get(nodeIdx).getFullName(); 64 64 } 65 65 -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java
r1100 r1207 6 6 import schedframe.events.scheduling.SchedulingEvent; 7 7 import schedframe.exceptions.ResourceException; 8 import schedframe.resources. CoolEmAllResourceType;8 import schedframe.resources.StandardResourceType; 9 9 import schedframe.resources.computing.ComputingResource; 10 10 import schedframe.scheduling.manager.resources.ClusterResourceManager; … … 64 64 List<ComputingResource> nodes = null; 65 65 try { 66 nodes = (List<ComputingResource>) resourceManager.getResourcesOfType( CoolEmAllResourceType.Node);66 nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node); 67 67 } catch (ResourceException e) { 68 68 // TODO Auto-generated catch block … … 70 70 } 71 71 int nodeIdx = rand.nextInt(nodes.size()); 72 return nodes.get(nodeIdx).get Name();72 return nodes.get(nodeIdx).getFullName(); 73 73 } 74 74 -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java
r1099 r1207 1 1 package example.localplugin.coolemall.computebox1; 2 2 3 import java.util.ArrayList; 4 import java.util.HashMap; 3 5 import java.util.List; 6 import java.util.Map; 4 7 import java.util.Random; 5 8 6 9 import schedframe.events.scheduling.SchedulingEvent; 7 10 import schedframe.exceptions.ResourceException; 8 import schedframe.resources.CoolEmAllResourceType; 11 import schedframe.resources.ResourceStatus; 12 import schedframe.resources.StandardResourceType; 9 13 import schedframe.resources.computing.ComputingResource; 14 import schedframe.resources.computing.Core; 15 import schedframe.resources.computing.coolemall.Node; 16 import schedframe.resources.units.ProcessingElements; 17 import schedframe.resources.units.ResourceUnit; 18 import schedframe.resources.units.ResourceUnitName; 19 import schedframe.resources.units.StandardResourceUnitName; 10 20 import schedframe.scheduling.manager.resources.ClusterResourceManager; 11 21 import schedframe.scheduling.manager.resources.ResourceManager; … … 17 27 import schedframe.scheduling.queue.TaskQueueList; 18 28 import schedframe.scheduling.tasks.TaskInterface; 29 import testbed_hpc.Node_Fan_Mapping; 19 30 import example.localplugin.BaseLocalSchedulingPlugin; 20 31 import gridsim.dcworms.DCWormsTags; … … 26 37 public CB1_FCFS_Random_SP () { 27 38 rand = new Random(47); 39 Node_Fan_Mapping.init(); 28 40 } 29 41 … … 49 61 if (task.getStatus() == DCWormsTags.READY) { 50 62 51 String nodeName = chooseRandomProvider(resourceManager);52 if ( nodeName!= null) {53 addToSchedulingPlan(plan, task, nodeName);63 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 64 if (choosenResources != null) { 65 addToSchedulingPlan(plan, task, choosenResources); 54 66 } 55 67 } … … 61 73 62 74 @SuppressWarnings("unchecked") 63 private String chooseRandomProvider(ClusterResourceManager resourceManager) { 64 List<ComputingResource> nodes = null; 75 private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution( 76 ClusterResourceManager resourceManager, TaskInterface<?> task) { 77 78 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 79 80 List<Node> nodes = null; 65 81 try { 66 nodes = (List< ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);82 nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node); 67 83 } catch (ResourceException e) { 68 84 // TODO Auto-generated catch block 69 85 e.printStackTrace(); 70 86 } 71 int nodeIdx = rand.nextInt(nodes.size()); 72 return nodes.get(nodeIdx).getName(); 87 List<Node> avNodes = filterNodes(nodes, task); 88 if(avNodes.size() == 0) 89 return null; 90 Node node = randomNode(avNodes); 91 int cpuRequest; 92 try { 93 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 94 } catch (NoSuchFieldException e) { 95 cpuRequest = 0; 96 } 97 98 if (cpuRequest != 0) { 99 100 List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(); 101 102 List<Core> cores = node.getCores(); 103 for (int i = 0; i < cores.size() && cpuRequest > 0; i++) { 104 if (cores.get(i).getStatus() == ResourceStatus.FREE) { 105 choosenResources.add(cores.get(i)); 106 cpuRequest--; 107 } 108 } 109 if (cpuRequest > 0) { 110 return null; 111 } 112 //choosenResources.add(node.getProcessors().get(0)); 113 ProcessingElements pe = new ProcessingElements(); 114 pe.addAll(choosenResources); 115 map.put(StandardResourceUnitName.PE, pe); 116 return map; 117 } 118 return null; 119 } 120 121 private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){ 122 List<Node> filteredNodes = new ArrayList<Node>(); 123 int cpuRequest; 124 try { 125 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 126 } catch (NoSuchFieldException e) { 127 cpuRequest = 0; 128 } 129 for (Node node : nodes) { 130 131 if (cpuRequest != 0) { 132 133 List<Core> cores = node.getCores(); 134 if (cores.size() < cpuRequest) { 135 if(cores.size() == 0){ 136 if(node.getProcessors().size() < cpuRequest) 137 continue; 138 } 139 } 140 141 int freeCores = 0; 142 for(Core core: cores){ 143 if(core.getStatus() == ResourceStatus.FREE) 144 freeCores++; 145 } 146 147 if(freeCores < cpuRequest) 148 continue; 149 150 filteredNodes.add(node); 151 } 152 } 153 154 return filteredNodes; 155 } 156 157 private Node randomNode(List<Node> nodes){ 158 return nodes.get(rand.nextInt(nodes.size())); 73 159 } 74 160 -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java
r1102 r1207 10 10 import schedframe.events.scheduling.SchedulingEvent; 11 11 import schedframe.exceptions.ResourceException; 12 import schedframe.resources.CoolEmAllResourceType;13 12 import schedframe.resources.ResourceStatus; 13 import schedframe.resources.StandardResourceType; 14 14 import schedframe.resources.computing.ComputingResource; 15 15 import schedframe.resources.computing.Processor; 16 import schedframe.resources.computing.coolemall.Node; 16 17 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 17 import schedframe.resources.computing.recs.Node;18 18 import schedframe.resources.units.Memory; 19 19 import schedframe.resources.units.ProcessingElements; … … 55 55 List<Node> nodes; 56 56 try { 57 nodes = (List<Node>) resourceManager.getResourcesOfType( CoolEmAllResourceType.Node);57 nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node); 58 58 } catch (ResourceException e) { 59 59 break; … … 140 140 } 141 141 } 142 ProcessingElements result = new ProcessingElements(node.get Name());142 ProcessingElements result = new ProcessingElements(node.getFullName()); 143 143 result.addAll(choosenResources); 144 144 map.put(StandardResourceUnitName.PE, result); … … 183 183 private void turnOffIdleNodes(List<Node> nodes){ 184 184 for(Node node : nodes){ 185 JobRegistry jr = new JobRegistryImpl(node.get Name());185 JobRegistry jr = new JobRegistryImpl(node.getFullName()); 186 186 if(jr.getRunningTasks().size() == 0) 187 187 node.getPowerInterface().setPowerState(StandardPowerStateName.OFF); -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java
r1102 r1207 5 5 import schedframe.events.scheduling.SchedulingEvent; 6 6 import schedframe.exceptions.ResourceException; 7 import schedframe.resources. CoolEmAllResourceType;7 import schedframe.resources.StandardResourceType; 8 8 import schedframe.resources.computing.ComputingResource; 9 import schedframe.resources.computing. recs.Node;9 import schedframe.resources.computing.coolemall.Node; 10 10 import schedframe.scheduling.manager.resources.ClusterResourceManager; 11 11 import schedframe.scheduling.manager.resources.ResourceManager; … … 62 62 List<ComputingResource> nodes = null; 63 63 try { 64 nodes = (List<ComputingResource>) resourceManager.getResourcesOfType( CoolEmAllResourceType.Node);64 nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node); 65 65 } catch (ResourceException e) { 66 66 // TODO Auto-generated catch block … … 68 68 } 69 69 int nodeIdx = findLeastLoadedResourceIdx(nodes); 70 return nodes.get(nodeIdx).get Name();70 return nodes.get(nodeIdx).getFullName(); 71 71 } 72 72 … … 77 77 for(int i = 0; i < nodes.size(); i++){ 78 78 Node node = (Node) nodes.get(i); 79 JobRegistry jr = new JobRegistryImpl(node.get Name());79 JobRegistry jr = new JobRegistryImpl(node.getFullName()); 80 80 int totalLoad = jr.getRunningTasks().size(); 81 81 if(totalLoad < minLoad){ -
DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java
r1103 r1207 2 2 3 3 import java.util.ArrayList; 4 import java.util.HashMap; 4 5 import java.util.List; 6 import java.util.Map; 5 7 import java.util.Random; 6 8 7 9 import schedframe.events.scheduling.SchedulingEvent; 8 10 import schedframe.exceptions.ResourceException; 9 import schedframe.resources.CoolEmAllResourceType; 11 import schedframe.resources.ResourceStatus; 12 import schedframe.resources.StandardResourceType; 10 13 import schedframe.resources.computing.ComputingNode; 11 import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName; 14 import schedframe.resources.computing.ComputingResource; 15 import schedframe.resources.computing.Core; 16 import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName; 17 import schedframe.resources.devices.Device; 18 import schedframe.resources.units.ProcessingElements; 19 import schedframe.resources.units.ResourceUnit; 20 import schedframe.resources.units.ResourceUnitName; 21 import schedframe.resources.units.StandardResourceUnitName; 12 22 import schedframe.scheduling.manager.resources.ClusterResourceManager; 13 23 import schedframe.scheduling.manager.resources.ResourceManager; … … 19 29 import schedframe.scheduling.queue.TaskQueueList; 20 30 import schedframe.scheduling.tasks.TaskInterface; 31 import testbed_hpc.Node_Fan_Mapping; 21 32 import example.localplugin.BaseLocalSchedulingPlugin; 22 33 import gridsim.dcworms.DCWormsTags; … … 28 39 public RECS_FCFS_Random_SP () { 29 40 rand = new Random(47); 41 Node_Fan_Mapping.init(); 30 42 } 31 43 … … 47 59 List<ComputingNode> notSelectedNodes = null; 48 60 try { 49 notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType( CoolEmAllResourceType.Node);61 notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node); 50 62 } catch (ResourceException e) { 51 63 // TODO Auto-generated catch block … … 57 69 // if status of the tasks in READY 58 70 if (task.getStatus() == DCWormsTags.READY) { 59 ComputingNode node = chooseRandomProvider(resourceManager); 71 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 72 if (choosenResources != null) { 73 addToSchedulingPlan(plan, task, choosenResources); 74 } 75 /*ComputingNode node = chooseRandomProvider(resourceManager); 60 76 if (node != null) { 61 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);77 //node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 62 78 notSelectedNodes.remove(node); 63 79 addToSchedulingPlan(plan, task, node.getName()); 64 } 80 }*/ 65 81 } 66 82 } … … 75 91 List<ComputingNode> nodes = null; 76 92 try { 77 nodes = (List<ComputingNode>) resourceManager.getResourcesOfType( CoolEmAllResourceType.Node);93 nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node); 78 94 } catch (ResourceException e) { 79 95 // TODO Auto-generated catch block … … 94 110 return filteredNodes; 95 111 } 112 113 private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution( 114 ClusterResourceManager resourceManager, TaskInterface<?> task) { 115 116 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 117 118 List<ComputingNode> nodes = null; 119 try { 120 nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node); 121 } catch (ResourceException e1) { 122 // TODO Auto-generated catch block 123 e1.printStackTrace(); 124 } 125 List<ComputingNode> avNodes = filterNodes(nodes, task); 126 if(avNodes.size() == 0) 127 return null; 128 ComputingNode node = randomNode(avNodes); 129 130 int cpuRequest; 131 try { 132 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 133 } catch (NoSuchFieldException e) { 134 cpuRequest = 0; 135 } 136 137 if (cpuRequest != 0) { 138 139 List<Core> cores = node.getProcessors().get(0).getCores(); 140 141 List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(); 142 for (int i = 0; i < cores.size(); i++) { 143 if (cores.get(i).getStatus() == ResourceStatus.FREE) { 144 //choosenResources.add(cores.get(i)); 145 cpuRequest--; 146 } 147 } 148 if (cpuRequest > 0) { 149 return null; 150 } 151 choosenResources.add(node.getProcessors().get(0)); 152 ProcessingElements pe = new ProcessingElements(); 153 pe.addAll(choosenResources); 154 map.put(StandardResourceUnitName.PE, pe); 155 return map; 156 } 157 return null; 158 } 159 160 private List<ComputingNode> filterNodes(List<ComputingNode> nodes, TaskInterface<?> task){ 161 List<ComputingNode> filteredNodes = new ArrayList<ComputingNode>(); 162 for (ComputingNode node : nodes) { 163 int cpuRequest; 164 try { 165 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 166 } catch (NoSuchFieldException e) { 167 cpuRequest = 0; 168 } 169 170 if (cpuRequest != 0) { 171 172 List<Core> cores = node.getProcessors().get(0).getCores(); 173 if (cores.size() < cpuRequest) { 174 if(cores.size() == 0){ 175 if(node.getProcessors().size() < cpuRequest) 176 continue; 177 } 178 } 179 180 int freeCores = 0; 181 for(Core core: cores){ 182 if(core.getStatus() == ResourceStatus.FREE) 183 freeCores++; 184 } 185 186 if(freeCores != cores.size()) 187 continue; 188 189 filteredNodes.add(node); 190 } 191 } 192 193 return filteredNodes; 194 } 195 196 private ComputingNode randomNode(List<ComputingNode> nodes){ 197 return nodes.get(rand.nextInt(nodes.size())); 198 } 199 96 200 private void adjustOtherFans(List<ComputingNode> nodes) { 97 201 for (ComputingNode node : nodes) { 202 98 203 if (node.getProcessors().size() == node.getFreeProcessorsNumber()) { 99 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF); 204 for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ 205 if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){ 206 device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("Off")); 207 break; 208 } 209 } 210 100 211 } else { 101 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 212 for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ 213 if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){ 214 device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("On")); 215 break; 216 } 217 } 102 218 } 103 219 } -
DCWoRMS/branches/coolemall/src/schedframe/SimulatedEnvironment.java
r768 r1207 3 3 import gridsim.GridSim; 4 4 5 import java.util.ArrayList; 5 6 import java.util.HashSet; 6 7 import java.util.Iterator; … … 10 11 11 12 import schedframe.exceptions.ResourceException; 13 import schedframe.resources.ResourceHistoryChanges; 12 14 import schedframe.resources.computing.ComputingResource; 13 15 import schedframe.scheduling.Scheduler; 14 16 15 public class ResourceController{17 public class SimulatedEnvironment { 16 18 17 19 protected static Scheduler scheduler; … … 19 21 protected List<Initializable> toInit; 20 22 protected Set<String> compResLayers; 23 protected static List<ResourceHistoryChanges> compResHistory = new ArrayList<ResourceHistoryChanges>(); 21 24 22 public ResourceController(Scheduler logicalStructure, List<ComputingResource> compResources){25 public SimulatedEnvironment(Scheduler logicalStructure, List<ComputingResource> compResources){ 23 26 scheduler = logicalStructure; 24 27 computingResources = compResources; … … 37 40 for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) { 38 41 ComputingResource resource = computingResources.get(i); 39 if (resource.get Name().equals(resourceName))42 if (resource.getFullName().equals(resourceName)) 40 43 resourceWithName = resource; 41 44 else … … 152 155 } 153 156 157 public static void traceResource(long timestamp, String resourceName, String operation, String paramter){ 158 ResourceHistoryChanges rhc = new ResourceHistoryChanges(timestamp, resourceName, operation, paramter); 159 compResHistory.add(rhc); 160 } 161 162 public static List<ResourceHistoryChanges> getCompResHistory() { 163 return compResHistory; 164 } 154 165 } -
DCWoRMS/branches/coolemall/src/schedframe/events/ResourceEventCommand.java
r477 r1207 1 1 package schedframe.events; 2 2 3 import schedframe.resources. computing.ComputingResource;3 import schedframe.resources.devices.PhysicalResource; 4 4 5 5 public class ResourceEventCommand implements EventCommand { 6 6 7 private ComputingResource compResource;7 private PhysicalResource resource; 8 8 9 public ResourceEventCommand( ComputingResource compResource) {10 this. compResource = compResource;9 public ResourceEventCommand(PhysicalResource resource) { 10 this.resource = resource; 11 11 } 12 12 … … 17 17 18 18 public void execute(Event event) { 19 compResource.getEventHandler().handleResourceEvent(event);19 resource.getEventHandler().handleResourceEvent(event); 20 20 } 21 21 -
DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventCommand.java
r477 r1207 16 16 public void execute(EventType evType) { 17 17 SchedulingEvent ev = new SchedulingEvent(evType); 18 ev.setSource(compResource.get Name());18 ev.setSource(compResource.getFullName()); 19 19 compResource.getEventHandler().handleSchedulingEvent(ev); 20 20 } … … 22 22 public void execute(Event event) { 23 23 SchedulingEvent ev = new SchedulingEvent(event.getType()); 24 ev.setSource(compResource.get Name());24 ev.setSource(compResource.getFullName()); 25 25 compResource.getEventHandler().handleSchedulingEvent(ev); 26 26 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceType.java
r1095 r1207 3 3 public enum CoolEmAllResourceType implements ResourceType { 4 4 5 ComputeBox2, 6 ComputeBox1, 7 NodeGroup, 8 Node, 9 Processor, 10 Core; 11 5 ComputeBox2("Room"), 6 ComputeBox1("Rack"), 7 NodeGroup("NodeGroup"), 8 Node("Node"), 9 Processor("Processor"), 10 Core("Core"); 11 12 private String label; 13 14 CoolEmAllResourceType(String label){ 15 this.label = label; 16 } 12 17 public String getName() { 13 18 return toString(); 14 19 } 20 public String getLabel(){ 21 return label; 22 } 15 23 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/Resource.java
r893 r1207 1 1 package schedframe.resources; 2 2 3 3 4 -
DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceTypeFactory.java
r1097 r1207 5 5 6 6 public static ResourceType createResourceType(String typeName){ 7 7 8 8 if(typeName.equals(StandardResourceType.Grid.getName())) 9 9 return StandardResourceType.Grid; … … 15 15 return StandardResourceType.Rack; 16 16 17 else if (typeName.equals(StandardResourceType. ComputingNode.getName()))18 return StandardResourceType. ComputingNode;17 else if (typeName.equals(StandardResourceType.Node.getName())) 18 return StandardResourceType.Node; 19 19 20 20 else if (typeName.equals(StandardResourceType.Processor.getName())) … … 24 24 return StandardResourceType.Core; 25 25 26 else if (typeName.equals(CoolEmAllResourceType.ComputeBox2.getName())) 27 return CoolEmAllResourceType.ComputeBox2; 28 26 29 else if (typeName.equals(CoolEmAllResourceType.ComputeBox1.getName())) 27 30 return CoolEmAllResourceType.ComputeBox1; … … 30 33 return CoolEmAllResourceType.NodeGroup; 31 34 32 else if (typeName.equals(CoolEmAllResourceType.Node.getName())) 33 return CoolEmAllResourceType.Node; 35 else if (typeName.equals(StandardResourceType.CRAH.getName())) 36 return StandardResourceType.CRAH; 37 38 else if (typeName.equals(StandardResourceType.Fan.getName())) 39 return StandardResourceType.Fan; 40 41 else if (typeName.equals(StandardResourceType.Inlet.getName())) 42 return StandardResourceType.Inlet; 43 44 else if (typeName.equals(StandardResourceType.Outlet.getName())) 45 return StandardResourceType.Outlet; 46 47 else if (typeName.equals(StandardResourceType.CoolingDevice.getName())) 48 return StandardResourceType.CoolingDevice; 49 50 else if (typeName.equals(StandardResourceType.Heatsink.getName())) 51 return StandardResourceType.Heatsink; 34 52 35 53 else if (typeName.equals(StandardResourceType.ResourceProvider.getName())) … … 42 60 return StandardResourceType.LS; 43 61 44 elsereturn new UserResourceType(typeName);62 return new UserResourceType(typeName); 45 63 } 46 64 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/StandardResourceType.java
r1095 r1207 7 7 DataCenter, 8 8 Rack, 9 ComputingNode,9 Node, 10 10 Processor, 11 11 Core, … … 13 13 ResourceProvider, 14 14 GS, 15 LS; 15 LS, 16 Fan, 17 Refrigeration, 18 Heatpipe, 19 ILC, 20 LCU, 21 CRAH, 22 HVAC, 23 Inlet, 24 Outlet, 25 Heatsink, 26 Sensor, 27 Network, 28 CoolingDevice, 29 PowerSupply; 16 30 17 31 public String getName() { -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingNode.java
r756 r1207 3 3 import java.util.List; 4 4 import java.util.Properties; 5 6 5 7 6 import schedframe.resources.ResourceStatus; … … 10 9 import schedframe.resources.computing.extensions.ExtensionType; 11 10 import schedframe.resources.computing.profiles.energy.EnergyExtension; 12 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputInterfaceFactory;13 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;14 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;15 11 import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 16 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;17 12 import schedframe.resources.computing.properties.ComputingNodePropertiesBuilder; 18 13 import schedframe.resources.computing.properties.PropertiesDirector; … … 32 27 //accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 33 28 //accept(new EnergyExtension(pi, resDesc.getPowerProfile(), ai, resDesc.getAirThroughputProfile())); 34 } 35 36 /*public ComputingNode (String resourceName, ResourceCharacteristics resourceCharacteristic, Category cat, PowerInterface powerInterface) { 37 super(resourceName, ResourceType.COMPUTING_NODE, resourceCharacteristic); 38 category = cat; 39 accept(powerInterface); 40 // extensionList.add(new EnergyExtension(this, "example.energy.ComputingNodeEnergyEstimationPlugin")); 41 }*/ 42 29 } 43 30 44 31 public ComputingNodePowerInterface getPowerInterface(){ … … 86 73 87 74 public Memory getMemory() throws NoSuchFieldException { 88 return (Memory) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.MEMORY);75 return (Memory) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.MEMORY); 89 76 } 90 77 … … 95 82 96 83 private Cost getCost() throws NoSuchFieldException { 97 return (Cost) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.COST);84 return (Cost) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.COST); 98 85 } 99 86 -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java
r1005 r1207 9 9 import java.util.Properties; 10 10 11 import schedframe.Initializable;12 11 import schedframe.events.Event; 13 12 import schedframe.events.EventHandler; … … 17 16 import schedframe.events.scheduling.SchedulingEventCommand; 18 17 import schedframe.exceptions.ResourceException; 19 import schedframe.resources.Resource;20 18 import schedframe.resources.ResourceStatus; 21 19 import schedframe.resources.ResourceType; 22 20 import schedframe.resources.computing.description.ComputingResourceDescription; 23 21 import schedframe.resources.computing.extensions.Extension; 24 import schedframe.resources.computing.extensions.ExtensionList;25 22 import schedframe.resources.computing.extensions.ExtensionListImpl; 26 import schedframe.resources.computing.extensions.ExtensionType;27 23 import schedframe.resources.computing.profiles.energy.EnergyEvent; 28 24 import schedframe.resources.computing.profiles.energy.EnergyEventType; 29 25 import schedframe.resources.computing.profiles.energy.EnergyExtension; 30 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;31 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;32 import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;33 26 import schedframe.resources.computing.properties.DefaultPropertiesBuilder; 34 27 import schedframe.resources.computing.properties.PropertiesDirector; … … 38 31 import schedframe.resources.computing.validator.ResourceTypeValidator; 39 32 import schedframe.resources.computing.validator.ResourceValidator; 40 import schedframe.resources.units.PEUnit; 41 import schedframe.resources.units.ResourceUnit; 42 import schedframe.resources.units.StandardResourceUnitName; 33 import schedframe.resources.devices.Device; 34 import schedframe.resources.devices.PhysicalResource; 43 35 import schedframe.scheduling.Scheduler; 44 36 45 public class ComputingResource implements Resource, Initializable{ 46 47 protected String name; 48 protected ResourceType type; 49 protected String category; 50 protected ResourceStatus status; 37 public class ComputingResource extends PhysicalResource{ 51 38 52 39 protected ComputingResource parent; … … 54 41 55 42 protected Scheduler scheduler; 56 protected ResourceCharacteristics resourceCharacteristic; 57 protected ExtensionList extensionList; 58 59 60 public ExtensionList getExtensionList() { 61 return extensionList; 62 } 43 //protected ResourceCharacteristics resourceCharacteristic; 44 63 45 64 46 public ComputingResource(ComputingResourceDescription resDesc) { … … 69 51 this.extensionList = new ExtensionListImpl(1); 70 52 initCharacteristics(resDesc); 71 accept(new EnergyExtension(this, resDesc.getPowerProfile(), resDesc.getAirThroughputProfile(), resDesc.getThermalProfile())); 72 addFakeProcessors(); 73 } 74 75 //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 76 private void addFakeProcessors() { 77 if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ 78 for(ResourceUnit resUnit: getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE)){ 79 PEUnit peUnit = (PEUnit) resUnit; 80 for(int i = 0; i < peUnit.getAmount(); i++){ 81 schemas.ComputingResource fakeCompResource = new schemas.ComputingResource(); 82 fakeCompResource.setClazz("Processor"); 83 addChild(ResourceFactory.createResource(new ComputingResourceDescription(fakeCompResource))); 84 } 85 } 86 } 53 accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airFlowProfile(resDesc.getAirThroughputProfile()).thermalProfile(resDesc.getThermalProfile()).build()); 87 54 } 88 55 89 56 protected void initCharacteristics(ComputingResourceDescription resDesc){ 90 resourceCharacteristic = new ResourceCharacteristics.Builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).build(); 57 resourceCharacteristic = ComputingResourceCharacteristics.builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).device(resDesc.getDevices()).build(); 58 for(Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()){ 59 device.setComputingResource(this); 60 } 91 61 } 92 62 … … 112 82 } 113 83 114 public String getName() {115 return name;116 }117 118 84 public String getFullName() { 119 85 if(this.getResourceCharacteristic().getParameters().get("fullPath") != null){ … … 127 93 } 128 94 129 public ResourceType getType() { 130 return type; 131 } 132 133 public ResourceCharacteristics getResourceCharacteristic() { 134 return resourceCharacteristic; 135 } 136 137 public ResourceStatus getStatus() { 138 return status; 95 public ComputingResourceCharacteristics getResourceCharacteristic() { 96 return (ComputingResourceCharacteristics)resourceCharacteristic; 139 97 } 140 98 … … 245 203 } 246 204 247 public String getCategory(){248 return category;249 }250 251 public PowerInterface getPowerInterface(){252 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);253 if(extension != null){254 EnergyExtension ee = (EnergyExtension)extension;255 return ee.getPowerInterface();256 }257 return null;258 }259 260 public AirThroughputInterface getAirThroughputInterface(){261 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);262 if(extension != null){263 EnergyExtension ee = (EnergyExtension)extension;264 return ee.getAirThroughputInterface();265 }266 return null;267 }268 269 public ThermalInterface getThermalInterface(){270 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);271 if(extension != null){272 EnergyExtension ee = (EnergyExtension)extension;273 return ee.getThermalInterface();274 }275 return null;276 }277 278 private Extension getExtension(ExtensionType type){279 if (extensionList != null) {280 for (Extension extension : extensionList) {281 if (extension.getType() == type) {282 return extension;283 }284 }285 }286 return null;287 }288 289 205 public Scheduler getScheduler() { 290 206 return scheduler; … … 307 223 if (extension.supportsEvent(event)) { 308 224 extension.handleEvent(event); 225 } 226 } 227 228 for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) { 229 for (Extension extension : device.getExtensionList()) { 230 if (extension.supportsEvent(event)) { 231 //extension.handleEvent(event); 232 } 309 233 } 310 234 } … … 332 256 } 333 257 334 public void initiate(){ 335 258 public final void initiate(){ 259 for(Device dev: this.getResourceCharacteristic().getDevices()){ 260 dev.initiate(); 261 } 336 262 ResourceEventCommand rec = new ResourceEventCommand(this); 337 263 EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); … … 343 269 rec.execute(event); 344 270 271 rec = new ResourceEventCommand(this); 272 event = new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, "Resource controller"); 273 event.setReason(EventReason.SIM_INIT); 274 rec.execute(event); 275 345 276 //alternative way 346 277 //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 347 278 //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 348 279 } 349 350 351 private void accept(EnergyExtension e){ 352 extensionList.add(e); 353 } 280 281 354 282 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Core.java
r756 r1207 1 1 package schedframe.resources.computing; 2 2 3 import schedframe.resources.StandardResourceType; 3 4 import schedframe.resources.computing.description.ComputingResourceDescription; 4 import schedframe.resources.computing.profiles.energy.EnergyExtension;5 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;6 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;7 5 import schedframe.resources.units.CpuSpeed; 8 6 import schedframe.resources.units.StandardResourceUnitName; … … 18 16 19 17 public Processor getProcessor(){ 20 return (Processor)parent; 18 ComputingResource compRes = parent; 19 while(compRes != null && !compRes.getType().equals(StandardResourceType.Processor)){ 20 compRes = compRes.getParent(); 21 } 22 Processor proc = null; 23 try{ 24 proc = (Processor)compRes; 25 } catch(ClassCastException e) { 26 } 27 return proc; 28 } 29 30 public ComputingNode getNode(){ 31 ComputingResource compRes = parent; 32 while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){ 33 compRes = compRes.getParent(); 34 } 35 ComputingNode compNode = null; 36 try{ 37 compNode = (ComputingNode)compRes; 38 } catch(ClassCastException e) { 39 } 40 return compNode; 21 41 } 22 42 … … 42 62 43 63 private CpuSpeed getSpeedUnit() throws NoSuchFieldException{ 44 return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED);64 return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED); 45 65 } 46 66 … … 48 68 super.initCharacteristics(resDesc); 49 69 try{ 50 resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0));70 ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 51 71 } catch(Exception e){ 52 resourceCharacteristic.addResourceUnit(new CpuSpeed(name, 1, 0));72 ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, 1, 0)); 53 73 } 54 74 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/DataCenter.java
r756 r1207 20 20 @SuppressWarnings("unchecked") 21 21 public List<ComputingNode> getComputingNodes(){ 22 return (List<ComputingNode>) getDescendantsByType(StandardResourceType. ComputingNode);22 return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 23 23 } 24 24 -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Processor.java
r883 r1207 9 9 import schedframe.resources.computing.extensions.ExtensionType; 10 10 import schedframe.resources.computing.profiles.energy.EnergyExtension; 11 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;12 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;13 11 import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface; 14 12 import schedframe.resources.computing.properties.CpuPropertiesBuilder; … … 27 25 } 28 26 29 30 public ComputingNode getComputingNode(){ 31 return (ComputingNode)parent; 27 public ComputingNode getNode(){ 28 ComputingResource compRes = parent; 29 while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){ 30 compRes = compRes.getParent(); 31 } 32 ComputingNode compNode = null; 33 try{ 34 compNode = (ComputingNode)compRes; 35 } catch(Exception e) { 36 } 37 return compNode; 32 38 } 33 39 … … 63 69 64 70 private CpuSpeed getSpeedUnit() throws NoSuchFieldException{ 65 return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED);71 return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED); 66 72 } 67 73 … … 80 86 super.initCharacteristics(resDesc); 81 87 try{ 82 resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0));88 ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 83 89 } catch(Exception e){ 84 resourceCharacteristic.addResourceUnit(new CpuSpeed(name, 1, 0));90 ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, 1, 0)); 85 91 } 86 92 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Rack.java
r756 r1207 5 5 import schedframe.resources.StandardResourceType; 6 6 import schedframe.resources.computing.description.ComputingResourceDescription; 7 import schedframe.resources.computing.profiles.energy.EnergyExtension;8 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;9 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;10 7 11 8 public class Rack extends ComputingResource{ … … 20 17 @SuppressWarnings("unchecked") 21 18 public List<ComputingNode> getComputingNodes(){ 22 return (List<ComputingNode>) getDescendantsByType(StandardResourceType. ComputingNode);19 return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 23 20 } 24 21 -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceCharacteristics.java
r1007 r1207 1 1 package schedframe.resources.computing; 2 3 import java.util.ArrayList;4 import java.util.HashMap;5 import java.util.List;6 import java.util.Map;7 2 8 3 import schedframe.Parameters; 9 4 import schedframe.resources.computing.location.Location; 10 import schedframe.resources.units.ResourceUnit;11 import schedframe.resources.units.ResourceUnitName;12 5 13 6 … … 16 9 private static final long serialVersionUID = 2719535186621622647L; 17 10 18 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;11 protected Location location; 19 12 protected Parameters parameters; 20 protected Location location; 13 //protected Location location; 14 //protected List<Device> devices; 21 15 22 16 /*public ResourceCharacteristics(Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits){ … … 32 26 }*/ 33 27 34 public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 35 if(resUnits == null) 36 return new HashMap<ResourceUnitName, List<ResourceUnit>>(); 37 return resUnits; 38 } 28 39 29 40 public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException{41 if(getResourceUnits().containsKey(unitName))42 return getResourceUnits().get(unitName).get(0);43 else throw new NoSuchFieldException("Resource unit " + unitName +44 " is not available in this resource ");45 }46 47 public void addResourceUnit(ResourceUnit unit){48 if(resUnits == null){49 resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2);50 }51 List<ResourceUnit> list = null;52 if(resUnits.containsKey(unit.getName())){53 list = resUnits.get(unit.getName());54 } else {55 list = new ArrayList<ResourceUnit>(1);56 resUnits.put(unit.getName(), list);57 }58 list.add(unit);59 }60 61 62 public static class Builder {63 64 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;65 protected Location location;66 protected Parameters parameters;67 68 public Builder location(Location loc){this.location = loc; return this; }69 public Builder parameters(Parameters params){this.parameters = params; return this; }70 public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; }71 public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; }72 73 public ResourceCharacteristics build() {74 return new ResourceCharacteristics(this);75 }76 }77 78 private ResourceCharacteristics(Builder builder) {79 this.location = builder.location;80 this.parameters = builder.parameters;81 this.resUnits = builder.resUnits;82 }83 84 30 public Parameters getParameters() { 85 31 if(parameters == null) … … 91 37 return location; 92 38 } 39 40 protected ResourceCharacteristics(Builder<?> builder) { 41 //this.location = builder.location; 42 this.parameters = builder.parameters; 43 this.location = builder.location; 44 //this.devices = builder.devices; 45 } 46 47 public static abstract class Builder<T extends Builder<T>> { 48 49 protected Location location; 50 protected Parameters parameters; 51 52 public T parameters(Parameters params){this.parameters = params; return self(); } 53 public T location(Location loc){this.location = loc; return self(); } 54 55 protected abstract T self(); 56 57 public ResourceCharacteristics build() { 58 return new ResourceCharacteristics(this); 59 } 60 } 61 private static class Builder2 extends Builder<Builder2> { 62 @Override 63 protected Builder2 self() { 64 return this; 65 } 66 } 67 68 public static Builder<?> builder() { 69 return new Builder2(); 70 } 71 72 /*public static class Builder { 73 74 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 75 //protected Location location; 76 protected Parameters parameters; 77 //protected List<Device> devices; 78 79 //public Builder location(Location loc){this.location = loc; return this; } 80 public Builder parameters(Parameters params){this.parameters = params; return this; } 81 //public Builder device(List<Device> dev){this.devices = dev; return this; } 82 public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; } 83 public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; } 84 85 public ResourceCharacteristics build() { 86 return new ResourceCharacteristics(this); 87 } 88 } 89 */ 90 93 91 94 92 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceFactory.java
r1095 r1207 1 1 package schedframe.resources.computing; 2 2 3 import schedframe.resources.CoolEmAllResourceType;4 3 import schedframe.resources.StandardResourceType; 5 4 import schedframe.resources.computing.description.ComputingResourceDescription; 6 import schedframe.resources.computing.recs.ComputeBox1;7 import schedframe.resources.computing.recs.Node;8 import schedframe.resources.computing.recs.NodeGroup;9 5 import schedframe.scheduling.Scheduler; 10 6 import schedframe.scheduling.manager.resources.ManagedResources; 11 7 import schedframe.scheduling.plugin.SchedulingPlugin; 12 8 import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; 13 import schedframe.scheduling.policy.AbstractManagementSystem;14 import schedframe.scheduling.policy.global.GridBroker;15 import schedframe.scheduling.policy.local.LocalManagementSystem;16 9 import schedframe.scheduling.queue.TaskQueueList; 17 import simulator.DCWormsConstants;18 10 19 11 20 public classResourceFactory {12 public interface ResourceFactory { 21 13 22 public static ComputingResource createResource(ComputingResourceDescription resDesc){ 23 24 if (resDesc.getType().equals(StandardResourceType.DataCenter)) 25 return new DataCenter(resDesc); 26 else if (resDesc.getType().equals(StandardResourceType.Rack)) 27 return new Rack(resDesc); 28 else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 29 return new ComputingNode(resDesc); 30 else if (resDesc.getType().equals(StandardResourceType.Processor)) 31 return new Processor(resDesc); 32 else if (resDesc.getType().equals(StandardResourceType.Core)) 33 return new Core(resDesc); 34 else if (resDesc.getType().equals(CoolEmAllResourceType.ComputeBox1)) 35 return new ComputeBox1(resDesc); 36 else if (resDesc.getType().equals(CoolEmAllResourceType.NodeGroup)) 37 return new NodeGroup(resDesc); 38 else if (resDesc.getType().equals(CoolEmAllResourceType.Node)) 39 return new Node(resDesc); 40 else if (resDesc.getType().equals(CoolEmAllResourceType.Processor)) 41 return new Processor(resDesc); 42 else if (resDesc.getType().equals(CoolEmAllResourceType.Core)) 43 return new Core(resDesc); 44 else 45 return new ComputingResource(resDesc); 14 public ComputingResource createComputingResource(ComputingResourceDescription resDesc); 15 16 //public Device createDevice(DeviceDescription devDesc); 46 17 47 /*switch(resDesc.getType()){ 48 case Grid: return new Grid(resDesc); 49 case DataCenter: return new DataCenter(resDesc); 50 case ComputingNode: return new ComputingNode(resDesc); 51 case Processor: return new Processor(resDesc); 52 default: 53 return new ComputingResource(resDesc); 54 }*/ 55 } 56 57 public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{ 58 AbstractManagementSystem ms; 59 switch(type){ 60 case GS: { 61 ms = new GridBroker("grid", 62 schedulingPlugin, execTimeEstimationPlugin, queues); 63 return new Scheduler(ms, type, managedResources); 64 } 65 case LS: { 66 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 67 schedulingPlugin, execTimeEstimationPlugin, queues); 68 return new Scheduler(ms, type, managedResources); 69 } 70 71 default:{ 72 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 73 schedulingPlugin, execTimeEstimationPlugin, queues); 74 return new Scheduler(ms, type, managedResources); 75 } 76 } 77 } 18 public Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception; 78 19 } 79 20 -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox1.java
r1098 r1207 1 package schedframe.resources.computing. recs;1 package schedframe.resources.computing.coolemall; 2 2 3 3 import java.util.List; … … 6 6 import schedframe.resources.StandardResourceType; 7 7 import schedframe.resources.computing.ComputingNode; 8 import schedframe.resources.computing.Processor;9 8 import schedframe.resources.computing.Rack; 10 9 import schedframe.resources.computing.description.ComputingResourceDescription; … … 23 22 @SuppressWarnings("unchecked") 24 23 public List<ComputingNode> getNodes(){ 25 return (List<ComputingNode>) getDescendantsByType(CoolEmAllResourceType.Node); 26 } 27 28 @SuppressWarnings("unchecked") 29 public List<Processor> getProcessors(){ 30 return (List<Processor>) getDescendantsByType(StandardResourceType.Processor); 24 return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 31 25 } 32 26 27 33 28 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/Node.java
r785 r1207 1 package schedframe.resources.computing.recs; 1 package schedframe.resources.computing.coolemall; 2 3 import java.util.ArrayList; 4 import java.util.List; 2 5 3 6 import schedframe.resources.computing.ComputingNode; 7 import schedframe.resources.computing.Core; 8 import schedframe.resources.computing.Processor; 4 9 import schedframe.resources.computing.description.ComputingResourceDescription; 5 10 … … 10 15 // TODO Auto-generated constructor stub 11 16 } 17 18 public List<Core> getCores(){ 19 List<Core> cores = new ArrayList<Core>(); 20 for(Processor proc: getProcessors()){ 21 cores.addAll(proc.getCores()); 22 } 23 return cores; 24 } 25 26 public List<Core> getFreeCores(){ 27 List<Core> freeCores = new ArrayList<Core>(); 28 for(Processor proc: getProcessors()){ 29 freeCores.addAll(proc.getFreeCores()); 30 } 31 return freeCores; 32 } 12 33 13 34 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java
r1098 r1207 1 package schedframe.resources.computing. recs;1 package schedframe.resources.computing.coolemall; 2 2 3 3 import java.util.List; 4 4 5 import schedframe.resources.CoolEmAllResourceType;6 5 import schedframe.resources.StandardResourceType; 7 6 import schedframe.resources.computing.ComputingResource; … … 17 16 @SuppressWarnings("unchecked") 18 17 public List<Node> getNodes(){ 19 return (List<Node>) getDescendantsByType( CoolEmAllResourceType.Node);18 return (List<Node>) getDescendantsByType(StandardResourceType.Node); 20 19 } 21 20 -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ComputingResourceDescription.java
r1113 r1207 1 1 package schedframe.resources.computing.description; 2 2 3 import java.io.FileInputStream;4 import java.io.FileNotFoundException;5 import java.io.IOException;6 3 import java.util.ArrayList; 4 import java.util.Collection; 5 import java.util.HashMap; 6 import java.util.Iterator; 7 7 import java.util.List; 8 import java.util.PropertyResourceBundle; 9 import java.util.ResourceBundle; 8 import java.util.Map; 10 9 11 import schedframe.Parameter;12 10 import schedframe.Parameters; 13 import schedframe.Property;14 11 import schedframe.resources.ResourceTypeFactory; 15 import schedframe.resources.computing.location.Location; 16 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 17 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 18 import schedframe.resources.computing.profiles.energy.airthroughput.plugin.AirThroughputEstimationPlugin; 19 import schedframe.resources.computing.profiles.energy.airthroughput.plugin.DefaultAirThroughputEstimationPlugin; 20 import schedframe.resources.computing.profiles.energy.power.PState; 21 import schedframe.resources.computing.profiles.energy.power.PowerProfile; 22 import schedframe.resources.computing.profiles.energy.power.PowerState; 23 import schedframe.resources.computing.profiles.energy.power.PowerStateNameFactory; 24 import schedframe.resources.computing.profiles.energy.power.Transition; 25 import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; 26 import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 27 import schedframe.resources.computing.profiles.energy.thermal.plugin.DefaultTemperatureEstimationPlugin; 28 import schedframe.resources.computing.profiles.energy.thermal.plugin.TemperatureEstimationPlugin; 12 import schedframe.resources.devices.Device; 13 import schedframe.resources.devices.description.DeviceDescription; 14 import schedframe.resources.devices.description.PhysicalResourceDescription; 29 15 import schedframe.resources.units.ResourceUnit; 30 16 import schedframe.resources.units.ResourceUnitFactory; 17 import schedframe.resources.units.ResourceUnitName; 31 18 import schedframe.resources.utils.ResourceIdGenerator; 32 19 import schemas.ComputingResource; 33 import schemas.PowerUsage;34 import schemas.Profile;35 import simulator.utils.InstanceFactory;36 import example.energy.DefaultEnergyEstimationPlugin;37 20 38 public class ComputingResourceDescription extends ExecutingResourceDescription {39 21 40 //protected Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits; 41 protected PowerProfile powerProfile; 42 protected AirThroughputProfile airThroughputProfile; 43 protected ThermalProfile thermalProfile; 44 protected Location location; 45 protected String category; 46 //protected Parameters parameters; 22 public class ComputingResourceDescription extends PhysicalResourceDescription implements ExecutingResourceDescription { 47 23 24 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 25 protected List<Device> devices; 26 48 27 public ComputingResourceDescription(ComputingResource computingResource) { 49 28 … … 55 34 if (computingResource.getComputingResourceTypeChoiceSequence() != null) { 56 35 initResourceUnits(computingResource.getComputingResourceTypeChoiceSequence().getResourceUnit()); 57 try { 58 if(System.getProperty("coolemall.resdesc") != null){ 59 schemas.EnergyEstimationPlugin eep = new schemas.EnergyEstimationPlugin(); 60 eep.setName(getEEP(createEEPQuery(computingResource), System.getProperty("coolemall.resdesc"))); 61 if(computingResource.getComputingResourceTypeChoiceSequence().getProfile() != null) { 62 if(computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile() != null) { 63 computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep); 64 } 65 } else { 66 schemas.Profile p = new schemas.Profile(); 67 computingResource.getComputingResourceTypeChoiceSequence().setProfile(p); 68 schemas.PowerProfile pp = new schemas.PowerProfile(); 69 computingResource.getComputingResourceTypeChoiceSequence().getProfile().setPowerProfile(pp); 70 computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep); 71 } 72 } 73 } catch (FileNotFoundException e) { 74 } catch (IOException e) { 75 } 36 76 37 initProfiles(computingResource.getComputingResourceTypeChoiceSequence().getProfile()); 77 38 initLocation(computingResource.getComputingResourceTypeChoiceSequence().getLocation()); 39 initDevices(computingResource.getComputingResourceTypeChoiceSequence().getDevice()); 78 40 this.parameters = extractParameters(computingResource.getComputingResourceTypeChoiceSequence().getParameter()); 79 41 } … … 97 59 } 98 60 } 99 100 private void initProfiles(Profile profile) {101 if (profile != null) {102 initPowerProfile(profile.getPowerProfile());103 initAirThroughputProfile(profile.getAirThroughputProfile());104 initThermalProfile(profile.getThermalProfile());105 }106 }107 61 108 private void initPowerProfile(schemas.PowerProfile powerProfileCharacteristic) { 109 110 if (powerProfileCharacteristic != null) { 111 EnergyEstimationPlugin energyEstimationPlugin = null; 112 List<PowerState> powerStates = null; 113 List<PState> pStates = null; 114 if(powerProfileCharacteristic.getEnergyEstimationPlugin() != null){ 115 String energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName(); 116 if(energyEstimationPluginName != null) { 117 energyEstimationPlugin = (EnergyEstimationPlugin) InstanceFactory.createInstance( 118 energyEstimationPluginName, EnergyEstimationPlugin.class); 119 } else { 120 energyEstimationPlugin = new DefaultEnergyEstimationPlugin(); 121 } 122 Parameters params = extractParameters(powerProfileCharacteristic.getEnergyEstimationPlugin().getParameter()); 123 energyEstimationPlugin.init(params); 62 private void initDevices(schemas.Device[] dev) { 63 if (dev != null){ 64 this.devices = new ArrayList<Device>(); 65 for(int i = 0; i < dev.length; i++){ 66 Device device = new Device(new DeviceDescription(dev[i])); 67 this.devices.add(device); 124 68 } 125 126 if(powerProfileCharacteristic.getPowerStates() != null) {127 powerStates = new ArrayList<PowerState>();128 int powerStateCount = powerProfileCharacteristic.getPowerStates().getPowerStateCount();129 for (int i = 0; i < powerStateCount ; i++) {130 schemas.PowerState ps = powerProfileCharacteristic.getPowerStates().getPowerState(i);131 List<Transition> transitions = new ArrayList<Transition>();132 int transitionCount = ps.getTransitionCount();133 for (int j = 0; j < transitionCount; j++) {134 schemas.Transition t = ps.getTransition(j);135 Transition transition = new Transition(PowerStateNameFactory.createPowerStateName(t.getTo()), t136 .getPowerUsage().getContent(), t.getTime().getContent());137 Parameters params = extractParameters(t.getParameter());138 transition.init(params);139 transitions.add(transition);140 }141 //CoolEmAll DEBB description case142 if(ps.getPowerUsage() == null){143 ps.setPowerUsage(new PowerUsage("0"));144 }145 PowerState powerState = new PowerState(PowerStateNameFactory.createPowerStateName(ps.getName()), ps146 .getPowerUsage().getContent(), transitions);147 Parameters params = extractParameters(ps.getParameter());148 powerState.init(params);149 powerStates.add(powerState);150 }151 }152 153 if(powerProfileCharacteristic.getParameter() != null){154 pStates = new ArrayList<PState>();155 int parameterCount = powerProfileCharacteristic.getParameterCount();156 for(int i = 0; i < parameterCount; i++){157 schemas.Parameter parameter = powerProfileCharacteristic.getParameter(i);158 if(parameter.getName().equals("pState")){159 PState.Builder builder = new PState.Builder();160 int propertyCount = parameter.getParameterTypeSequence().getPropertyCount();161 for(int j = 0; j < propertyCount; j++){162 schemas.Property property = parameter.getParameterTypeSequence().getProperty(j);163 if(property.getName().equals("name")){164 builder = builder.name(property.getStringValueWithUnit(0).getContent());165 } else if (property.getName().equals("frequency")){166 builder = builder.frequency(Double.valueOf(property.getStringValueWithUnit(0).getContent()));167 } else if (property.getName().equals("voltage")){168 builder = builder.voltage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));169 } else if (property.getName().equals("powerUsage")){170 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){171 builder = builder.powerUsage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));172 }173 } else if (property.getName().equals("powerUsageMin")){174 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){175 builder = builder.powerUsageMin(Double.valueOf(property.getStringValueWithUnit(0).getContent()));176 }177 } else if (property.getName().equals("powerUsageMax")){178 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){179 builder = builder.powerUsageMax(Double.valueOf(property.getStringValueWithUnit(0).getContent()));180 }181 }182 }183 PState pState = builder.build();184 pStates.add(pState);185 }186 }187 }188 this.powerProfile = new PowerProfile(energyEstimationPlugin, powerStates, pStates);189 Parameters params = extractParameters(powerProfileCharacteristic.getParameter());190 this.powerProfile.init(params);191 69 } 192 70 } 193 71 194 private void initAirThroughputProfile(schemas.AirThroughputProfile airThroughputProfile) { 195 if (airThroughputProfile != null) { 196 197 AirThroughputEstimationPlugin airThroughputEstimationPlugin = null; 198 List<AirThroughputState> airThroughputStates = null; 199 if(airThroughputProfile.getAirThroughputEstimationPlugin() != null){ 200 String airThroughputEstimationPluginName = airThroughputProfile.getAirThroughputEstimationPlugin().getName(); 201 if(airThroughputEstimationPluginName != null) { 202 airThroughputEstimationPlugin = (AirThroughputEstimationPlugin) InstanceFactory.createInstance( 203 airThroughputEstimationPluginName, AirThroughputEstimationPlugin.class); 204 } else { 205 airThroughputEstimationPlugin = new DefaultAirThroughputEstimationPlugin(); 206 } 207 Parameters params = extractParameters(airThroughputProfile.getAirThroughputEstimationPlugin().getParameter()); 208 airThroughputEstimationPlugin.init(params); 209 } 210 if(airThroughputProfile.getAirThroughputStates() != null){ 211 airThroughputStates = new ArrayList<AirThroughputState>(); 212 int airThrouhputStateCount = airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount(); 213 for (int i = 0; i < airThrouhputStateCount; i++) { 214 schemas.AirThroughputState ats = airThroughputProfile.getAirThroughputStates().getAirThroughputState(i); 215 AirThroughputState airThroughputState = new AirThroughputState(ats.getName(), ats.getValue() 216 .getContent(), ats.getPowerUsage().getContent()); 217 Parameters params = extractParameters(ats.getParameter()); 218 airThroughputState.init(params); 219 airThroughputStates.add(airThroughputState); 220 } 221 } 222 this.airThroughputProfile = new AirThroughputProfile(airThroughputEstimationPlugin, airThroughputStates); 223 Parameters params = extractParameters(airThroughputProfile.getParameter()); 224 this.airThroughputProfile.init(params); 225 } 72 public String getCompResourceParameterValue(String name){ 73 return getParameters().get(name).get(0).getContent(); 226 74 } 227 228 private void initThermalProfile(schemas.ThermalProfile thermalProfile) {229 230 if (thermalProfile != null) {231 232 TemperatureEstimationPlugin temperatureEstimationPlugin = null;233 234 if(thermalProfile.getTemperatureEstimationPlugin() != null){235 String temperatureEstimationPluginName = thermalProfile.getTemperatureEstimationPlugin().getName();236 if(temperatureEstimationPluginName != null) {237 temperatureEstimationPlugin = (TemperatureEstimationPlugin) InstanceFactory.createInstance(238 temperatureEstimationPluginName, TemperatureEstimationPlugin.class);239 } else {240 temperatureEstimationPlugin = new DefaultTemperatureEstimationPlugin();241 }242 Parameters params = extractParameters(thermalProfile.getTemperatureEstimationPlugin().getParameter());243 temperatureEstimationPlugin.init(params);244 }245 this.thermalProfile = new ThermalProfile();246 Parameters params = extractParameters(thermalProfile.getParameter());247 this.thermalProfile.init(params);248 }249 }250 251 private void initLocation(schemas.Location l) {252 if (location != null) {253 this.location = new Location(l.getHorizontal(), l.getVertical(), l.getDepth());254 Parameters params = extractParameters(l.getParameter());255 this.location.init(params);256 }257 }258 259 75 260 76 /*private Properties initProperties(schemas.Parameter[] parameters){ … … 285 101 return prop; 286 102 }*/ 287 288 private Parameters extractParameters(schemas.Parameter[] parameters){289 290 Parameters params = null;291 292 if(parameters.length != 0)293 params = new Parameters();294 295 for(int i = 0; i < parameters.length; i++){296 schemas.Parameter parameter = parameters[i];297 Parameter param = new Parameter(parameter.getName());298 if(parameter.getParameterTypeSequence() != null && parameter.getParameterTypeSequence().getProperty() != null)299 {300 int propertyCount = parameter.getParameterTypeSequence().getPropertyCount();301 for(int j = 0; j < propertyCount; j++){302 schemas.Property property = parameter.getParameterTypeSequence().getProperty(j);303 Property prop = new Property(property.getName());304 int stringValueWithUnitCount = property.getStringValueWithUnitCount();305 for(int k = 0; k < stringValueWithUnitCount; k++){306 prop.add(property.getStringValueWithUnit(k));307 }308 param.addProperty(prop);309 }310 } else {311 int stringValueWithUnitCount = parameter.getStringValueWithUnitCount();312 for(int j = 0; j < stringValueWithUnitCount; j++){313 param.add(parameter.getStringValueWithUnit(j));314 }315 }316 params.put(parameter.getName(), param);317 }318 return params;319 }320 103 321 public PowerProfile getPowerProfile() {322 return powerProfile;323 }324 104 325 public AirThroughputProfile getAirThroughputProfile() { 326 return airThroughputProfile; 327 } 328 329 public ThermalProfile getThermalProfile() { 330 return thermalProfile; 331 } 332 333 public Location getLocation() { 334 return location; 335 } 336 337 public String getCategory() { 338 return category; 105 public List<Device> getDevices() { 106 return devices; 339 107 } 340 108 341 109 342 /***COOLEMALL CASE RELATED***/ 343 344 private static ResourceBundle recsBundle; 345 346 private ResourceBundle getRecsBundle(String fileName) throws FileNotFoundException, IOException{ 347 if(recsBundle == null){ 348 recsBundle = new PropertyResourceBundle(new FileInputStream(fileName)); 110 public void addResourceUnit(ResourceUnit unit) { 111 if (this.resUnits == null) 112 this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 113 List<ResourceUnit> list = null; 114 if (this.resUnits.containsKey(unit.getName())) { 115 list = this.resUnits.get(unit.getName()); 116 } else { 117 list = new ArrayList<ResourceUnit>(1); 118 this.resUnits.put(unit.getName(), list); 349 119 } 350 return recsBundle;120 list.add(unit); 351 121 } 352 122 353 protected String getEEP(String query, String fileName) throws FileNotFoundException, IOException{ 354 ResourceBundle recsBundle = getRecsBundle(fileName); 355 return recsBundle.getString(query); 123 public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 124 return getResourceUnitList(unitName).get(0); 356 125 } 357 358 protected String createEEPQuery(ComputingResource compRes) { 359 String query = compRes.getClazz() + "EEP"; 360 return query; 126 127 public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 128 if (resUnits.containsKey(unitName)) 129 return resUnits.get(unitName); 130 else 131 throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 132 } 133 134 public Collection<ResourceUnit> getResourceUnit() { 135 if (resUnits == null) 136 return null; 137 List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 138 Collection<List<ResourceUnit>> lists = resUnits.values(); 139 Iterator<List<ResourceUnit>> itr = lists.iterator(); 140 141 while (itr.hasNext()) { 142 List<ResourceUnit> list = itr.next(); 143 values.addAll(list); 144 } 145 146 return values; 147 } 148 149 public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 150 return resUnits; 361 151 } 362 152 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ExecutingResourceDescription.java
r477 r1207 1 1 package schedframe.resources.computing.description; 2 2 3 import java.util.ArrayList;4 3 import java.util.Collection; 5 import java.util.HashMap;6 import java.util.Iterator;7 4 import java.util.List; 8 5 import java.util.Map; 9 6 10 import schedframe.Parameters;11 import schedframe.resources.ResourceType;12 7 import schedframe.resources.units.ResourceUnit; 13 8 import schedframe.resources.units.ResourceUnitName; 14 9 15 public class ExecutingResourceDescription extends AbstractResourceDescription { 10 public interface ExecutingResourceDescription { 11 12 public void addResourceUnit(ResourceUnit unit); 13 14 public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException ; 16 15 17 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 18 protected Parameters parameters; 16 public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException; 17 18 public Collection<ResourceUnit> getResourceUnit(); 19 19 20 public ExecutingResourceDescription(ResourceType type) { 21 super(type); 22 } 23 24 public Parameters getParameters() { 25 return parameters; 26 } 27 28 public String getCompResourceParameterValue(String name){ 29 return getParameters().get(name).get(0).getContent(); 30 } 31 32 public void addResourceUnit(ResourceUnit unit) { 33 if (this.resUnits == null) 34 this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 35 List<ResourceUnit> list = null; 36 if (this.resUnits.containsKey(unit.getName())) { 37 list = this.resUnits.get(unit.getName()); 38 } else { 39 list = new ArrayList<ResourceUnit>(1); 40 this.resUnits.put(unit.getName(), list); 41 } 42 list.add(unit); 43 } 44 45 public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 46 return getResourceUnitList(unitName).get(0); 47 } 48 49 public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 50 if (resUnits.containsKey(unitName)) 51 return resUnits.get(unitName); 52 else 53 throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 54 } 55 56 public Collection<ResourceUnit> getResourceUnit() { 57 if (resUnits == null) 58 return null; 59 List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 60 Collection<List<ResourceUnit>> lists = resUnits.values(); 61 Iterator<List<ResourceUnit>> itr = lists.iterator(); 62 63 while (itr.hasNext()) { 64 List<ResourceUnit> list = itr.next(); 65 values.addAll(list); 66 } 67 68 return values; 69 } 70 71 public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 72 return resUnits; 73 } 20 public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits(); 74 21 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ResourceDescription.java
r477 r1207 5 5 import java.util.List; 6 6 7 import schedframe.Parameters; 7 8 import schedframe.resources.ResourceType; 8 9 9 10 10 public abstract class AbstractResourceDescription {11 public abstract class ResourceDescription { 11 12 12 13 protected String id; 13 14 protected ResourceType type; 14 protected List<AbstractResourceDescription> children; 15 protected List<ResourceDescription> children; 16 protected Parameters parameters; 15 17 16 public AbstractResourceDescription(ResourceType type){18 public ResourceDescription(ResourceType type){ 17 19 this.type = type; 18 this.children = null;19 20 } 20 21 21 public List< AbstractResourceDescription> getChildren() {22 public List<ResourceDescription> getChildren() { 22 23 return children; 23 24 } 24 25 25 public void setChildren(List< AbstractResourceDescription> children) {26 public void setChildren(List<ResourceDescription> children) { 26 27 this.children = children; 27 28 } 28 29 29 public void addChildren( AbstractResourceDescription child) {30 public void addChildren(ResourceDescription child) { 30 31 //child.setParent(this); 31 32 if(children == null) 32 children = new ArrayList< AbstractResourceDescription> (1);33 children = new ArrayList<ResourceDescription> (1); 33 34 this.children.add(child); 34 35 } … … 40 41 public ResourceType getType() { 41 42 return type; 43 } 44 45 public Parameters getParameters() { 46 return parameters; 42 47 } 43 48 -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java
r1165 r1207 7 7 8 8 import schedframe.events.Event; 9 import schedframe.resources.computing.ComputingResource;10 9 import schedframe.resources.computing.extensions.Extension; 11 10 import schedframe.resources.computing.extensions.ExtensionException; … … 20 19 import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 21 20 import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 21 import schedframe.resources.devices.PhysicalResource; 22 22 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 23 import simulator.DataCenterWorkloadSimulator; 23 24 24 25 public class EnergyExtension implements Extension{ … … 35 36 protected ThermalProfile thermalProfile; 36 37 37 protected ComputingResource computingResource; 38 39 40 public EnergyExtension(ComputingResource computingResource, PowerInterface powerInterface, PowerProfile powerProfile) { 38 protected PhysicalResource resource; 39 40 41 /*public EnergyExtension(PhysicalResource resource, PowerInterface powerInterface, PowerProfile powerProfile) { 42 super(); 43 this.resource = resource; 41 44 this.powerProfile = powerProfile; 42 this.powerInterface = PowerInterfaceFactory.createPowerInterface( computingResource, powerProfile);43 } 44 45 public EnergyExtension( ComputingResource computingResource, PowerProfile powerProfile,45 this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 46 } 47 48 public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile, 46 49 AirThroughputProfile airFlowProfile) { 47 50 super(); 48 this. computingResource = computingResource;51 this.resource = resource; 49 52 this.powerProfile = powerProfile; 50 this.powerInterface = PowerInterfaceFactory.createPowerInterface( computingResource, powerProfile);53 this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 51 54 this.airFlowProfile = airFlowProfile; 52 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface( computingResource, airFlowProfile);53 } 54 55 public EnergyExtension( ComputingResource computingResource, PowerProfile powerProfile,55 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); 56 } 57 58 public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile, 56 59 AirThroughputProfile airFlowProfile, ThermalProfile thermalProfile) { 57 60 super(); 58 this. computingResource = computingResource;61 this.resource = resource; 59 62 this.powerProfile = powerProfile; 60 this.powerInterface = PowerInterfaceFactory.createPowerInterface( computingResource, powerProfile);63 this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 61 64 this.airFlowProfile = airFlowProfile; 62 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface( computingResource, airFlowProfile);65 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); 63 66 this.thermalProfile = thermalProfile; 64 this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(computingResource, thermalProfile); 65 } 66 67 this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); 68 }*/ 69 70 public static class Builder { 71 72 protected PhysicalResource resource; 73 protected PowerInterface powerInterface; 74 protected PowerProfile powerProfile; 75 76 protected AirThroughputInterface airFlowInterface; 77 protected AirThroughputProfile airFlowProfile; 78 79 protected ThermalInterface thermalInterface; 80 protected ThermalProfile thermalProfile; 81 82 public Builder resource(PhysicalResource res) {this.resource = res; return this;} 83 84 public Builder powerProfile(PowerProfile pp){this.powerProfile = pp; this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); return this; } 85 86 public Builder airFlowProfile(AirThroughputProfile atp){this.airFlowProfile = atp; this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); return this; } 87 88 public Builder thermalProfile(ThermalProfile tp){this.thermalProfile = tp; this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); return this; } 89 90 public EnergyExtension build() { 91 return new EnergyExtension(this); 92 } 93 } 94 95 private EnergyExtension(Builder builder) { 96 this.resource = builder.resource; 97 this.powerInterface = builder.powerInterface; 98 this.powerProfile = builder.powerProfile; 99 100 this.airFlowInterface = builder.airFlowInterface ; 101 this.airFlowProfile = builder.airFlowProfile; 102 103 this.thermalInterface = builder.thermalInterface; 104 this.thermalProfile = builder.thermalProfile; 105 } 106 107 67 108 public boolean supportsEvent(Event event) { 68 109 … … 82 123 if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 83 124 return true; 125 if(event.getType().getName().equals(EnergyEventType.TEMPERATURE_CHANGED.getName())) 126 return true; 84 127 85 128 else return false; … … 90 133 EnergyEvent enEvent = (EnergyEvent)event; 91 134 double power = 0; 92 double temperature = 0;135 boolean status = false; 93 136 try{ 94 137 switch (enEvent.getType()) { 95 138 96 139 case POWER_STATE_CHANGED: 97 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl( computingResource.getName()), computingResource);140 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 98 141 /*if(computingResource instanceof ComputingNode){ 99 142 ComputingNode node = (ComputingNode)computingResource; … … 109 152 } 110 153 } 111 else*/ powerProfile.addToPowerUsageHistory(power);112 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);113 thermalProfile.addToTemperatureHistory(temperature);154 else*/ 155 156 status = powerProfile.addToPowerUsageHistory(power); 114 157 break; 115 158 116 159 case FREQUENCY_CHANGED: 117 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 118 powerProfile.addToPowerUsageHistory(power); 119 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 120 thermalProfile.addToTemperatureHistory(temperature); 160 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 161 status = powerProfile.addToPowerUsageHistory(power); 121 162 break; 122 163 123 164 case TASK_STARTED: 124 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 125 powerProfile.addToPowerUsageHistory(power); 126 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 127 thermalProfile.addToTemperatureHistory(temperature); 165 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 166 status = powerProfile.addToPowerUsageHistory(power); 128 167 break; 129 168 130 169 case TASK_FINISHED: 131 //System.out.println(this.resource.getName() + " - ENERGY EXTENSION: TASK FINISHED"); 132 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 133 //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 134 powerProfile.addToPowerUsageHistory(power); 135 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 136 thermalProfile.addToTemperatureHistory(temperature); 170 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 171 status = powerProfile.addToPowerUsageHistory(power); 137 172 break; 138 173 139 174 case RESOURCE_UTILIZATION_CHANGED: 140 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 141 powerProfile.addToPowerUsageHistory(power); 142 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 143 thermalProfile.addToTemperatureHistory(temperature); 175 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 176 status = powerProfile.addToPowerUsageHistory(power); 144 177 break; 145 178 146 179 case AIRFLOW_STATE_CHANGED: 147 double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 148 airFlowProfile.addToPowerUsageHistory(airFlow); 149 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 150 powerProfile.addToPowerUsageHistory(power); 151 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 180 double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 181 airFlowProfile.addToAirFlowHistory(airFlow); 182 break; 183 184 case TEMPERATURE_CHANGED: 185 double temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 152 186 thermalProfile.addToTemperatureHistory(temperature); 153 187 break; … … 156 190 157 191 } 192 if(status){ 193 DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, resource.getFullName())); 194 } 158 195 } 159 196 -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputInterfaceFactory.java
r753 r1207 1 1 package schedframe.resources.computing.profiles.energy.airthroughput; 2 2 3 import schedframe.resources.StandardResourceType; 3 4 import schedframe.resources.computing.ComputingResource; 4 5 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 5 6 import schedframe.resources.computing.profiles.energy.airthroughput.ui.ComputingResourceAirThroughputInterface; 7 import schedframe.resources.devices.PhysicalResource; 8 import schedframe.resources.devices.PhysicalResourceAirThroughputInterface; 9 import schedframe.resources.devices.coolemall.FanAirThroughputInterface; 6 10 7 11 public class AirThroughputInterfaceFactory { 8 12 9 public static AirThroughputInterface createAirThroughputInterface( ComputingResource resource, AirThroughputProfile atp){13 public static AirThroughputInterface createAirThroughputInterface(PhysicalResource resource, AirThroughputProfile atp){ 10 14 if(atp == null) 11 15 return null; 12 AirThroughputInterface airThroughputInterface = new ComputingResourceAirThroughputInterface(resource, atp); 13 16 AirThroughputInterface airThroughputInterface = null; 17 if(resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 18 airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp); 19 else if(resource.getType().getName().equals(StandardResourceType.Fan.getName())) 20 airThroughputInterface = new FanAirThroughputInterface(resource, atp); 21 else if(resource.getType().getName().equals(StandardResourceType.Inlet.getName())) 22 airThroughputInterface = new FanAirThroughputInterface(resource, atp); 23 else if(resource.getType().getName().equals(StandardResourceType.Outlet.getName())) 24 airThroughputInterface = new FanAirThroughputInterface(resource, atp); 25 else if(resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName())) 26 airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp); 27 else 28 airThroughputInterface = new ComputingResourceAirThroughputInterface((ComputingResource)resource, atp); 14 29 return airThroughputInterface; 15 30 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java
r495 r1207 28 28 } 29 29 30 public void addTo PowerUsageHistory(double airFlow) {30 public void addToAirFlowHistory(double airFlow) { 31 31 32 32 if (airFlowHistory.size() == 0) { -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/StandardAirThroughputStateName.java
r753 r1207 3 3 public enum StandardAirThroughputStateName implements AirThroughputStateName{ 4 4 5 FAN_ON,6 FAN_OFF;5 ON, 6 OFF; 7 7 8 8 public String getName() { -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java
r754 r1207 4 4 5 5 import schedframe.Parameters; 6 import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 6 7 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 7 8 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputStateName; … … 9 10 public interface AirThroughputInterface { 10 11 11 public AirThroughputStateName 12 public AirThroughputStateName getAirThroughputState(); 12 13 13 14 public boolean setAirThroughputState(AirThroughputStateName airThroughputState); … … 21 22 public double getPowerConsumption(AirThroughputStateName state) throws NoSuchFieldException; 22 23 24 public AirFlowValue getRecentAirFlow(); 25 26 List<AirFlowValue> getAirFlowHistory(); 27 23 28 public Parameters getParameters(); 29 30 24 31 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/ComputingResourceAirThroughputInterface.java
r754 r1207 4 4 import java.util.List; 5 5 6 import org.joda.time.DateTimeUtils; 7 6 8 import schedframe.Parameters; 7 9 import schedframe.resources.computing.ComputingResource; 8 10 import schedframe.resources.computing.profiles.energy.EnergyEvent; 9 11 import schedframe.resources.computing.profiles.energy.EnergyEventType; 12 import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 10 13 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 11 14 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; … … 22 25 this.resource = resource; 23 26 this.airThroughputProfile = airThroughputProfile; 24 this.currentAirThroughputState = StandardAirThroughputStateName. FAN_ON;27 this.currentAirThroughputState = StandardAirThroughputStateName.ON; 25 28 } 26 29 … … 34 37 35 38 //TO DO - notifications should be called for all resources starting form the lowest layer 36 resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getName())); 39 resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getFullName())); 40 resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 37 41 return true; 38 42 } … … 83 87 } 84 88 89 public AirFlowValue getRecentAirFlow() { 90 AirFlowValue airFlow = null; 91 int lastIdx = getAirFlowHistory().size() - 1; 92 if(lastIdx >= 0) 93 airFlow = getAirFlowHistory().get(lastIdx); 94 else { 95 try { 96 airFlow = new AirFlowValue(DateTimeUtils.currentTimeMillis(), getAirFlow(currentAirThroughputState)); 97 } catch (NoSuchFieldException e) { 98 } 99 } 100 return airFlow; 101 } 102 103 public List<AirFlowValue> getAirFlowHistory(){ 104 return airThroughputProfile.getAirThroughputHistory(); 105 } 106 107 85 108 public Parameters getParameters() { 86 109 return airThroughputProfile.getParameters(); -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PState.java
r1119 r1207 1 1 package schedframe.resources.computing.profiles.energy.power; 2 3 import java.util.Map; 4 import java.util.TreeMap; 2 5 3 6 public class PState { … … 9 12 protected double powerUsageMin; 10 13 protected double powerUsageMax; 11 14 //protected List<LoadPowerUsage> loadPowerUsageList; 15 protected Map<Double, Double> loadPowerUsage; 16 12 17 /*public PState(PStateType name, double frequency, double voltage, double power) { 13 18 super(); … … 38 43 return powerUsageMax; 39 44 } 40 45 /*public List<LoadPowerUsage> getLoadPowerUsageList() { 46 return loadPowerUsageList; 47 }*/ 48 public Map<Double, Double> getLoadPowerUsage() { 49 if(loadPowerUsage == null) { 50 return new TreeMap<Double, Double>(); 51 } 52 return loadPowerUsage; 53 } 54 41 55 public static class Builder { 42 56 … … 47 61 protected double powerUsageMin; 48 62 protected double powerUsageMax; 63 //protected List<LoadPowerUsage> loadPowerUsageList = new ArrayList<LoadPowerUsage>(); 64 protected Map<Double, Double> loadPowerUsage = new TreeMap<Double, Double>(); 49 65 50 66 public Builder name(String name){this.name = name; return this; } … … 54 70 public Builder powerUsageMin(double rate){this.powerUsageMin = rate; return this; } 55 71 public Builder powerUsageMax(double rate){this.powerUsageMax = rate; return this; } 72 //public Builder loadPowerUsage(LoadPowerUsage lpu){this.loadPowerUsageList.add(lpu); return this; } 73 public Builder loadPowerUsage(double load, double power){this.loadPowerUsage.put(load, power); return this; } 56 74 57 75 public PState build() { … … 67 85 this.powerUsageMin = builder.powerUsageMin; 68 86 this.powerUsageMax = builder.powerUsageMax; 87 //this.loadPowerUsageList = builder.loadPowerUsageList; 88 this.loadPowerUsage = builder.loadPowerUsage; 69 89 } 90 91 70 92 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java
r1104 r1207 1 1 package schedframe.resources.computing.profiles.energy.power; 2 2 3 import schedframe.resources.CoolEmAllResourceType;4 3 import schedframe.resources.StandardResourceType; 5 4 import schedframe.resources.computing.ComputingResource; 6 5 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 6 import schedframe.resources.devices.PhysicalResource; 7 import schedframe.resources.devices.PhysicalResourcePowerInterface; 7 8 8 9 public class PowerInterfaceFactory { 9 10 10 11 12 //new113 /*public static PowerInterface createPowerProfile(ResourceType resourceType, List<PowerState> powerStates, List<PState> pStates, String eepn){14 15 PowerInterface powerProfile;16 17 switch(resourceType){18 case DataCenter: powerProfile = new DataCenterPowerInterfaceNew(eepn, powerStates); break;19 case ComputingNode: powerProfile = new ComputingNodePowerInterfaceNew(eepn, powerStates); break;20 case Processor: powerProfile = new CPUPowerInterfaceNew(eepn, powerStates, pStates); break;21 default:22 throw new IllegalArgumentException("ResourceType " + resourceType + " is not supported.");23 }24 25 return powerProfile;26 }*/27 11 28 public static PowerInterface createPowerInterface( ComputingResource resource, PowerProfile pp){12 public static PowerInterface createPowerInterface(PhysicalResource resource, PowerProfile pp){ 29 13 if(pp == null) 30 14 return null; 31 15 PowerInterface powerInterface; 32 16 33 17 if(resource.getType().getName().equals(StandardResourceType.DataCenter.getName())) 34 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface( resource, pp);35 else if (resource.getType().getName().equals(StandardResourceType. ComputingNode.getName()))36 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface( resource, pp);18 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface((ComputingResource)resource, pp); 19 else if (resource.getType().getName().equals(StandardResourceType.Node.getName())) 20 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface((ComputingResource)resource, pp); 37 21 else if (resource.getType().getName().equals(StandardResourceType.Processor.getName())) 38 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface(resource, pp); 39 else if (resource.getType().getName().equals(CoolEmAllResourceType.Node.getName())) 40 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface(resource, pp); 22 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface((ComputingResource)resource, pp); 23 else if (resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 24 powerInterface = new PhysicalResourcePowerInterface(resource, pp); 25 else if (resource.getType().getName().equals(StandardResourceType.Fan.getName())) 26 powerInterface = new PhysicalResourcePowerInterface(resource, pp); 27 else if (resource.getType().getName().equals(StandardResourceType.Inlet.getName())) 28 powerInterface = new PhysicalResourcePowerInterface(resource, pp); 29 else if (resource.getType().getName().equals(StandardResourceType.Outlet.getName())) 30 powerInterface = new PhysicalResourcePowerInterface(resource, pp); 31 else if (resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName())) 32 powerInterface = new PhysicalResourcePowerInterface(resource, pp); 33 else if (resource.getType().getName().equals(StandardResourceType.Heatsink.getName())) 34 powerInterface = new PhysicalResourcePowerInterface(resource, pp); 41 35 else 42 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface( resource, pp);36 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface((ComputingResource)resource, pp); 43 37 44 38 /*switch(resource.getType()){ -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java
r1167 r1207 24 24 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 25 25 this.energyEstimationPlugin = energyEstimationPlugin; 26 this.supportedPowerStates = powerStates; 26 27 this.powerUsage = new ArrayList<PowerUsage>(); 27 this.supportedPowerStates = powerStates;28 initDefaultPowerStates(); 28 29 } 29 30 30 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, 31 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, List<PState> pStates) { 31 32 this.energyEstimationPlugin = energyEstimationPlugin; 32 33 this.supportedPowerStates = powerStates; … … 37 38 supportedPStates.put(pState.getName(), pState); 38 39 } 40 initDefaultPowerStates(); 39 41 } 40 42 … … 60 62 } 61 63 62 public List<PowerState> getSupportedPowerStates() throws NoSuchFieldException{64 public List<PowerState> getSupportedPowerStates() { 63 65 if(supportedPowerStates == null) 64 throw new NoSuchFieldException("Supported power states are not defined.");66 return new ArrayList<PowerState>(); 65 67 return supportedPowerStates; 66 68 } … … 111 113 } 112 114 113 115 protected void initDefaultPowerStates(){ 116 boolean supportsON = false; 117 boolean supportsOFF = false; 118 if(supportedPowerStates == null){ 119 supportedPowerStates = new ArrayList<PowerState>(); 120 } 121 for(PowerState ps: supportedPowerStates){ 122 if(ps.getName().equals(StandardPowerStateName.ON)){ 123 supportsON = true; 124 } else if (ps.getName().equals(StandardPowerStateName.OFF)){ 125 supportsOFF = true; 126 } 127 } 128 129 if(!supportsON){ 130 supportedPowerStates.add(new PowerState(StandardPowerStateName.ON, -1, new ArrayList<Transition>())); 131 } 132 if(!supportsOFF){ 133 supportedPowerStates.add(new PowerState(StandardPowerStateName.OFF, -1, new ArrayList<Transition>())); 134 } 135 } 114 136 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java
r477 r1207 2 2 3 3 import schedframe.Plugin; 4 import schedframe.resources.computing.ComputingResource;5 4 import schedframe.resources.computing.profiles.energy.EnergyEvent; 5 import schedframe.resources.devices.PhysicalResource; 6 6 import schedframe.scheduling.manager.tasks.JobRegistry; 7 7 8 8 public interface EnergyEstimationPlugin extends Plugin { 9 9 10 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource);10 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 11 11 12 public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource);12 public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 13 13 14 public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource);14 public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 15 15 16 16 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java
r1166 r1207 1 1 package schedframe.resources.computing.profiles.energy.power.ui; 2 2 3 4 5 import org.joda.time.DateTime; 6 7 import schedframe.SimulatedEnvironment; 3 8 import schedframe.resources.ResourceStatus; 4 9 import schedframe.resources.computing.ComputingNode; … … 38 43 39 44 if(!pePowerStateChangeStatus){ 40 computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.get Name()));45 computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getFullName())); 41 46 } 42 47 … … 48 53 } 49 54 //computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 55 //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 50 56 return true; 51 57 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java
r579 r1207 4 4 import java.util.List; 5 5 6 import org.joda.time.DateTime; 6 7 import org.joda.time.DateTimeUtils; 7 8 8 9 import schedframe.Parameters; 10 import schedframe.SimulatedEnvironment; 9 11 import schedframe.resources.ResourceStatus; 10 12 import schedframe.resources.computing.ComputingResource; … … 46 48 } 47 49 //notifications from all levels 48 resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.get Name()));50 resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 49 51 50 52 //notification from last level 51 53 //if (resource.getChildren() == null) resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource)); 52 54 55 //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 53 56 return true; 54 57 } … … 70 73 71 74 public boolean supportPowerState(PowerStateName state) { 72 try { 73 for(PowerState powerState: powerProfile.getSupportedPowerStates()){ 74 if(powerState.getName().equals(state)){ 75 return true; 76 } 75 for(PowerState powerState: powerProfile.getSupportedPowerStates()){ 76 if(powerState.getName().equals(state)){ 77 return true; 77 78 } 78 } catch (NoSuchFieldException e) {79 return false;80 79 } 81 80 return false; -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java
r495 r1207 1 1 package schedframe.resources.computing.profiles.energy.power.ui; 2 2 3 import org.joda.time.DateTime; 4 5 import schedframe.SimulatedEnvironment; 3 6 import schedframe.resources.computing.ComputingResource; 4 7 import schedframe.resources.computing.DataCenter; … … 23 26 child.getPowerInterface().setPowerState(state); 24 27 } 25 28 //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 26 29 return true; 27 30 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java
r782 r1207 4 4 import java.util.Map; 5 5 6 import org.joda.time.DateTime; 7 8 import schedframe.SimulatedEnvironment; 6 9 import schedframe.resources.ResourceStatus; 7 10 import schedframe.resources.computing.ComputingResource; … … 16 19 17 20 protected PState currentPState; 18 19 21 20 22 public ProcessorPowerInterface(ComputingResource resource, PowerProfile pp){ … … 34 36 resource.setStatus(ResourceStatus.FREE); 35 37 } 36 resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.get Name()));38 resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 37 39 } 38 40 … … 68 70 //speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 69 71 //new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED); 70 resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.get Name()));72 resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getFullName())); 71 73 //resource.getScheduler().sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, resource.getName()); 74 75 //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "PSTATE_CHANGED", pStateName); 72 76 return true; 73 77 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/thermal/ThermalInterfaceFactory.java
r803 r1207 1 1 package schedframe.resources.computing.profiles.energy.thermal; 2 2 3 import schedframe.resources.StandardResourceType; 3 4 import schedframe.resources.computing.ComputingResource; 4 5 import schedframe.resources.computing.profiles.energy.thermal.ui.ComputingResourceThermalInterface; 5 6 import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 7 import schedframe.resources.devices.PhysicalResource; 8 import schedframe.resources.devices.PhysicalResourceThermalInterface; 6 9 7 10 public class ThermalInterfaceFactory { 8 public static ThermalInterface createThermalInterface( ComputingResource resource, ThermalProfile tp){11 public static ThermalInterface createThermalInterface(PhysicalResource resource, ThermalProfile tp){ 9 12 if(tp == null) 10 13 return null; 11 ThermalInterface thermalInterface = new ComputingResourceThermalInterface(resource, tp); 12 14 ThermalInterface thermalInterface; 15 if (resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 16 thermalInterface = new PhysicalResourceThermalInterface(resource, tp); 17 else if (resource.getType().getName().equals(StandardResourceType.Fan.getName())) 18 thermalInterface = new PhysicalResourceThermalInterface(resource, tp); 19 else 20 thermalInterface = new ComputingResourceThermalInterface((ComputingResource)resource, tp); 13 21 return thermalInterface; 14 22 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/properties/ResourceProperties.java
r477 r1207 3 3 import java.util.Properties; 4 4 5 import schedframe.resources.computing.description. AbstractResourceDescription;5 import schedframe.resources.computing.description.ResourceDescription; 6 6 7 7 public class ResourceProperties extends Properties{ … … 16 16 } 17 17 18 public ResourceProperties( AbstractResourceDescription ard){18 public ResourceProperties(ResourceDescription ard){ 19 19 20 20 } -
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/validator/ResourceNameValidator.java
r477 r1207 13 13 @Override 14 14 public boolean validate(ComputingResource resource) { 15 return resource.get Name().equals(name);15 return resource.getFullName().equals(name); 16 16 } 17 17 -
DCWoRMS/branches/coolemall/src/schedframe/resources/utils/ResourceIdGenerator.java
r816 r1207 2 2 3 3 import java.util.HashMap; 4 5 import schedframe.resources.ResourceType;6 4 7 5 public class ResourceIdGenerator { … … 11 9 public static int getId(String key){ 12 10 13 int value = 0;11 int value = 1; 14 12 if(resourceCounter.containsKey(key)){ 15 13 value = resourceCounter.get(key); -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/ResourceHistoryItem.java
r477 r1207 8 8 import schedframe.resources.units.ResourceUnitName; 9 9 10 //TODO - change name 10 11 public class ResourceHistoryItem { 11 12 -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/SchedulerDescription.java
r477 r1207 2 2 3 3 import java.util.ArrayList; 4 import java.util.Collection; 4 5 import java.util.HashMap; 5 6 import java.util.Iterator; … … 9 10 import schedframe.resources.StandardResourceType; 10 11 import schedframe.resources.computing.description.ExecutingResourceDescription; 12 import schedframe.resources.computing.description.ResourceDescription; 11 13 import schedframe.resources.providers.ResourceProvider; 12 import schedframe.resources.units.AbstractResourceUnit;13 14 import schedframe.resources.units.ResourceUnit; 14 15 import schedframe.resources.units.ResourceUnitName; 15 16 import schedframe.scheduling.queue.QueueDescription; 16 17 17 public class SchedulerDescription extends ExecutingResourceDescription{18 public class SchedulerDescription extends ResourceDescription implements ExecutingResourceDescription{ 18 19 19 20 protected ResourceProvider provider; 20 21 protected List<QueueDescription> accesQueues; 22 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 21 23 22 24 public SchedulerDescription(ResourceProvider provider){ … … 62 64 return provider; 63 65 } 66 67 public void addResourceUnit(ResourceUnit unit) { 68 if (this.resUnits == null) 69 this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 70 List<ResourceUnit> list = null; 71 if (this.resUnits.containsKey(unit.getName())) { 72 list = this.resUnits.get(unit.getName()); 73 } else { 74 list = new ArrayList<ResourceUnit>(1); 75 this.resUnits.put(unit.getName(), list); 76 } 77 list.add(unit); 78 } 79 80 public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 81 return getResourceUnitList(unitName).get(0); 82 } 83 84 public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 85 if (resUnits.containsKey(unitName)) 86 return resUnits.get(unitName); 87 else 88 throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 89 } 90 91 public Collection<ResourceUnit> getResourceUnit() { 92 if (resUnits == null) 93 return null; 94 List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 95 Collection<List<ResourceUnit>> lists = resUnits.values(); 96 Iterator<List<ResourceUnit>> itr = lists.iterator(); 97 98 while (itr.hasNext()) { 99 List<ResourceUnit> list = itr.next(); 100 values.addAll(list); 101 } 102 103 return values; 104 } 105 106 public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 107 return resUnits; 108 } 64 109 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/ClusterResourceManager.java
r477 r1207 23 23 public List<ComputingNode> getComputingNodes(){ 24 24 try { 25 return (List<ComputingNode>) getResourcesOfType(StandardResourceType. ComputingNode);25 return (List<ComputingNode>) getResourcesOfType(StandardResourceType.Node); 26 26 } catch (ResourceException e) { 27 27 return new ArrayList<ComputingNode>(); … … 40 40 @SuppressWarnings("unchecked") 41 41 public List<ComputingNode> getComputingNodes(Properties properties){ 42 properties.setProperty("type", StandardResourceType. ComputingNode.toString());42 properties.setProperty("type", StandardResourceType.Node.toString()); 43 43 return (List<ComputingNode>) filterResources(properties); 44 44 -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/LocalResourceManager.java
r1054 r1207 19 19 import schedframe.resources.StandardResourceType; 20 20 import schedframe.resources.computing.ComputingResource; 21 import schedframe.resources.computing.ComputingResourceCharacteristics; 21 22 import schedframe.resources.computing.ResourceCharacteristics; 22 23 import schedframe.resources.computing.validator.ResourcePropertiesValidator; … … 138 139 for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) { 139 140 ComputingResource resource = computingResources.get(i); 140 if (resource.get Name().equals(resourceName))141 if (resource.getFullName().equals(resourceName)) 141 142 resourceWithName = resource; 142 143 else … … 154 155 while (!toExamine.isEmpty()) { 155 156 ComputingResource resource = toExamine.pop(); 156 ResourceCharacteristics resourceCharacteristic =resource.getResourceCharacteristic();157 ComputingResourceCharacteristics resourceCharacteristic = (ComputingResourceCharacteristics)resource.getResourceCharacteristic(); 157 158 List<ResourceUnit> units = null; 158 159 units = resourceCharacteristic.getResourceUnits().get(unitName); … … 266 267 for(int i = 0 ; i < computingResources.size() && resourceWithName == null; i++){ 267 268 ComputingResource resource = computingResources.get(i); 268 if(resource.get Name().equals(resName))269 if(resource.getFullName().equals(resName)) 269 270 resourceWithName = resource; 270 271 else -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
r1162 r1207 24 24 25 25 import qcg.shared.constants.BrokerConstants; 26 import schedframe. ResourceController;26 import schedframe.SimulatedEnvironment; 27 27 import schedframe.events.scheduling.SchedulingEvent; 28 28 import schedframe.events.scheduling.SchedulingEventType; … … 323 323 ExecTask task = iter.next(); 324 324 Executable exec = (Executable)task; 325 //exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration());326 325 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 327 326 UsedResourcesList usedResourcesList = exec.getUsedResources(); … … 338 337 for (ComputingResource resource : pes) { 339 338 resource.handleEvent(new EnergyEvent(eventType, obj)); 339 //DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj)); 340 340 } 341 341 /*try { … … 350 350 ComputingResource resource = null; 351 351 try { 352 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());352 resource = SimulatedEnvironment.getComputingResourceByName(peUnit.getResourceId()); 353 353 } catch (ResourceException e) { 354 354 return; … … 428 428 if(exec.getResourceConsumptionProfile().getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){ 429 429 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 430 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 431 notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 430 432 } else { 431 433 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask); 434 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 435 notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 432 436 } 433 437 } … … 540 544 job.setStatus((int)BrokerConstants.JOB_STATUS_SUBMITTED); 541 545 } catch (Exception e) { 542 // TODO Auto-generated catch block543 546 e.printStackTrace(); 544 547 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Job.java
r1159 r1207 7 7 import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 8 8 9 import gridsim.dcworms.DCWormsTags;10 9 11 10 import java.io.StringWriter; -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java
r1194 r1207 4 4 import java.io.StringWriter; 5 5 import java.util.ArrayList; 6 import java.util.LinkedList;7 6 import java.util.List; 8 7 … … 22 21 import org.qcg.broker.schemas.resreqs.ProcessesResourceRequirements; 23 22 import org.qcg.broker.schemas.resreqs.Requirements; 24 import org.qcg.broker.schemas.resreqs.ResourceConsumptionType;25 23 import org.qcg.broker.schemas.resreqs.TaskResourceRequirements; 26 24 import org.qcg.broker.schemas.resreqs.TimePeriod; … … 31 29 import schedframe.scheduling.WorkloadUnitHandler; 32 30 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 33 import schedframe.scheduling.tasks.phases.ResourceConsumption;34 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;35 31 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 36 32 … … 75 71 private long workloadLogWaitTime; 76 72 77 private ResourceConsumptionProfile resourceConsumptionProfile;78 73 79 74 public Task(org.qcg.broker.schemas.resreqs.Task task){ … … 96 91 } 97 92 98 private void preparePhases() { 99 LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>(); 100 101 if(task.getExecution() == null || task.getExecution().getResourceConsumptionProfile() == null){ 102 ResourceConsumption resConsumption = null; 103 try { 104 resConsumption = new ResourceConsumption(this.length, getComputingResourceRequirements()); 105 } catch (NoSuchFieldException e) { 106 // TODO Auto-generated catch block 107 e.printStackTrace(); 108 } 109 resourceConsumptionList.add(resConsumption); 110 } 111 else{ 112 for(ResourceConsumptionType resConsumption: task.getExecution().getResourceConsumptionProfile().getResourceConsumption()){ 113 ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption); 114 resourceConsumptionList.add(resourceConsumption); 115 } 116 } 117 this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList); 118 119 // System.out.println("======"+task.getExecution().getExecutable().getApplication().getName()); 120 } 93 121 94 122 95 public DateTime getExecutionStartTime() throws NoSuchFieldException { … … 310 283 } 311 284 312 p rotectedComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{285 public ComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{ 313 286 314 287 Requirements req = this.task.getRequirements(); … … 450 423 public void setLength(long length) { 451 424 this.length = length; 452 preparePhases();453 425 } 454 426 … … 515 487 wuh.handleTask(this); 516 488 } 517 518 public ResourceConsumptionProfile getResourceConsumptionProfile(){ 519 return resourceConsumptionProfile; 520 } 521 489 522 490 public String getApplicationName(){ 523 491 try{ -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/TaskInterface.java
r1190 r1207 7 7 8 8 import schedframe.DescriptionContainer; 9 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;10 9 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 11 10 … … 111 110 public long getWorkloadLogWaitTime(); 112 111 113 public ResourceConsumptionProfile getResourceConsumptionProfile();112 //public ResourceConsumptionProfile getResourceConsumptionProfile(); 114 113 115 114 public String getApplicationName(); -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java
r1129 r1207 9 9 import org.qcg.broker.schemas.resreqs.ComputingResourceParameterType; 10 10 import org.qcg.broker.schemas.resreqs.PhaseBehaviourType; 11 import org.qcg.broker.schemas.resreqs.ReferenceType; 11 import org.qcg.broker.schemas.resreqs.StringParameterType; 12 12 13 import org.qcg.broker.schemas.resreqs.ResourceConsumptionType; 13 14 … … 36 37 if(resConsumptionType.getReferenceHardware() != null){ 37 38 for (int i = 0; i < resConsumptionType.getReferenceHardware().getReference().length; i++){ 38 ReferenceType rt = resConsumptionType.getReferenceHardware().getReference(i);39 referenceHardware.put( rt.getName(), rt.getContent());39 StringParameterType spt = resConsumptionType.getReferenceHardware().getReference(i); 40 referenceHardware.put(spt.getName(), spt.getContent()); 40 41 } 41 42 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java
r896 r1207 2 2 3 3 import java.util.LinkedList; 4 import java.util.List;5 4 6 5 public class ResourceConsumptionProfile { 7 6 8 7 protected LinkedList<ResourceConsumption> resourceConsumptionList; 9 protected int currentPhase; 8 protected long usefulWork; 9 private int currentPhase; 10 10 11 11 public ResourceConsumptionProfile() { … … 37 37 this.currentPhase = currentPhase; 38 38 } 39 40 public long getUsefulWork() { 41 return usefulWork; 42 } 43 44 public void setUsefulWork(long usefulWork) { 45 this.usefulWork = usefulWork; 46 } 39 47 } -
DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java
r802 r1207 52 52 public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER 53 53 + ".inputfolder"; 54 54 /** The input folder with application profiles */ 55 public static final String READ_SCENARIO_APPLCIATION_PROFILES = READ_SCENARIO_MODIFIER + ".applicationProfiles"; 55 56 /** The name of the workload file */ 56 57 public static final String READ_SCENARIO_WORKLOAD_FILE = READ_SCENARIO_MODIFIER … … 79 80 public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs"; 80 81 public static final String SIMULATION_STATISTICS = CREATESTATISTICS + ".simulation"; 81 82 public static final String COOLEMALL = "coolemall"; 83 public static final String COOLEMALL_RESOURCE = COOLEMALL + ".resdesc"; 84 82 83 public static final String PRESSURE_DROP = "pressuredrop"; 84 public static final String OUTLET_ROOM_AIR_TEMPERATURE = "outletroomairtemperature"; 85 public static final String INLET_ROOM_AIR_TEMPERATURE = "inletroomairtemperature"; 86 public static final String AMBIENT_AIR_TEMPERATURE = "ambientairtemperature"; 87 public static final String AIR_FLOW_VOLUME = "airflowvolume"; 88 public static final String ALPHA = "alpha"; 89 85 90 /** 86 91 * The main output folders base name … … 101 106 * Suffix for read scenario output folder 102 107 */ 103 public String statsOutputSubfolderNameRe rad = null;108 public String statsOutputSubfolderNameRead = null; 104 109 105 110 /* =============================================================================================== */ … … 137 142 */ 138 143 public String inputFolder = null; 144 145 public String appProfilesFolder = null; 139 146 140 147 public String inputTar = null; … … 184 191 public String [] resForUtilizationChart; 185 192 186 public String coolEmAllResdescFileName = null; 187 193 public static double pressureDrop; 194 public static double outletRoomAirTempeature; 195 public static double inletRoomAirTempeature; 196 public static double ambientAirTempeature; 197 public static double airFlowVolume; 198 public static double alpha 199 ; 188 200 /** 189 201 * An empty constructor. … … 255 267 256 268 try { 269 co.appProfilesFolder = getSeparatorTerminatedPath(bundle 270 .getString(READ_SCENARIO_APPLCIATION_PROFILES)); 271 } catch (MissingResourceException e) { 272 co.appProfilesFolder = null; 273 } 274 275 try { 257 276 co.inputWorkloadFileName = bundle 258 277 .getString(READ_SCENARIO_WORKLOAD_FILE); … … 346 365 try { 347 366 co.statsOutputSubfolderNameCreate = bundle.getString(STATS_OUTPUT_SUBFOLDER_NAME); 348 co.statsOutputSubfolderNameRe rad = co.statsOutputSubfolderNameCreate;367 co.statsOutputSubfolderNameRead = co.statsOutputSubfolderNameCreate; 349 368 } catch(MissingResourceException e){ 350 369 co.statsOutputSubfolderNameCreate = "stats_create"; 351 co.statsOutputSubfolderNameRe rad = "stats_read";370 co.statsOutputSubfolderNameRead = "stats_read"; 352 371 } 353 372 … … 370 389 co.numberOfSimulations = 1; 371 390 } 372 373 try { 374 co.coolEmAllResdescFileName = bundle.getString(COOLEMALL_RESOURCE); 375 System.setProperty("coolemall.resdesc", co.coolEmAllResdescFileName); 376 } catch(MissingResourceException e){ 377 co.coolEmAllResdescFileName = null; 378 } 391 392 try { 393 ConfigurationOptions.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue(); 394 } catch(MissingResourceException e){ 395 ConfigurationOptions.pressureDrop = 175.337; 396 } 397 398 try { 399 ConfigurationOptions.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 400 } catch(MissingResourceException e){ 401 ConfigurationOptions.outletRoomAirTempeature = 23; 402 } 403 404 try { 405 ConfigurationOptions.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 406 } catch(MissingResourceException e){ 407 ConfigurationOptions.inletRoomAirTempeature = 17; 408 } 409 410 try { 411 ConfigurationOptions.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue(); 412 } catch(MissingResourceException e){ 413 ConfigurationOptions.ambientAirTempeature = 17; 414 } 415 416 try { 417 ConfigurationOptions.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue(); 418 } catch(MissingResourceException e){ 419 ConfigurationOptions.airFlowVolume = 0.304; 420 } 421 422 try { 423 ConfigurationOptions.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue(); 424 } catch(MissingResourceException e){ 425 ConfigurationOptions.alpha = 0.02; 426 } 427 379 428 return co; 380 429 } -
DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java
r1160 r1207 22 22 import org.apache.commons.logging.LogFactory; 23 23 import org.joda.time.DateTime; 24 import org.qcg.broker.schemas.jobdesc.ParentType;25 import org.qcg.broker.schemas.jobdesc.Workflow;26 import org.qcg.broker.schemas.jobdesc.types.TaskStatesName;27 24 28 25 import qcg.shared.constants.BrokerConstants; … … 244 241 245 242 } 246 System.out.println("finished sending jobs");247 243 } 248 244 -
DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java
r1142 r1207 14 14 import javax.swing.filechooser.FileFilter; 15 15 16 import org.apache.commons.io.FilenameUtils; 16 17 import org.apache.commons.logging.Log; 17 18 import org.apache.commons.logging.LogFactory; … … 21 22 22 23 import schedframe.Initializable; 23 import schedframe. ResourceController;24 import schedframe.SimulatedEnvironment; 24 25 import simulator.reader.ResourceReader; 25 26 import simulator.stats.AccumulatedStatistics; … … 51 52 * The name of the simulator application 52 53 */ 53 public static final String SIMULATOR_NAME = "Data Center Workload Simulator"; 54 public static final String SIMULATOR_NAME = "Data Center Workload and Resource Management Simulator"; 55 56 /** 57 * The simulation mode 58 */ 59 public static String MODE = "Standard"; 54 60 55 61 /** … … 183 189 } 184 190 185 if (log.isInfoEnabled()) 191 if (log.isInfoEnabled()){ 186 192 log.info("Done :: " + SIMULATOR_NAME + " has finished " 187 193 + noOfSimulations + " simulation runs ::"); 194 log.info("Simulation finished with status: 0"); 195 } 188 196 189 197 System.out.flush(); … … 259 267 260 268 ResourceReader resourceReader = new ResourceReader( 261 options );262 ResourceControllerrc = resourceReader.read();269 options.resdescFileName); 270 SimulatedEnvironment rc = resourceReader.read(); 263 271 eventManager = new EventManager("eventManager", rc); 264 272 … … 268 276 rc.setInitList(null); 269 277 270 DCWormsUsers wl= new DCWormsUsers("Users",278 DCWormsUsers users = new DCWormsUsers("Users", 271 279 rc.getScheduler().get_name(), workload); 272 280 281 System.out.println("Starting simulation..."); 282 273 283 GridSimWrapper.startSimulation(); 274 284 long stopSimulation = System.currentTimeMillis(); 275 285 286 System.out.println("Simulation finished"); 287 276 288 DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 277 options, wl, statsOutputPath, rc);289 options, users, statsOutputPath, rc); 278 290 accumulatedStatistics.add(stats); 279 291 if (log.isInfoEnabled()) … … 301 313 String wlFileName = options.inputWorkloadFileName; 302 314 315 String appProfilesFolder = options.appProfilesFolder; 303 316 if (options.inputFolder != null) { 304 317 File f = null; … … 318 331 swfReader = AbstractWAReader.getInstace(wlFileName); 319 332 320 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader );333 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader, appProfilesFolder); 321 334 workload.load(); 322 335 … … 346 359 prefix = options.inputFolder; 347 360 } else if (options.inputWorkloadFileName != null) { 348 prefix = new File(options.inputWorkloadFileName).getParent();361 prefix = FilenameUtils.getFullPath(new File(options.inputWorkloadFileName).getAbsolutePath()); 349 362 } else { 350 363 prefix = System.getProperty("user.dir"); 351 364 } 352 statsOutputPath = prefix + File.separator 353 + options.statsOutputSubfolderNameRerad; 365 //statsOutputPath = prefix + File.separator 366 // + options.statsOutputSubfolderNameRead; 367 statsOutputPath = options.statsOutputSubfolderNameRead; 354 368 } 355 369 statsOutputPath += File.separator; -
DCWoRMS/branches/coolemall/src/simulator/reader/EnvironmentWrapper.java
r477 r1207 18 18 public class EnvironmentWrapper { 19 19 20 Environment environment;20 private Environment environment; 21 21 22 22 public void wrap(Environment environment) { … … 53 53 public ComputingResource[] getComputingResources() throws UnknownParameter{ 54 54 55 ArrayList<ComputingResource>tab = null;56 57 55 if(environment == null) 58 56 throw new UnknownParameter("Environment parameters are not defined."); … … 61 59 return null; 62 60 63 tab= new ArrayList<ComputingResource>();61 ArrayList<ComputingResource> computingResources = new ArrayList<ComputingResource>(); 64 62 65 63 for(int i = 0; i < resources.getComputingResourceCount(); i++){ 66 64 ComputingResource compRes = resources.getComputingResource(i); 67 tab.add(compRes);65 computingResources.add(compRes); 68 66 } 69 if( tab.size() == 0)67 if(computingResources.size() == 0) 70 68 return null; 71 69 else 72 return tab.toArray(new ComputingResource[0]);70 return computingResources.toArray(new ComputingResource[0]); 73 71 } 74 72 -
DCWoRMS/branches/coolemall/src/simulator/reader/ResourceReader.java
r1042 r1207 1 1 package simulator.reader; 2 3 import gridsim.ResourceCalendar;4 2 5 3 import java.io.File; … … 19 17 import java.util.Set; 20 18 19 import org.apache.commons.io.FilenameUtils; 21 20 import org.exolab.castor.xml.MarshalException; 22 21 import org.exolab.castor.xml.ValidationException; … … 26 25 import schedframe.Parameter; 27 26 import schedframe.Parameters; 28 import schedframe. ResourceController;27 import schedframe.SimulatedEnvironment; 29 28 import schedframe.exceptions.ResourceException; 29 import schedframe.resources.CoolEmAllResourceFactory; 30 30 import schedframe.resources.Resource; 31 31 import schedframe.resources.StandardResourceType; 32 32 import schedframe.resources.computing.ComputingResource; 33 33 import schedframe.resources.computing.ResourceFactory; 34 import schedframe.resources.computing. description.AbstractResourceDescription;34 import schedframe.resources.computing.StandardResourceFactory; 35 35 import schedframe.resources.computing.description.ComputingResourceDescription; 36 import schedframe.resources.computing.description.ResourceDescription; 36 37 import schedframe.resources.units.ResourceUnit; 37 38 import schedframe.resources.units.ResourceUnitName; … … 45 46 import schemas.ManagedComputingResources; 46 47 import schemas.StringValueWithUnit; 47 import simulator. ConfigurationOptions;48 import simulator.DataCenterWorkloadSimulator; 48 49 import simulator.utils.InstanceFactory; 50 import test.DEBBTranslator.src.PLMXMLTranslator; 49 51 50 52 public class ResourceReader { 51 53 52 54 private static String COOLEMALL_RESDESC_PREFIX = "DCWORMS"; 53 protected String resDescFileName; 54 55 protected ResourceCalendar resourceCalendar; 56 protected List<Initializable> toInit = new ArrayList<Initializable>(); 57 55 private String resDescFileName; 56 private ResourceFactory resFactory; 57 58 58 private ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 59 private String globalSchedulingPluginName;60 59 61 60 private Set<String> compResLayers; 62 63 public ResourceReader(ConfigurationOptions options) throws IOException { 64 65 resDescFileName = options.resdescFileName; 66 globalSchedulingPluginName = "example.globalplugin.GridFCFSRoundRobinPlugin"; 67 prepareCalendar(); 68 compResLayers = new LinkedHashSet<String>(); 69 } 70 71 public ResourceController read() throws MarshalException, ValidationException, FileNotFoundException, Exception, 61 private List<Initializable> toInit; 62 63 public ResourceReader(String resdescFileName) throws IOException { 64 65 this.resDescFileName = resdescFileName; 66 this.resFactory = new StandardResourceFactory(); 67 this.compResLayers = new LinkedHashSet<String>(); 68 this.toInit = new ArrayList<Initializable>(); 69 } 70 71 public SimulatedEnvironment read() throws MarshalException, ValidationException, FileNotFoundException, Exception, 72 72 UnknownParameter { 73 73 74 74 File file = new File(resDescFileName); 75 76 Environment env ;75 76 Environment env = null; 77 77 try{ 78 78 env = Environment.unmarshal(new FileReader(file)); 79 79 80 } catch (Exception e){ 80 File dcwormsFile = new File(file.getParent() + "/" + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 81 env = Environment.unmarshal(new FileReader(dcwormsFile)); 82 } 83 81 //e.printStackTrace(); 82 try{ 83 File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 84 env = Environment.unmarshal(new FileReader(dcwormsFile)); 85 } catch (Exception e2){ 86 PLMXMLTranslator plmxmlTranslator = new PLMXMLTranslator(); 87 String trasnlatedFileName = plmxmlTranslator.translate(new String[]{file.getAbsolutePath()}); 88 File dcwormsFile = new File(trasnlatedFileName); 89 //File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 90 91 env = Environment.unmarshal(new FileReader(dcwormsFile)); 92 } 93 } 94 95 if(env.getResources().getMode().equals("CoolEmAll")){ 96 DataCenterWorkloadSimulator.MODE = "CoolEmAll"; 97 resFactory = new CoolEmAllResourceFactory(); 98 } 84 99 System.out.println("started creating environment description"); 85 100 List<ComputingResourceDescription> mainCompResDescList = createEnvironmentDescription(env); … … 94 109 System.out.println("finished creating schedulers"); 95 110 96 ResourceController rc = new ResourceController(mainScheduler, computingResources);111 SimulatedEnvironment simEnv = new SimulatedEnvironment(mainScheduler, computingResources); 97 112 Collections.sort(toInit, new ResourceTypeComparator(new ArrayList<String>(compResLayers))); 98 rc.setInitList(toInit);99 rc.setCompResLayers(compResLayers);100 return rc;113 simEnv.setInitList(toInit); 114 simEnv.setCompResLayers(compResLayers); 115 return simEnv; 101 116 } 102 117 … … 181 196 182 197 for(ComputingResourceDescription mainExecResDes : mainCompResDesList){ 183 ComputingResource mainResource = ResourceFactory.createResource(mainExecResDes);198 ComputingResource mainResource = resFactory.createComputingResource(mainExecResDes); 184 199 toExamine.push(mainExecResDes); 185 200 resStructure.push(mainResource); … … 192 207 toInit.add(parentResource); 193 208 compResLayers.add(parentResource.getType().getName()); 194 List< AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren();209 List<ResourceDescription> childrenResDesc = parentResDesc.getChildren(); 195 210 if (childrenResDesc == null){ 196 211 continue; … … 200 215 ComputingResourceDescription compResDesc = (ComputingResourceDescription) childrenResDesc.get(i); 201 216 toExamine.push(compResDesc); 202 ComputingResource resource = ResourceFactory.createResource(compResDesc);217 ComputingResource resource = resFactory.createComputingResource(compResDesc); 203 218 parentResource.addChild(resource); 204 219 resStructure.push(resource); … … 254 269 } 255 270 else{ 256 SchedulingPlugin schedulingPlugin = (SchedulingPlugin) InstanceFactory.createInstance(globalSchedulingPluginName, 257 SchedulingPlugin.class); 258 TaskQueueList queues = new TaskQueueList(1); 259 TaskQueue queue = new TaskQueue(false); 260 queues.add(queue); 261 ManagedResources managedResources = new ManagedResources(mainCompResourceList, new HashMap<ResourceUnitName, List<ResourceUnit>>()); 262 mainScheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin , execTimeEstimationPlugin, queues, managedResources); 263 264 for(Scheduler lr: mainSchedulers){ 265 mainScheduler.addChild(lr); 266 } 267 //necessary if children list isn't initialized in Scheduler 268 //mainScheduler.init(); 271 throw new Exception("Worng schedule definition"); 269 272 } 270 273 return mainScheduler; … … 332 335 //TODO - refactor (create scheduler in 1 line) 333 336 if(schedulerDef.getClazz().equals("GridBroker")){ 334 scheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources);337 scheduler = resFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources); 335 338 } else { 336 scheduler = ResourceFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin, queues, managedResources);339 scheduler = resFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin, queues, managedResources); 337 340 } 338 341 return scheduler; … … 374 377 ComputingResource computingResource; 375 378 try { 376 if( resourceName.equals(mainCompRes.getName()))379 if(mainCompRes.getFullName().contains(resourceName)) 377 380 computingResource = mainCompRes; 378 381 else … … 421 424 return resourceUnits; 422 425 } 423 424 private void prepareCalendar() { 425 long seed = 11L * 13L * 17L * 19L * 23L + 1L; 426 double timeZone = 0.0; 427 double peakLoad = 0.0; // the resource load during peak hour 428 double offPeakLoad = 0.0; // the resource load during off-peak hr 429 double holidayLoad = 0.0; // the resource load during holiday 430 431 // incorporates weekends so the grid resource is on 7 days a week 432 LinkedList<Integer> Weekends = new LinkedList<Integer>(); 433 Weekends.add(java.util.Calendar.SATURDAY); 434 Weekends.add(java.util.Calendar.SUNDAY); 435 436 // incorporates holidays. However, no holidays are set in this example 437 LinkedList<Integer> Holidays = new LinkedList<Integer>(); 438 resourceCalendar = new ResourceCalendar(timeZone, peakLoad, offPeakLoad, holidayLoad, Weekends, Holidays, 439 seed); 440 } 426 441 427 442 428 class ResourceTypeComparator implements Comparator<Initializable>{ -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
r1199 r1207 7 7 import java.io.IOException; 8 8 import java.io.PrintStream; 9 import java.text.DecimalFormat; 9 10 import java.text.NumberFormat; 10 11 import java.util.ArrayList; … … 14 15 import java.util.Date; 15 16 import java.util.HashMap; 17 import java.util.HashSet; 16 18 import java.util.List; 17 19 import java.util.Map; 20 import java.util.Set; 18 21 import java.util.SortedMap; 19 22 import java.util.TreeMap; … … 54 57 55 58 import schedframe.ExecutablesList; 56 import schedframe. ResourceController;59 import schedframe.SimulatedEnvironment; 57 60 import schedframe.exceptions.ResourceException; 58 61 import schedframe.resources.ResourceType; … … 66 69 import schedframe.resources.computing.profiles.energy.power.PowerUsage; 67 70 import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue; 68 import schedframe.resources.units.PEUnit; 71 import schedframe.resources.devices.Device; 72 import schedframe.resources.devices.PhysicalResource; 69 73 import schedframe.resources.units.ProcessingElements; 70 74 import schedframe.resources.units.ResourceUnit; … … 82 86 import simulator.GenericUser; 83 87 import simulator.stats.GSSAccumulator; 88 import simulator.stats.MetricsCalculator; 84 89 import simulator.stats.SimulationStatistics; 85 90 import simulator.stats.implementation.out.AbstractStringSerializer; 86 91 import simulator.stats.implementation.out.CoolEmAllStringSerializer; 92 import simulator.stats.implementation.out.StringSerializer; 87 93 import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; 88 94 import csiro.mit.utils.jfreechart.timetablechart.data.Timetable; … … 93 99 import dcworms.schedframe.scheduling.Executable; 94 100 import eduni.simjava.Sim_stat; 101 import example.energy.coolemall.CoolEmAllTestbedMeasurements; 95 102 96 103 public class DCWormsStatistics implements SimulationStatistics { … … 111 118 protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt"; 112 119 protected static final String TEMPERATURE_STATISTICS_OUTPUT_FILE_NAME = "Temperature.txt"; 113 120 protected static final String USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME = "UsefulWork.txt"; 121 protected static final String DEVICE_STATISTICS_OUTPUT_FILE_NAME = "Devices.txt"; 122 protected static final String NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME = "NodesAvailability.txt"; 123 protected static final String METRICS_STATISTICS_OUTPUT_FILE_NAME = "Metrics.txt"; 124 protected static final String RESOURCE_HISTORY_OUTPUT_FILE_NAME = "ResourceHistyory.txt"; 125 114 126 protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; 115 127 protected static final String STATS_FILE_NAME_PREFIX = "Stats_"; … … 127 139 128 140 protected GenericUser users; 129 protected ResourceControllerresourceController;141 protected SimulatedEnvironment resourceController; 130 142 protected boolean generateDiagrams = true; 131 143 protected AbstractStringSerializer serializer; … … 154 166 protected TaskSeriesCollection ganttDiagramTaskSeriesCollection; 155 167 protected TaskSeriesCollection ganttDiagramWaitingTimeSeriesCollection; 156 protected Map<String, List<String>> task_processorsMap;168 protected Map<String, Set<ComputingResource>> task_processorsMap; 157 169 158 170 protected JobRegistry jr; 159 171 protected MetricsCalculator metCalc; 160 172 161 173 public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 162 String outputFolderName, ResourceControllerresourceController) {174 String outputFolderName, SimulatedEnvironment resourceController) { 163 175 this.simulationIdentifier = simulationIdentifier; 164 176 this.configuration = co; … … 167 179 this.outputFolderName = outputFolderName; 168 180 169 this.serializer = new CoolEmAllStringSerializer(); 181 this.serializer = new StringSerializer(); 182 183 if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){ 184 this.serializer = new CoolEmAllStringSerializer(); 185 } 170 186 this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 171 187 … … 173 189 this.jr = new JobRegistryImpl(""); 174 190 init(); 191 metCalc = new MetricsCalculator(); 175 192 } 176 193 … … 183 200 this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 184 201 202 metCalc.setStartTime(startSimulationTime); 203 metCalc.setEndTime(endSimulationTime); 204 185 205 long s = 0; 186 206 long e = 0; … … 211 231 212 232 private void init() { 213 task_processorsMap = new HashMap<String, List<String>>();233 task_processorsMap = new HashMap<String, Set<ComputingResource>>(); 214 234 accStats = new GSSAccumulatorsStats(); 215 235 statsData = new HashMap<String, GSSAccumulator>(); … … 229 249 if (simulationStatsFile != null) { 230 250 Object txt = accStats.serialize(this.serializer); 251 252 DecimalFormat df = new DecimalFormat(); 253 df.setMaximumFractionDigits(3); 254 df.setGroupingUsed(false); 255 256 /*log.info("#STATS " + "Performance statistics"); 257 log.info("#STATS " + "Makespan: " + accStats.makespan.getMean() + " [s]"); 258 log.info("#STATS " + "Task completion time - " + "min: " + accStats.meanTaskCompletionTime.getMin() + "; max: " + accStats.meanTaskCompletionTime.getMax() + " [s]"); 259 log.info("#STATS " + "Mean task execution time: " + accStats.meanTaskExecutionTime.getMean() + " [s]"); 260 log.info("#STATS " + "System load: " + accStats.meanTotalLoad.getMean() * 100 + " [%]");*/ 261 262 System.out.println("#STATS " + "===== Performance statistics ====="); 263 System.out.println("#STATS " + "Makespan: " + df.format(accStats.makespan.getMean()) + " [s]"); 264 System.out.println("#STATS " + "Task completion time - " + "min: " + df.format(accStats.meanTaskCompletionTime.getMin()) + " [s]" + "; max: " + df.format(accStats.meanTaskCompletionTime.getMax()) + " [s]"); 265 System.out.println("#STATS " + "Mean task execution time: " + df.format(accStats.meanTaskExecutionTime.getMean()) + " [s]"); 266 System.out.println("#STATS " + "System load: " + df.format(accStats.meanTotalLoad.getMean() * 100) + " [%]"); 267 231 268 simulationStatsFile.println(txt); 232 269 } … … 238 275 239 276 /************* RESOURCE STATISTICS SECTION **************/ 240 p rivatevoid gatherResourceStatistics() {277 public void gatherResourceStatistics() { 241 278 242 279 HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 243 280 244 for(String resource Name: resourceController.getComputingResourceLayers()){281 for(String resourceTypeName: resourceController.getComputingResourceLayers()){ 245 282 List<Stats> cStats = new ArrayList<Stats>(); 246 283 cStats.add(Stats.textLoad); 247 if(ArrayUtils.contains(configuration.resForUtilizationChart, resource Name))284 if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceTypeName)) 248 285 cStats.add(Stats.chartLoad); 249 286 cStats.add(Stats.textEnergy); 250 if(ArrayUtils.contains(configuration.resForEnergyChart, resource Name))287 if(ArrayUtils.contains(configuration.resForEnergyChart, resourceTypeName)) 251 288 cStats.add(Stats.chartEnergy); 252 289 cStats.add(Stats.textAirFlow); 253 if(ArrayUtils.contains(configuration.resForAirFlowChart, resource Name))290 if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceTypeName)) 254 291 cStats.add(Stats.chartAirFlow); 255 292 cStats.add(Stats.textTemperature); 256 if(ArrayUtils.contains(configuration.resForTemperatureChart, resource Name))293 if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceTypeName)) 257 294 cStats.add(Stats.chartTemperature); 258 type_stats.put(resourceName, cStats); 295 type_stats.put(resourceTypeName, cStats); 296 259 297 } 260 298 … … 269 307 ganttDiagramTimetable = new Timetable(new FixedMillisecond( 270 308 startSimulationTime), new FixedMillisecond(endSimulationTime)); 309 271 310 272 311 PrintStream resourceLoadStatsFile = null; … … 310 349 } 311 350 351 PrintStream deviceStatsFile = null; 352 try { 353 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 354 + simulationIdentifier + "_" 355 + DEVICE_STATISTICS_OUTPUT_FILE_NAME); 356 deviceStatsFile = new PrintStream(new FileOutputStream(file)); 357 } catch (IOException e) { 358 deviceStatsFile = null; 359 } 360 361 PrintStream nodesAvailabilityStatsFile = null; 362 try { 363 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 364 + simulationIdentifier + "_" 365 + NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME); 366 nodesAvailabilityStatsFile = new PrintStream(new FileOutputStream(file)); 367 } catch (IOException e) { 368 nodesAvailabilityStatsFile = null; 369 } 370 371 PrintStream metricsStatsFile = null; 372 try { 373 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 374 + simulationIdentifier + "_" 375 + METRICS_STATISTICS_OUTPUT_FILE_NAME); 376 metricsStatsFile = new PrintStream(new FileOutputStream(file)); 377 } catch (IOException e) { 378 metricsStatsFile = null; 379 } 380 381 PrintStream usefulWorkStatsFile = null; 382 try { 383 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 384 + simulationIdentifier + "_" 385 + USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME); 386 usefulWorkStatsFile = new PrintStream(new FileOutputStream(file)); 387 } catch (IOException e) { 388 usefulWorkStatsFile = null; 389 } 390 312 391 basicResStats = gatherPEStats(jr.getTasks()); 313 392 peStatsPostProcessing(basicResStats); … … 318 397 } 319 398 320 for(String resourceName: resourceController.getComputingResourceLayers()){ 321 List<ComputingResource> resources = null; 322 323 resources = new ArrayList<ComputingResource>(); 399 List<ComputingResource> compResources = null; 400 for(String resourceTypeName: resourceController.getComputingResourceLayers()){ 401 GSSAccumulator resourceEnergyAccumulator = new GSSAccumulator(); 402 GSSAccumulator maxResourceEnergyAccumulator = new GSSAccumulator(); 403 GSSAccumulator calculationsEnergyAccumulator = new GSSAccumulator(); 404 compResources = new ArrayList<ComputingResource>(); 324 405 for(ComputingResource compRes: resourceController.getComputingResources() ){ 325 resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName))); 326 } 327 if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName)) 328 resources.addAll(resourceController.getComputingResources()); 329 330 if(type_stats.containsKey(resourceName)){ 331 for(ComputingResource resource: resources){ 406 compResources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceTypeName))); 407 } 408 if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceTypeName)) 409 compResources.addAll(resourceController.getComputingResources()); 410 if(type_stats.containsKey(resourceTypeName)){ 411 412 413 for(ComputingResource compResource: compResources){ 332 414 ResourceUsageStats resourceUsage = null; 333 415 ResourcePowerStats energyUsage = null; 334 416 ResourceAirFlowStats airFlow = null; 335 417 ResourceTemperatureStats temperature = null; 336 if(type_stats.get(resourceName).contains(Stats.textLoad)){ 337 resourceUsage = gatherResourceLoadStats(resource, basicResStats); 418 ResourceUsefulWorkStats usefulWork = null; 419 if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){ 420 resourceUsage = gatherResourceLoadStats(compResource, basicResStats); 338 421 resourceUsage.setMeanValue(calculateMeanValue(resourceUsage)); 339 422 if (resourceLoadStatsFile != null) { … … 341 424 resourceLoadStatsFile.print(txt); 342 425 } 343 } 344 if(type_stats.get(resourceName).contains(Stats.chartLoad)){ 426 427 } 428 if(type_stats.get(resourceTypeName).contains(Stats.chartLoad)){ 345 429 if (configuration.creatediagrams_resutilization) { 346 430 createResourceLoadDiagram(resourceUsage); 347 431 } 348 432 } 349 if(type_stats.get(resource Name).contains(Stats.textEnergy)){350 energyUsage = gatherResourcePowerConsumptionStats( resource);433 if(type_stats.get(resourceTypeName).contains(Stats.textEnergy)){ 434 energyUsage = gatherResourcePowerConsumptionStats(compResource); 351 435 energyUsage.setMeanValue(calculateMeanValue(energyUsage)); 352 436 energyUsage.setSumValue(energyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 353 354 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 355 if(resourceController.getComputingResources().contains(resource)) { 437 resourceEnergyAccumulator.add(energyUsage.getSumValue()); 438 maxResourceEnergyAccumulator.add(calculateMaxValue(energyUsage)); 439 double calulcationsEnergy = 0; 440 try { 441 /*boolean doCalc = false; 442 double prevTimestamp = 0; 443 for(Long key: resourceUsage.getHistory().keySet()){ 444 if(doCalc){ 445 System.out.println(energyUsage.getHistory().get(key)); 446 calulcationsEnergy = calulcationsEnergy + energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600 * MILLI_SEC); 447 doCalc = false; 448 } 449 if(resourceUsage.getHistory().get(key)>0){ 450 prevTimestamp = key; 451 doCalc = true; 452 } 453 }*/ 454 boolean doCalc = false; 455 long prevTimestamp = 0; 456 for(Long key: energyUsage.getHistory().keySet()){ 457 if(doCalc){ 458 double load = 0; 459 if(resourceUsage.getHistory().get(prevTimestamp)!= null){ 460 load = resourceUsage.getHistory().get(prevTimestamp); 461 } 462 calulcationsEnergy = calulcationsEnergy + load * energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600.0 * MILLI_SEC); 463 doCalc = false; 464 } 465 if(energyUsage.getHistory().get(key) > compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION){ 466 467 prevTimestamp = key; 468 doCalc = true; 469 } 470 } 471 //calulcationsEnergy = energyUsage.getSumValue() - 472 // ((1 - resourceUsage.getMeanValue()) * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)) * 473 // (compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION); 474 //System.out.println(compResource.getFullName() + ";" + resourceUsage.getMeanValue() +":"+ calulcationsEnergy + ":" + energyUsage.getSumValue()); 475 calculationsEnergyAccumulator.add(calulcationsEnergy); 476 } catch (Exception e) { 477 e.printStackTrace(); 478 } 479 EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 480 if(resourceController.getComputingResources().contains(compResource)) { 356 481 if( een != null && een.getPowerProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 357 482 accStats.meanEnergyUsage.add(energyUsage.getSumValue()); … … 359 484 360 485 } else if( een != null && een.getPowerProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 361 ComputingResource parent = resource.getParent();486 ComputingResource parent = compResource.getParent(); 362 487 boolean top = true; 363 488 while(parent != null){ … … 377 502 energyStatsFile.print(txt); 378 503 } 379 } 380 if(type_stats.get(resourceName).contains(Stats.chartEnergy)){ 381 504 505 for(Device device: compResource.getResourceCharacteristic().getDevices()){ 506 GSSAccumulator devAccumulator = new GSSAccumulator(); 507 ResourcePowerStats deviceEnergyUsage = gatherResourcePowerConsumptionStats(device); 508 deviceEnergyUsage.setMeanValue(calculateMeanValue(deviceEnergyUsage)); 509 deviceEnergyUsage.setSumValue(deviceEnergyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 510 devAccumulator.add(deviceEnergyUsage.getSumValue()); 511 metCalc.addMetricsData(device.getType().getName(), devAccumulator); 512 if (deviceStatsFile != null) { 513 Object txt = deviceEnergyUsage.serialize(serializer); 514 deviceStatsFile.print(txt); 515 } 516 517 if(ArrayUtils.contains(configuration.resForEnergyChart, device.getType().getName())){ 518 if (configuration.creatediagrams_respowerusage) { 519 createResourceEnergyDiagramData(deviceEnergyUsage); 520 } 521 } 522 } 523 } 524 if(type_stats.get(resourceTypeName).contains(Stats.chartEnergy)){ 382 525 if (configuration.creatediagrams_respowerusage) { 383 526 createResourceEnergyDiagramData(energyUsage); … … 385 528 } 386 529 387 if(type_stats.get(resource Name).contains(Stats.textAirFlow)){388 airFlow = gatherResourceAirFlowStats( resource);530 if(type_stats.get(resourceTypeName).contains(Stats.textAirFlow)){ 531 airFlow = gatherResourceAirFlowStats(compResource); 389 532 airFlow.setMeanValue(calculateMeanValue(airFlow)); 390 533 airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC)); 391 534 392 EnergyExtension een = (EnergyExtension)( resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));393 if(resourceController.getComputingResources().contains( resource)) {535 EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 536 if(resourceController.getComputingResources().contains(compResource)) { 394 537 if( een != null && een.getAirFlowProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 395 538 accStats.meanAirFlow.add(airFlow.getMeanValue()); … … 397 540 398 541 } else if( een != null && een.getAirFlowProfile() != null ){ 399 ComputingResource parent = resource.getParent();542 ComputingResource parent = compResource.getParent(); 400 543 een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 401 544 boolean top = true; … … 415 558 airFlowStatsFile.print(txt); 416 559 } 417 } 418 if(type_stats.get(resourceName).contains(Stats.chartAirFlow)){ 560 561 for(Device device: compResource.getResourceCharacteristic().getDevices()){ 562 ResourceAirFlowStats deviceAirFlow = gatherResourceAirFlowStats(device); 563 deviceAirFlow.setMeanValue(calculateMeanValue(deviceAirFlow)); 564 deviceAirFlow.setSumValue(deviceAirFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC)); 565 566 if (deviceStatsFile != null) { 567 Object txt = deviceAirFlow.serialize(serializer); 568 deviceStatsFile.print(txt); 569 } 570 571 if(ArrayUtils.contains(configuration.resForAirFlowChart, device.getType().getName())){ 572 if (configuration.creatediagrams_resairflow) { 573 createResourceAirFlowDiagramData(deviceAirFlow); 574 } 575 } 576 } 577 } 578 if(type_stats.get(resourceTypeName).contains(Stats.chartAirFlow)){ 419 579 420 580 if (configuration.creatediagrams_resairflow) { … … 423 583 } 424 584 425 if(type_stats.get(resource Name).contains(Stats.textTemperature)){426 temperature = gatherResourceTemperatureStats( resource);585 if(type_stats.get(resourceTypeName).contains(Stats.textTemperature)){ 586 temperature = gatherResourceTemperatureStats(compResource); 427 587 temperature.setMeanValue(calculateMeanValue(temperature)); 428 588 temperature.setSumValue(temperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 429 589 430 EnergyExtension een = (EnergyExtension)( resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));431 if(resourceController.getComputingResources().contains( resource)) {590 EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 591 if(resourceController.getComputingResources().contains(compResource)) { 432 592 if( een != null && een.getThermalProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 433 593 accStats.meanTemperature.add(temperature.getMeanValue()); … … 435 595 436 596 } else if( een != null && een.getThermalProfile() != null ){ 437 ComputingResource parent = resource.getParent();597 ComputingResource parent = compResource.getParent(); 438 598 een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 439 599 boolean top = true; … … 453 613 temperatureStatsFile.print(txt); 454 614 } 455 } 456 if(type_stats.get(resourceName).contains(Stats.chartTemperature)){ 457 615 616 for(Device device: compResource.getResourceCharacteristic().getDevices()){ 617 ResourceTemperatureStats deviceTemperature = gatherResourceTemperatureStats(device); 618 deviceTemperature.setMeanValue(calculateMeanValue(deviceTemperature)); 619 deviceTemperature.setSumValue(deviceTemperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 620 621 if (deviceStatsFile != null) { 622 Object txt = deviceTemperature.serialize(serializer); 623 deviceStatsFile.print(txt); 624 } 625 626 if(ArrayUtils.contains(configuration.resForTemperatureChart, device.getType().getName())){ 627 if (configuration.creatediagrams_restemperature) { 628 createResourceTemperatureDiagramData(deviceTemperature); 629 } 630 } 631 } 632 } 633 if(type_stats.get(resourceTypeName).contains(Stats.chartTemperature)){ 458 634 if (configuration.creatediagrams_restemperature) { 459 635 createResourceTemperatureDiagramData(temperature); 460 636 } 461 637 } 638 639 if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){ 640 usefulWork = gatherResourceUsefulWorkStats(compResource); 641 if (usefulWorkStatsFile != null) { 642 Object txt = usefulWork.serialize(serializer); 643 usefulWorkStatsFile.print(txt); 644 } 645 } 646 647 648 if (nodesAvailabilityStatsFile != null) { 649 ResourceAvailabilityStats ras = new ResourceAvailabilityStats(compResource.getFullName(), compResource.getType(), "availableNodes", compResource.getChildren().size(), endSimulationTime); 650 Object txt = ras.serialize(serializer); 651 nodesAvailabilityStatsFile.print(txt); 652 ras = gatherResourceAvailabilityStats(compResource); 653 txt = ras.serialize(serializer); 654 nodesAvailabilityStatsFile.print(txt); 655 } 656 462 657 } 463 } 464 } 465 658 metCalc.addMetricsData(resourceTypeName + "_CALC", calculationsEnergyAccumulator); 659 metCalc.addMetricsData(resourceTypeName, resourceEnergyAccumulator); 660 metCalc.addMetricsData(resourceTypeName + "_MAX", maxResourceEnergyAccumulator); 661 } 662 } 663 664 665 if (metricsStatsFile != null) { 666 //log.info("#STATS " + "Metrics"); 667 System.out.println("#STATS " + "===== Metrics ====="); 668 for(MetricsStats metric: metCalc.calulateMetrics(endSimulationTime)){ 669 Object txt = metric.serialize(serializer); 670 //log.info("#STATS " + metric.getResourceName() + " " + metric.getMetricName() + ": " + metric.getValue()); 671 DecimalFormat df = new DecimalFormat(); 672 df.setMaximumFractionDigits(3); 673 df.setGroupingUsed(false); 674 System.out.println("#STATS " + metric.getMetricName().replaceAll("_", " ") + ": " + df.format(metric.getValue()) + " [" + metric.getUnit() + "]"); 675 metricsStatsFile.println(txt); 676 } 677 } 466 678 saveResourceUsageDiagrams(); 467 679 createAccumulatedResourceSimulationStatistic(); … … 479 691 resourceLoadStatsFile.close(); 480 692 } 693 694 if (usefulWorkStatsFile != null) { 695 usefulWorkStatsFile.close(); 696 } 697 if (deviceStatsFile != null) { 698 deviceStatsFile.close(); 699 } 700 701 if (nodesAvailabilityStatsFile != null) { 702 nodesAvailabilityStatsFile.close(); 703 } 704 705 if (metricsStatsFile != null) { 706 metricsStatsFile.close(); 707 } 708 481 709 } 482 710 … … 500 728 } 501 729 for(ComputingResource resource: resources){ 502 if(!basicResStats.containsKey(resource.get Name())){503 basicResStats.put(resource.get Name(), new ArrayList<ResStat>());730 if(!basicResStats.containsKey(resource.getFullName())){ 731 basicResStats.put(resource.getFullName(), new ArrayList<ResStat>()); 504 732 } 505 733 } … … 509 737 510 738 Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 511 512 739 for (ExecTask execTask:executables) { 513 740 Executable exec = (Executable) execTask; … … 522 749 ProcessingElements pes = (ProcessingElements) resUnit; 523 750 for(ComputingResource pe: pes){ 524 String peName = pe.get Name();751 String peName = pe.getFullName(); 525 752 long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 526 753 long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; … … 541 768 String uniqueTaskID = getUniqueTaskId(execTask); 542 769 543 List<String> peNames = task_processorsMap.get(uniqueTaskID);770 Set<ComputingResource> peNames = task_processorsMap.get(uniqueTaskID); 544 771 if (peNames == null) { 545 peNames = new ArrayList<String>();546 peNames.add(pe Name);772 peNames = new HashSet<ComputingResource>(); 773 peNames.add(pe); 547 774 task_processorsMap.put(uniqueTaskID, peNames); 548 775 } else { 549 peNames.add(peName); 550 } 776 peNames.add(pe); 777 } 778 779 try{ 780 double usefulWork = execTask.getResourceConsumptionProfile().getUsefulWork(); 781 //double usefulWork = gatherUsefulWorkStats(pe).getValue(); 782 GSSAccumulator uwAcc; 783 if(metCalc.getMetricsData().containsKey(pe.getFullName())){ 784 uwAcc = metCalc.getMetricsData().get(pe.getFullName()).get(0); 785 uwAcc.add(usefulWork); 786 } else { 787 uwAcc = new GSSAccumulator(); 788 uwAcc.add(usefulWork); 789 metCalc.addMetricsData(pe.getFullName(), uwAcc); 790 } 791 } catch (Exception e){ 792 793 } 794 551 795 } 552 } else if (resUnit instanceof PEUnit){ 553 PEUnit peUnit = (PEUnit) resUnit; 554 } 555 796 } 556 797 } 557 798 return basicResStats; … … 571 812 } 572 813 814 573 815 private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) { 574 ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), "resourceLoadStats"); 816 String usageType = null; 817 if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){ 818 usageType = resource.getResourceCharacteristic().getParameters().get("load-sensor").get(0).getContent(); 819 } 820 ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), usageType); 575 821 int cnt = 0; 576 822 for(String resName: basicStats.keySet()){ 577 823 try { 578 if(resource.getDescendantByName(resName) != null || resource.get Name().compareTo(resName) == 0){824 if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 579 825 createResourceLoadData(usageStats, basicStats.get(resName)); 580 826 cnt++; … … 591 837 592 838 return usageStats; 839 } 840 841 private ResourceAvailabilityStats gatherResourceAvailabilityStats(ComputingResource resource) { 842 String usageType = new String ("usedNodes"); 843 844 int usedResources = 0; 845 for(ComputingResource compResource: resource.getChildren()){ 846 double meanLoad = calculateMeanValue(gatherResourceLoadStats(compResource, basicResStats)); 847 if(meanLoad > 0){ 848 usedResources++; 849 } 850 } 851 ResourceAvailabilityStats availabilityStats = new ResourceAvailabilityStats(resource.getFullName(), resource.getType(), usageType, usedResources, endSimulationTime); 852 return availabilityStats; 853 } 854 855 private ResourceUsefulWorkStats gatherResourceUsefulWorkStats(ComputingResource compResource) { 856 String usageType = "usefulWork"; 857 double usefulWork = 0; 858 JobRegistry jr = new JobRegistryImpl(compResource.getFullName()); 859 for(ExecTask task: jr.getFinishedTasks()){ 860 usefulWork = usefulWork + task.getResourceConsumptionProfile().getUsefulWork(); 861 } 862 ResourceUsefulWorkStats usefulWorkStats = new ResourceUsefulWorkStats(compResource.getFullName(), compResource.getType(), usageType, usefulWork, endSimulationTime); 863 return usefulWorkStats; 593 864 } 594 865 … … 629 900 } 630 901 } 631 902 if(ganttData.get(startSimulationTime) == null) 903 ganttData.put(startSimulationTime, 0.0); 904 if(ganttData.get(endSimulationTime) == null) 905 ganttData.put(endSimulationTime, 0.0); 632 906 return ganttData; 633 907 } … … 643 917 644 918 645 private ResourcePowerStats gatherResourcePowerConsumptionStats( ComputingResource resource) {919 private ResourcePowerStats gatherResourcePowerConsumptionStats(PhysicalResource resource) { 646 920 double power = 0; 647 ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), "resourcePowerConsumptionStats"); 921 922 String usageType = null; 923 if(resource.getResourceCharacteristic().getParameters().get("power-sensor")!= null){ 924 usageType = resource.getResourceCharacteristic().getParameters().get("power-sensor").get(0).getContent(); 925 } 926 ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), usageType); 648 927 Map<Long, Double> usage = resEnergyUsage.getHistory(); 649 928 … … 665 944 usage.put(pu.getTimestamp(), pu.getValue()); 666 945 667 /// System.out.println(resource.getName() + ":"+new DateTime(pu.getTimestamp())+";"+pu.getValue());668 946 power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * MILLI_SEC); 669 947 lastPower = pu.getValue(); … … 673 951 } 674 952 } 675 //System.out.println(power);676 953 return resEnergyUsage; 677 954 } 678 955 679 956 680 private ResourceAirFlowStats gatherResourceAirFlowStats(ComputingResource resource) { 681 682 ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), "resourceAirFlowStats"); 957 private ResourceAirFlowStats gatherResourceAirFlowStats(PhysicalResource resource) { 958 959 String usageType = null; 960 if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor")!= null){ 961 usageType = resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor").get(0).getContent(); 962 } 963 ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), usageType); 683 964 Map<Long, Double> airFlow = resAirFlow.getHistory(); 684 965 … … 704 985 } 705 986 706 private ResourceTemperatureStats gatherResourceTemperatureStats(ComputingResource resource) { 707 708 ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), "resourceTemperatureStats"); 987 private ResourceTemperatureStats gatherResourceTemperatureStats(PhysicalResource resource) { 988 989 String usageType = null; 990 if(resource.getResourceCharacteristic().getParameters().get("temperature-sensor")!= null){ 991 usageType = resource.getResourceCharacteristic().getParameters().get("temperature-sensor").get(0).getContent(); 992 } 993 ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), usageType); 709 994 Map<Long, Double> temperature = resTemperature.getHistory(); 710 995 … … 1065 1350 1066 1351 try { 1067 if(resource.getDescendantByName(resName) != null || resource.get Name().compareTo(resName) == 0){1352 if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 1068 1353 Double load = peLoad.get(resName); 1069 1354 sum += load; … … 1102 1387 1103 1388 1104 1105 1106 1389 private double calculateMaxValue(ResourceDynamicStats resDynamicStats ){ 1390 double maxValue = 0; 1391 1392 Map<Long, Double> history = resDynamicStats.getHistory(); 1393 for (Long key : history.keySet()) { 1394 if(history.get(key) > maxValue){ 1395 maxValue = history.get(key) ; 1396 } 1397 } 1398 return maxValue; 1399 } 1107 1400 1108 1401 … … 1221 1514 TaskStats taskStats = new TaskStats(task, startSimulationTime); 1222 1515 String uniqueTaskID = getUniqueTaskId(task); 1223 taskStats.setProcessors Name(task_processorsMap.get(uniqueTaskID));1516 taskStats.setProcessors(task_processorsMap.get(uniqueTaskID)); 1224 1517 return taskStats; 1225 1518 } … … 1484 1777 1485 1778 public int compare(String o1, String o2) { 1486 Integer o1int ;1487 Integer o2int ;1779 Integer o1int = 0; 1780 Integer o2int = 0; 1488 1781 String o1string; 1489 String o2string; 1490 o1string = o1.substring(0, o1.indexOf("_")); 1491 o2string = o2.substring(0, o2.indexOf("_")); 1492 o1int = Integer.parseInt(o1.substring(o1.indexOf("_")+1)); 1493 o2int = Integer.parseInt(o2.substring(o2.indexOf("_")+1)); 1494 //if(o1string.compareTo(o2string) != 0) 1495 // return o1string.compareTo(o2string); 1496 //else 1782 String o2string = null; 1783 1784 if(o1.contains("_")){ 1785 o1string = o1.substring(0, o1.lastIndexOf("_")); 1786 o1int = Integer.parseInt(o1.substring(o1.lastIndexOf("_")+1)); 1787 } else { 1788 o1string = o1; 1789 } 1790 1791 if(o2.contains("_")){ 1792 o2string = o2.substring(0, o2.lastIndexOf("_")); 1793 o2int = Integer.parseInt(o2.substring(o2.lastIndexOf("_")+1)); 1794 }else { 1795 o2string = o2; 1796 } 1797 1798 if(o1int.compareTo(o2int) != 0) 1497 1799 return o1int.compareTo(o2int); 1800 else 1801 return o1string.compareTo(o2string); 1498 1802 } 1499 1803 } … … 1573 1877 chartAirFlow, 1574 1878 textTemperature, 1575 chartTemperature; 1879 chartTemperature, 1880 textUsefulWorl; 1576 1881 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAirFlowStats.java
r496 r1207 12 12 public ResourceAirFlowStats (String resourceName, ResourceType resourceType, String usageType) { 13 13 super(resourceName, resourceType, usageType); 14 if(usageType == null){ 15 this.usageType = "airflow_volume"; 16 } 14 17 } 15 18 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourcePowerStats.java
r496 r1207 12 12 public ResourcePowerStats (String resourceName, ResourceType resourceType, String usageType) { 13 13 super(resourceName, resourceType, usageType); 14 if(usageType == null){ 15 this.usageType = "power"; 16 } 14 17 } 15 18 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceStats.java
r477 r1207 22 22 23 23 public ResourceStats(ComputingResource compResource) { 24 this.resourceName = compResource.get Name();24 this.resourceName = compResource.getFullName(); 25 25 init(); 26 26 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceTemperatureStats.java
r806 r1207 12 12 public ResourceTemperatureStats (String resourceName, ResourceType resourceType, String usageType) { 13 13 super(resourceName, resourceType, usageType); 14 if(usageType == null){ 15 this.usageType = "temperature"; 16 } 14 17 } 15 18 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsageStats.java
r496 r1207 10 10 public ResourceUsageStats(String resourceName, ResourceType resourceType, String usageType) { 11 11 super(resourceName, resourceType, usageType); 12 if(usageType == null){ 13 this.usageType = "cpu_load"; 14 } 12 15 } 13 16 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java
r1199 r1207 2 2 3 3 4 import java.util.List; 5 4 import java.util.HashSet; 5 import java.util.Iterator; 6 import java.util.Set; 7 8 9 import schedframe.resources.computing.ComputingNode; 10 import schedframe.resources.computing.ComputingResource; 11 import schedframe.resources.computing.Core; 12 import schedframe.resources.computing.Processor; 13 import simulator.stats.implementation.out.StatsSerializer; 6 14 import dcworms.schedframe.scheduling.Executable; 7 8 import simulator.stats.implementation.out.StatsSerializer;9 15 10 16 /** … … 14 20 */ 15 21 public class TaskStats implements StatsInterface { 16 protected List<String> processorsName;22 protected Set<ComputingResource> processingElements; 17 23 protected double reservationStartDate; 18 24 protected double reservationFinishDate; … … 26 32 "ExecutionTime", "ReadyTime", "StartTime", "FlowTime", 27 33 "WaitingTime", "GQ_WaitingTime", "Lateness", "Tardiness", 28 "ReservStartDate", "ReservFinishDate", " ProcessorName", "Energy"};34 "ReservStartDate", "ReservFinishDate", "HostNames", "ProcessorName", "Energy", "AppName",}; 29 35 30 36 public TaskStats(Executable task, long startSimulationTime) { … … 147 153 } 148 154 149 public void setProcessors Name(List<String> value) {150 this.process orsName= value;155 public void setProcessors(Set<ComputingResource> value) { 156 this.processingElements = value; 151 157 } 152 158 … … 159 165 } 160 166 161 public List<String> getProcessorsName() { 162 return processorsName; 163 } 164 167 public Set<String> getProcessingElementsName() { 168 Set<String> processingElementsNames = new HashSet<String>(); 169 Iterator<ComputingResource> it = processingElements.iterator(); 170 while(it.hasNext()) { 171 ComputingResource compRes = it.next(); 172 processingElementsNames.add(compRes.getFullName()); 173 } 174 return processingElementsNames; 175 } 176 177 public Set<String> getHostName() { 178 Set<String> hostNames = new HashSet<String>(); 179 Iterator<ComputingResource> it = processingElements.iterator(); 180 while(it.hasNext()) { 181 ComputingResource compRes = it.next(); 182 ComputingNode node = null; 183 if(compRes instanceof Core){ 184 Core core =(Core) compRes; 185 node = (ComputingNode)core.getNode(); 186 } else if(compRes instanceof Processor){ 187 Processor proc = (Processor) compRes; 188 node = (ComputingNode)proc.getNode(); 189 } else if(compRes instanceof ComputingNode){ 190 node = (ComputingNode)compRes; 191 } 192 if(node != null) 193 hostNames.add(node.getFullName()); 194 } 195 return hostNames; 196 } 197 165 198 public double getReservationStartDate() { 166 199 return reservationStartDate; … … 170 203 return reservationFinishDate; 171 204 } 205 206 public String getExecName() { 207 String execName = null; 208 if(task.getDescription().getExecution() != null) { 209 if(task.getDescription().getExecution().getStdin()!= null && task.getDescription().getExecution().getStdin().length > 0) 210 execName = task.getDescription().getExecution().getStdin()[0].getName(); 211 else if(task.getDescription().getExecution().getExecutable() != null && task.getDescription().getExecution().getExecutable().getApplication() != null) 212 execName = task.getDescription().getExecution().getExecutable().getApplication().getName(); 213 } 214 return execName; 215 } 172 216 173 217 public String[] getHeaders() { -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java
r1140 r1207 1 1 package simulator.stats.implementation.out; 2 2 3 import java.text.DecimalFormat; 3 4 import java.util.Map; 4 5 … … 7 8 8 9 import schedframe.resources.CoolEmAllResourceType; 10 import schedframe.resources.ResourceHistoryChanges; 9 11 import schedframe.resources.StandardResourceType; 12 import simulator.stats.implementation.MetricsStats; 10 13 import simulator.stats.implementation.ResourceAirFlowStats; 14 import simulator.stats.implementation.ResourceAvailabilityStats; 15 import simulator.stats.implementation.ResourceHistoryStats; 11 16 import simulator.stats.implementation.ResourcePowerStats; 12 17 import simulator.stats.implementation.ResourceTemperatureStats; 13 18 import simulator.stats.implementation.ResourceUsageStats; 19 import simulator.stats.implementation.ResourceUsefulWorkStats; 14 20 15 21 public class CoolEmAllStringSerializer extends StringSerializer { … … 19 25 public Object visit(ResourceUsageStats resourceUsageStats) { 20 26 Map<Long, Double> resourceUsage = resourceUsageStats.getHistory(); 21 String cpuMetricName = "CPU_Load"; 27 //String metricName = "cpu_load"; 28 String metricName = resourceUsageStats.getUsageType(); 22 29 int mapSize = resourceUsage.size(); 23 30 /* … … 45 52 } 46 53 47 if( resourceUsageStats.getResourceType().equals(StandardResourceType.Processor) || resourceUsageStats.getResourceType().equals(CoolEmAllResourceType.Processor)){54 if(!resourceUsageStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsageStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){ 48 55 for (Long timestamp : resourceUsage.keySet()) { 49 56 50 buffer.append(cpuMetricName); 51 buffer.append(fieldSeparator); 52 buffer.append(resourceUsageStats.getResourceName()); 57 buffer.append(metricName); 58 buffer.append(fieldSeparator); 59 if(resourceUsageStats.getResourceName().startsWith("/")) 60 buffer.append(resourceUsageStats.getResourceName().substring(1)); 61 else buffer.append(resourceUsageStats.getResourceName()); 53 62 buffer.append(fieldSeparator); 54 63 Double value = resourceUsage.get(timestamp); … … 73 82 public Object visit(ResourcePowerStats resourceEnergyStats) { 74 83 Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory(); 75 String nodeMetricName = "RECS_Power"; 84 //String nodeMetricName = "power"; 85 String metricName = resourceEnergyStats.getUsageType(); 76 86 int mapSize = resourceEnergy.size(); 77 87 /* … … 98 108 buffer = new StringBuffer(size); 99 109 } 100 101 if(resourceEnergyStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceEnergyStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 110 //if(resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.ComputingNode.getName()) || resourceEnergyStats.getResourceType().getName().equals(CoolEmAllResourceType.Node.getName()) || 111 //resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName()) || resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName()) || 112 // resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Heatsink.getName())){ 113 102 114 for (Long timestamp : resourceEnergy.keySet()) { 103 115 104 buffer.append( nodeMetricName);116 buffer.append(metricName); 105 117 buffer.append(fieldSeparator); 106 118 if(resourceEnergyStats.getResourceName().startsWith("/")) … … 117 129 buffer.append(System.getProperty("line.separator")); 118 130 } 119 }131 // } 120 132 121 133 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); … … 129 141 public Object visit(ResourceAirFlowStats resourceAirFlowStats) { 130 142 Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory(); 131 String nodeMetricName = "RECS_Airflow"; 143 //String nodeMetricName = "airflow_volume"; 144 String metricName = resourceAirFlowStats.getUsageType(); 132 145 int mapSize = resourceAirFlow.size(); 133 146 /* … … 154 167 buffer = new StringBuffer(size); 155 168 } 156 157 if(resourceAirFlowStats.getResourceType(). equals(StandardResourceType.ComputingNode) || resourceAirFlowStats.getResourceType().equals(CoolEmAllResourceType.Node)){169 170 if(resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName()) || resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName())){ 158 171 for (Long timestamp : resourceAirFlow.keySet()) { 159 160 buffer.append(nodeMetricName); 172 buffer.append(metricName); 161 173 buffer.append(fieldSeparator); 162 174 if(resourceAirFlowStats.getResourceName().startsWith("/")) … … 185 197 public Object visit(ResourceTemperatureStats resourceTemperatureStats) { 186 198 Map<Long, Double> resourceTemperature = resourceTemperatureStats.getHistory(); 187 String nodeMetricName = "RECS_Temperature"; 188 String cpuMetricName = "CPU_Temp"; 199 //String nodeMetricName = "temperature"; 200 //String cpuMetricName = "temperature"; 201 202 String metricName = resourceTemperatureStats.getUsageType(); 203 189 204 int mapSize = resourceTemperature.size(); 190 205 /* … … 212 227 } 213 228 214 if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node) || 215 resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 216 String metricName = null; 229 if(resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Node.getName()) || resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Processor.getName())){ 230 /*String metricName = null; 217 231 if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 218 232 metricName = nodeMetricName; 219 233 } else if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 220 234 metricName = cpuMetricName; 221 } 235 }*/ 222 236 for (Long timestamp : resourceTemperature.keySet()) { 223 237 224 238 buffer.append(metricName); 225 239 buffer.append(fieldSeparator); 226 buffer.append(resourceTemperatureStats.getResourceName()); 240 if(resourceTemperatureStats.getResourceName().startsWith("/")) 241 buffer.append(resourceTemperatureStats.getResourceName().substring(1)); 242 else buffer.append(resourceTemperatureStats.getResourceName()); 227 243 buffer.append(fieldSeparator); 228 244 Double value = resourceTemperature.get(timestamp); … … 245 261 } 246 262 247 263 public Object visit(MetricsStats metricsStats) { 264 StringBuffer buffer = null; 265 266 if(printedHeaders.add("metrics")) { 267 buffer = new StringBuffer(600); 268 /*String[] headers = metricsStats.getHeaders(); 269 for(int i = 0; i < headers.length; i++) 270 { 271 buffer.append(headers[i]); 272 buffer.append(fieldSeparator); 273 } 274 buffer.append(System.getProperty("line.separator"));*/ 275 } else { 276 buffer = new StringBuffer(300); 277 } 278 DecimalFormat df = new DecimalFormat(); 279 df.setMaximumFractionDigits(3); 280 df.setGroupingUsed(false); 281 282 buffer.append(metricsStats.getMetricName()); 283 buffer.append(fieldSeparator); 284 buffer.append(metricsStats.getResourceName()); 285 buffer.append(fieldSeparator); 286 buffer.append(metricsStats.getTimestamp()); 287 buffer.append(fieldSeparator); 288 buffer.append(df.format(metricsStats.getValue())); 289 buffer.append(fieldSeparator); 290 291 return buffer.toString(); 292 } 293 294 public Object visit(ResourceHistoryStats arg) { 295 StringBuffer buffer = null; 296 297 if(printedHeaders.add("metrics")) { 298 buffer = new StringBuffer(600); 299 /*String[] headers = metricsStats.getHeaders(); 300 for(int i = 0; i < headers.length; i++) 301 { 302 buffer.append(headers[i]); 303 buffer.append(fieldSeparator); 304 } 305 buffer.append(System.getProperty("line.separator"));*/ 306 } else { 307 buffer = new StringBuffer(300); 308 } 309 DecimalFormat df = new DecimalFormat(); 310 df.setMaximumFractionDigits(3); 311 df.setGroupingUsed(false); 312 313 for(ResourceHistoryChanges rhc: arg.getResHistChanges()){ 314 buffer.append(rhc.getTimestamp()); 315 buffer.append(fieldSeparator); 316 buffer.append(rhc.getResourceName()); 317 buffer.append(fieldSeparator); 318 buffer.append(rhc.getOperation()); 319 buffer.append(fieldSeparator); 320 buffer.append(rhc.getParamter()); 321 buffer.append(fieldSeparator); 322 buffer.append(System.getProperty("line.separator")); 323 } 324 325 return buffer.toString(); 326 } 327 328 public Object visit(ResourceUsefulWorkStats resourceUsefulWorkStats) { 329 330 String metricName = resourceUsefulWorkStats.getUsageType(); 331 332 StringBuffer buffer = null; 333 334 if(printedHeaders.add("metrics")) { 335 buffer = new StringBuffer(600); 336 /*String[] headers = metricsStats.getHeaders(); 337 for(int i = 0; i < headers.length; i++) 338 { 339 buffer.append(headers[i]); 340 buffer.append(fieldSeparator); 341 } 342 buffer.append(System.getProperty("line.separator"));*/ 343 } else { 344 buffer = new StringBuffer(300); 345 } 346 DecimalFormat df = new DecimalFormat(); 347 df.setMaximumFractionDigits(3); 348 df.setGroupingUsed(false); 349 if(!resourceUsefulWorkStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsefulWorkStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){ 350 351 buffer.append(metricName); 352 buffer.append(fieldSeparator); 353 buffer.append(resourceUsefulWorkStats.getResourceName()); 354 buffer.append(fieldSeparator); 355 buffer.append(resourceUsefulWorkStats.getTimestamp()); 356 buffer.append(fieldSeparator); 357 buffer.append(df.format(resourceUsefulWorkStats.getValue())); 358 buffer.append(fieldSeparator); 359 buffer.append(System.getProperty("line.separator")); 360 } 361 return buffer.toString(); 362 } 363 364 365 public Object visit(ResourceAvailabilityStats resourceAvailabilityStats) { 366 367 String metricName = resourceAvailabilityStats.getUsageType(); 368 369 StringBuffer buffer = null; 370 371 if(printedHeaders.add("metrics")) { 372 buffer = new StringBuffer(600); 373 /*String[] headers = metricsStats.getHeaders(); 374 for(int i = 0; i < headers.length; i++) 375 { 376 buffer.append(headers[i]); 377 buffer.append(fieldSeparator); 378 } 379 buffer.append(System.getProperty("line.separator"));*/ 380 } else { 381 buffer = new StringBuffer(300); 382 } 383 DecimalFormat df = new DecimalFormat(); 384 df.setMaximumFractionDigits(3); 385 df.setGroupingUsed(false); 386 if(resourceAvailabilityStats.getResourceType().getName().equals(CoolEmAllResourceType.NodeGroup.getName())){ 387 388 buffer.append(metricName); 389 buffer.append(fieldSeparator); 390 buffer.append(resourceAvailabilityStats.getResourceName()); 391 buffer.append(fieldSeparator); 392 buffer.append(resourceAvailabilityStats.getTimestamp()); 393 buffer.append(fieldSeparator); 394 buffer.append(df.format(resourceAvailabilityStats.getValue())); 395 buffer.append(fieldSeparator); 396 buffer.append(System.getProperty("line.separator")); 397 } 398 return buffer.toString(); 399 } 248 400 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StatsSerializer.java
r805 r1207 4 4 import simulator.stats.implementation.GSSAccumulatorsStats; 5 5 import simulator.stats.implementation.JobStats; 6 import simulator.stats.implementation.MetricsStats; 6 7 import simulator.stats.implementation.ResourceAirFlowStats; 8 import simulator.stats.implementation.ResourceAvailabilityStats; 9 import simulator.stats.implementation.ResourceHistoryStats; 7 10 import simulator.stats.implementation.ResourcePowerStats; 8 11 import simulator.stats.implementation.ResourceStats; 9 12 import simulator.stats.implementation.ResourceTemperatureStats; 10 13 import simulator.stats.implementation.ResourceUsageStats; 14 import simulator.stats.implementation.ResourceUsefulWorkStats; 11 15 import simulator.stats.implementation.TaskStats; 12 16 … … 34 38 public Object visit(ResourceTemperatureStats arg); 35 39 40 public Object visit(ResourceUsefulWorkStats arg); 41 36 42 public Object visit(GSSAccumulatorsStats arg); 37 43 44 public Object visit(MetricsStats arg); 45 46 public Object visit(ResourceHistoryStats arg); 47 48 public Object visit(ResourceAvailabilityStats resourceAvailabilityStats); 49 38 50 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StringSerializer.java
r1192 r1207 11 11 import simulator.stats.implementation.GSSAccumulatorsStats; 12 12 import simulator.stats.implementation.JobStats; 13 import simulator.stats.implementation.MetricsStats; 13 14 import simulator.stats.implementation.ResourceAirFlowStats; 15 import simulator.stats.implementation.ResourceAvailabilityStats; 16 import simulator.stats.implementation.ResourceHistoryStats; 14 17 import simulator.stats.implementation.ResourcePowerStats; 15 18 import simulator.stats.implementation.ResourceStats; 16 19 import simulator.stats.implementation.ResourceTemperatureStats; 17 20 import simulator.stats.implementation.ResourceUsageStats; 21 import simulator.stats.implementation.ResourceUsefulWorkStats; 18 22 import simulator.stats.implementation.TaskStats; 19 23 … … 48 52 buffer.append(fieldSeparator); 49 53 } 50 51 54 } 52 55 … … 108 111 .longValue()); 109 112 buffer.append(fieldSeparator); 110 buffer.append(taskStats.getProcessorsName()); 113 buffer.append(taskStats.getHostName()); 114 buffer.append(fieldSeparator); 115 buffer.append(taskStats.getProcessingElementsName()); 116 buffer.append(fieldSeparator); 117 buffer.append(0); 118 buffer.append(fieldSeparator); 119 buffer.append(taskStats.getExecName()); 111 120 buffer.append(fieldSeparator); 112 121 } … … 311 320 } 312 321 313 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));314 if(lastIdx != -1)315 buffer.deleteCharAt(lastIdx);316 317 322 if(resourceUsage.size() > 0){ 318 323 buffer.append("mean: " + resourceUsageStats.getMeanValue()); … … 373 378 374 379 } 375 376 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 377 if(lastIdx != -1) 378 buffer.deleteCharAt(lastIdx); 379 380 380 381 if(resourceEnergy.size() > 0) { 381 382 buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue()); … … 437 438 438 439 } 439 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 440 if(lastIdx != -1) 441 buffer.deleteCharAt(lastIdx); 442 440 443 441 if(resourceAirFlow.size() > 0) { 444 442 buffer.append("mean: "+resourceAirFlowStats.getMeanValue()); … … 500 498 501 499 } 502 503 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 504 if(lastIdx != -1) 505 buffer.deleteCharAt(lastIdx); 506 500 507 501 if(resourceTemperature.size() > 0) { 508 502 buffer.append("mean: "+resourceTemperatureStats.getMeanValue()); … … 573 567 } 574 568 569 public Object visit(MetricsStats metricsStats) { 570 StringBuffer buffer = new StringBuffer(300); 571 return buffer.toString(); 572 } 573 574 public Object visit(ResourceHistoryStats arg) { 575 StringBuffer buffer = new StringBuffer(300); 576 return buffer.toString(); 577 } 578 579 public Object visit(ResourceUsefulWorkStats arg) { 580 StringBuffer buffer = new StringBuffer(300); 581 return buffer.toString(); 582 } 583 584 public Object visit(ResourceAvailabilityStats arg) { 585 StringBuffer buffer = new StringBuffer(300); 586 return buffer.toString(); 587 } 588 589 575 590 } -
DCWoRMS/branches/coolemall/src/simulator/utils/XsltTransformations.java
r1131 r1207 19 19 import javax.xml.xpath.XPathExpressionException; 20 20 21 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 21 22 import dcworms.schedframe.scheduling.utils.JobDescription; 22 23 import dcworms.schedframe.scheduling.utils.TaskDescription; … … 35 36 String value = 36 37 //"org.apache.xalan.xsltc.trax.TransformerFactoryImpl"; 37 "org.apache.xalan.processor.TransformerFactoryImpl"; 38 //"org.apache.xalan.processor.TransformerFactoryImpl"; 39 "net.sf.saxon.TransformerFactoryImpl"; 38 40 Properties props = System.getProperties(); 39 41 props.put(key, value); … … 191 193 } 192 194 195 public ApplicationProfileDescription getApplicationProfileDescription(String xmlJob){ 196 ApplicationProfileDescription appProfDesc = new ApplicationProfileDescription(xmlJob); 197 return appProfDesc; 198 } 199 193 200 public String extractJobId(String job){ 194 201 Transformer t = null; -
DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java
r1170 r1207 17 17 import javax.xml.xpath.XPathExpressionException; 18 18 19 import org.apache.commons.io.FilenameUtils; 19 20 import org.apache.commons.logging.Log; 20 21 import org.apache.commons.logging.LogFactory; … … 32 33 import simulator.workload.reader.archive.swf.SWFFields; 33 34 import simulator.workload.reader.xmlJob.XMLJobReader; 35 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 34 36 import dcworms.schedframe.scheduling.utils.JobDescription; 35 37 import dcworms.schedframe.scheduling.utils.TaskDescription; … … 56 58 57 59 protected Map<String, JobDescription> jobsMap; 58 protected Map<String, JobDescription> applicationProfilesMap; 59 60 public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader){ 60 61 protected String appProfilesFolder; 62 protected Map<String, ApplicationProfileDescription> applicationProfiles; 63 64 public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader, String appProfilesFolder){ 61 65 if(swfReader == null){ 62 66 throw new RuntimeException("Swf reader is required to build proper tasks."); … … 67 71 this.generatedTasksCnt = 0; 68 72 this.jobsMap = new TreeMap<String, JobDescription>(); 69 this.applicationProfilesMap = new TreeMap<String, JobDescription>(); 73 this.appProfilesFolder = appProfilesFolder; 74 this.applicationProfiles = new TreeMap<String, ApplicationProfileDescription>(); 70 75 try { 71 76 this.xsltTransformation = new XsltTransformations(); … … 187 192 188 193 // determine which reader should be used 189 String jobDesc = null; 190 JobDescription job = null; 191 194 String xmlJob = null; 195 JobDescription jobDesc = null; 196 197 for(String key: waReader.getParser().getAppProfilesLocation().keySet()){ 198 String xmlApp = loadApplicationProfile(waReader.getParser().getAppProfilesLocation().get(key)); 199 xmlApp = this.xsltTransformation.extendJobDescription(xmlApp); 200 ApplicationProfileDescription app = this.xsltTransformation.getApplicationProfileDescription(xmlApp); 201 this.applicationProfiles.put(key, app); 202 } 203 192 204 if(this.xmlJobReader != null){ // use xml job reader. Xml job require xslt transformation 193 while(( jobDesc= this.xmlJobReader.readRaw()) != null){194 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc);195 job = createJobDescription(jobDesc, puSpeed);196 if(job != null)197 this.jobsMap.put(job .getJobId(), job);205 while((xmlJob = this.xmlJobReader.readRaw()) != null){ 206 xmlJob = this.xsltTransformation.extendJobDescription(xmlJob); 207 jobDesc = createJobDescription(xmlJob, puSpeed); 208 if(jobDesc != null) 209 this.jobsMap.put(jobDesc.getJobId(), jobDesc); 198 210 } 199 211 } else { // use swf job reader. Job created by this reader does not require xslt transformation 200 212 201 for(String key: waReader.getParser().getAppMapping().keySet()){ 202 jobDesc = loadApplicationProfile(waReader.getParser().getAppMapping().get(key)); 203 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 204 205 try { 206 job = this.xsltTransformation.splitJobToTasks(jobDesc); 207 } catch (Exception e) { 208 throw new IOException(e.getMessage()); 209 } 210 211 this.applicationProfilesMap.put(key, job); 212 } 213 214 while((jobDesc = this.waReader.readRaw()) != null){ 213 while((xmlJob = this.waReader.readRaw()) != null){ 215 214 QcgWAJobReader qcgReader = (QcgWAJobReader)waReader; 216 if(!applicationProfilesMap.isEmpty()) 217 jobDesc = qcgReader.mergeSwfAndXmlProfile(applicationProfilesMap, jobDesc); 218 job = createJobDescription(jobDesc, puSpeed); 219 /*if(job!= null && !applicationProfilesMap.isEmpty()){ 220 for(int i = 0; i < job.getDescription().getTaskCount(); i++){ 221 try { 222 JobDescription xmlJobDescription = applicationProfilesMap.get(job.getDescription().getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 223 if(xmlJobDescription != null){ 224 for(int j = 0; j < xmlJobDescription.size(); j++){ 225 Task patternTask = xmlJobDescription.getDescription().getTask(j); 226 if(patternTask != null){ 227 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 228 job.getDescription().getTask(j).getExecution().setResourceConsumptionProfile(rcp); 229 } 230 } 231 } 232 } catch (Exception e){ 233 continue; 234 } 235 } 236 } 237 */ 238 if(job != null) 239 this.jobsMap.put(job.getJobId(), job); 215 if(!applicationProfiles.isEmpty()) 216 xmlJob = qcgReader.mergeSwfAndAppProfile(applicationProfiles, xmlJob); 217 jobDesc = createJobDescription(xmlJob, puSpeed); 218 if(jobDesc != null) 219 this.jobsMap.put(jobDesc.getJobId(), jobDesc); 240 220 } 241 221 } … … 302 282 } 303 283 304 public String loadApplicationProfile(String fileName) throws IOException{284 public String loadApplicationProfile(String pathToAppProfile) throws IOException{ 305 285 306 286 BufferedReader reader = null; 307 287 StringBuffer buffer = new StringBuffer(); 308 288 309 try { 310 reader = new BufferedReader(new FileReader(fileName)); 289 String localPathToAppProfile; 290 291 if(appProfilesFolder != null) { 292 String folderName = FilenameUtils.getFullPath(appProfilesFolder); 293 String fileName = FilenameUtils.getName(pathToAppProfile); 294 localPathToAppProfile = folderName + fileName; 295 } else { 296 localPathToAppProfile = pathToAppProfile; 297 } 298 try { 299 reader = new BufferedReader(new FileReader(localPathToAppProfile )); 311 300 String line = null; 312 301 -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java
r1144 r1207 33 33 protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id 34 34 protected HashMap<String, Long> jobIndex; 35 protected HashMap<String, String> app Mapping;35 protected HashMap<String, String> appProfilesLocation; 36 36 protected String fields[]; 37 37 protected int fieldsNo; … … 46 46 this.reverseIdMapping = new HashMap<String, String>(); 47 47 this.jobIndex = new HashMap<String, Long>(); 48 this.app Mapping= new HashMap<String, String>();48 this.appProfilesLocation = new HashMap<String, String>(); 49 49 this.headerLoaded = false; 50 50 this.buildIndex = true; 51 51 this.fieldsNo = 18; 52 52 53 } 53 54 … … 152 153 String appId = valueData[0]; 153 154 String pathToAppProfile = valueData[1]; 154 app Mapping.put(appId, pathToAppProfile);155 appProfilesLocation.put(appId, pathToAppProfile); 155 156 continue; 156 157 } … … 296 297 297 298 298 public Map<String, String> getApp Mapping() {299 return app Mapping;299 public Map<String, String> getAppProfilesLocation() { 300 return appProfilesLocation; 300 301 } 301 302 -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java
r1163 r1207 15 15 16 16 import simulator.workload.reader.archive.swf.SWFFields; 17 18 import org.qcg.broker.schemas.jobdesc.FileType; 17 19 import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 18 20 import org.qcg.broker.schemas.jobdesc.Task; 19 21 import org.qcg.broker.schemas.jobdesc.Workflow; 20 22 21 import dcworms.schedframe.scheduling.utils. JobDescription;23 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 22 24 23 25 /** … … 116 118 } 117 119 118 public String mergeSwfAnd XmlProfile(Map<String, JobDescription> applicationProfilesMap, String swfJobDesc) throws IOException{120 public String mergeSwfAndAppProfile(Map<String, ApplicationProfileDescription> applicationProfiles, String swfJobDesc) throws IOException{ 119 121 120 122 StringReader reader = new StringReader(swfJobDesc); … … 132 134 for(int i = 0; i < job.getTaskCount(); i++){ 133 135 try { 134 JobDescription xmlJobDescription = applicationProfilesMap.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 135 if(xmlJobDescription != null){ 136 for(int j = 0; j < xmlJobDescription.size(); j++){ 137 Task patternTask = xmlJobDescription.getDescription().getTask(j); 138 if(patternTask != null){ 139 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 140 job.getTask(j).getExecution().setResourceConsumptionProfile(rcp); 141 } 136 ApplicationProfileDescription appProfileDescription = applicationProfiles.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 137 if(appProfileDescription != null){ 138 Task patternTask = appProfileDescription.getDescription(); 139 if(patternTask != null){ 140 ResourceConsumptionProfileType[] rcp = patternTask.getExecution().getResourceConsumptionProfile(); 141 job.getTask(i).getExecution().setResourceConsumptionProfile(rcp); 142 FileType script = new FileType(); 143 script.setName(patternTask.getId()); 144 job.getTask(i).getExecution().addStdin(script); 142 145 } 143 146 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java
r1144 r1207 45 45 public int getType(); 46 46 47 public Map<String, String> getApp Mapping();47 public Map<String, String> getAppProfilesLocation(); 48 48 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java
r1202 r1207 221 221 222 222 case SWFFields.DATA_EXECUTABLE_NUMBER: 223 String pathToAppProfile = waParser.getApp Mapping().get(String.valueOf(value));223 String pathToAppProfile = waParser.getAppProfilesLocation().get(String.valueOf(value)); 224 224 String appName = null; 225 225 if(pathToAppProfile == null){
Note: See TracChangeset
for help on using the changeset viewer.