Changeset 1207 for DCWoRMS/branches/coolemall/src/schedframe
- Timestamp:
- 11/26/13 11:56:07 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src/schedframe
- Files:
-
- 19 added
- 45 edited
- 3 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.