Changeset 1207 for DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java
- Timestamp:
- 11/26/13 11:56:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.