Changeset 495 for DCWoRMS/trunk/src/schedframe/resources/computing/profiles
- Timestamp:
- 10/10/12 12:12:06 (13 years ago)
- Location:
- DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy
- Files:
-
- 3 added
- 9 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyEventType.java
r477 r495 15 15 FREQUENCY_CHANGED(64), 16 16 VOLTAGE_CHANGED(128), 17 RESOURCE_FAILED(256) 17 18 AIRFLOW_STATE_CHANGED(256), 19 20 RESOURCE_FAILED(512) 18 21 ; 19 22 -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java
r477 r495 11 11 import schedframe.resources.computing.extensions.ExtensionException; 12 12 import schedframe.resources.computing.extensions.ExtensionType; 13 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 14 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 13 15 import schedframe.resources.computing.profiles.energy.power.PowerProfile; 14 16 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 15 17 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 16 18 17 public class EnergyExtension implements Extension /*, ResourceVisitor */{19 public class EnergyExtension implements Extension{ 18 20 19 21 private Log log = LogFactory.getLog(EnergyExtension.class); … … 21 23 protected PowerInterface powerInterface; 22 24 protected PowerProfile powerProfile; 23 25 26 protected AirThroughputInterface airFlowInterface; 27 protected AirThroughputProfile airFlowProfile; 28 24 29 protected ComputingResource computingResource; 25 30 … … 29 34 } 30 35 31 @Override 36 public EnergyExtension(PowerInterface powerInterface, PowerProfile powerProfile, 37 AirThroughputInterface airFlowInterface, AirThroughputProfile airFlowProfile) { 38 super(); 39 this.powerInterface = powerInterface; 40 this.powerProfile = powerProfile; 41 this.airFlowInterface = airFlowInterface; 42 this.airFlowProfile = airFlowProfile; 43 } 44 32 45 public boolean supportsEvent(Event event) { 33 46 34 47 if(powerProfile == null || powerProfile.getEnergyEstimationPlugin() == null) 35 48 return false; 36 37 49 if(event.getType().getName().equals(EnergyEventType.POWER_STATE_CHANGED.getName())) 38 50 return true; … … 43 55 else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName())) 44 56 return true; 57 58 if(airFlowProfile == null) 59 return false; 60 if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 61 return true; 62 45 63 else return false; 46 64 47 65 } 48 49 66 50 @Override51 67 public void handleEvent(Event event) { 52 68 EnergyEvent enEvent = (EnergyEvent)event; … … 87 103 //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 88 104 powerProfile.addToPowerUsageHistory(power); 89 105 break; 106 case AIRFLOW_STATE_CHANGED: 107 System.out.println("====="); 108 double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 109 airFlowProfile.addToPowerUsageHistory(airFlow); 110 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 111 powerProfile.addToPowerUsageHistory(power); 90 112 break; 91 113 } 92 114 } 93 94 @Override 115 95 116 public void init(Properties properties) throws ExtensionException { 96 117 // TODO Auto-generated method stub 97 118 } 98 119 99 @Override100 120 public ExtensionType getType() { 101 121 return ExtensionType.ENERGY_EXTENSION; … … 118 138 } 119 139 140 public AirThroughputInterface getAirThroughputInterface() { 141 return airFlowInterface; 142 } 143 144 public AirThroughputProfile getAirFlowProfile() { 145 return airFlowProfile; 146 } 120 147 121 148 } -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java
r477 r495 1 1 package schedframe.resources.computing.profiles.energy.airthroughput; 2 2 3 import java.util.ArrayList; 3 4 import java.util.List; 5 6 import org.joda.time.DateTimeUtils; 4 7 5 8 import schedframe.Parameters; … … 7 10 8 11 public class AirThroughputProfile { 12 13 protected List<AirFlowValue> airFlowHistory; 9 14 10 15 protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; … … 16 21 this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 17 22 this.airThroughputStates = airThroughputStates; 23 this.airFlowHistory = new ArrayList<AirFlowValue>(); 18 24 } 19 25 20 26 public List<AirThroughputState> getAirThroughputStates() { 21 27 return airThroughputStates; 28 } 29 30 public void addToPowerUsageHistory(double airFlow) { 31 32 if (airFlowHistory.size() == 0) { 33 AirFlowValue usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 34 airFlowHistory.add(usage); 35 return; 36 } 37 38 int lastIdx = airFlowHistory.size() - 1; 39 double lastAirFlow = airFlowHistory.get(lastIdx).getValue(); 40 if (lastAirFlow != airFlow) { 41 AirFlowValue usage = airFlowHistory.get(lastIdx); 42 long currentTime = DateTimeUtils.currentTimeMillis(); 43 if (usage.getTimestamp() == currentTime) { 44 usage.setValue(airFlow); 45 if(lastIdx > 0 && airFlowHistory.get(lastIdx - 1).getValue() == airFlow) 46 airFlowHistory.remove(usage); 47 } else { 48 usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 49 airFlowHistory.add(usage); 50 } 51 } 52 } 53 54 public List<AirFlowValue> getAirThroughputHistory() { 55 return airFlowHistory; 22 56 } 23 57 -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java
r477 r495 10 10 public String getAirThroughputState(); 11 11 12 public boolean setAirThroughputState(String airThroug putState);12 public boolean setAirThroughputState(String airThroughputState); 13 13 14 14 public boolean supportAirThroughputState(String powerState); -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/DefaultAirThroughputInterface.java
r477 r495 6 6 import schedframe.Parameters; 7 7 import schedframe.resources.computing.ComputingResource; 8 import schedframe.resources.computing.profiles.energy.EnergyEvent; 9 import schedframe.resources.computing.profiles.energy.EnergyEventType; 8 10 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 9 11 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 10 12 11 public class DefaultAirThroug putInterface implements AirThroughputInterface{13 public class DefaultAirThroughputInterface implements AirThroughputInterface{ 12 14 13 15 protected String currentAirThroughputState; 14 16 protected AirThroughputProfile airThroughputProfile; 15 17 protected ComputingResource resource; 18 19 public DefaultAirThroughputInterface(ComputingResource resource, AirThroughputProfile airThroughputProfile){ 20 this.resource = resource; 21 this.airThroughputProfile = airThroughputProfile; 22 } 16 23 17 24 public String getAirThroughputState() { … … 22 29 if(supportAirThroughputState(state)){ 23 30 currentAirThroughputState = state; 31 32 //TO DO - notifications should be called for all resources starting form the lowest layer 33 resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getName())); 34 24 35 return true; 25 36 } … … 28 39 29 40 public boolean supportAirThroughputState(String state) { 30 31 41 for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){ 32 42 if(airFlowState.getName().equals(state)){ -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java
r477 r495 5 5 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 6 6 7 public class Power ProfileFactory {7 public class PowerInterfaceFactory { 8 8 9 9 … … 36 36 else if (resource.getType().getName().equals(StandardResourceType.Processor.getName())) 37 37 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface(resource, pp); 38 else throw new IllegalArgumentException("ResourceType " + resource.getType() + " is not supported."); 38 else 39 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface(resource, pp); 39 40 40 41 /*switch(resource.getType()){ -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java
r477 r495 22 22 23 23 24 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates) {24 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 25 25 this.energyEstimationPlugin = energyEstimationPlugin; 26 26 this.powerUsage = new ArrayList<PowerUsage>(); 27 this.supportedPowerStates = supportedPowerStates;27 this.supportedPowerStates = powerStates; 28 28 } 29 29 30 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates, List<PState> pStates) {30 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, List<PState> pStates) { 31 31 this.energyEstimationPlugin = energyEstimationPlugin; 32 this.supportedPowerStates = supportedPowerStates;32 this.supportedPowerStates = powerStates; 33 33 this.powerUsage = new ArrayList<PowerUsage>(); 34 34 if(pStates.size() > 0) -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerUsage.java
r477 r495 1 1 package schedframe.resources.computing.profiles.energy.power; 2 2 3 public class PowerUsage { 3 import schedframe.resources.computing.profiles.energy.MeasurementHistory; 4 4 5 protected long timestamp; 6 protected double value; 5 public class PowerUsage extends MeasurementHistory{ 7 6 8 7 public PowerUsage(long timestamp, double value){ 9 this.timestamp = timestamp; 10 this.value = value; 11 } 12 13 public long getTimestamp() { 14 return timestamp; 15 } 16 17 public double getValue() { 18 return value; 19 } 20 21 public void setValue(double value) { 22 this.value = value; 8 super(timestamp, value); 23 9 } 24 10 -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java
r477 r495 10 10 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 11 11 12 public class ComputingNodePowerInterface extends AbstractPowerInterface{12 public class ComputingNodePowerInterface extends ComputingResourcePowerInterface{ 13 13 14 14 public static long START_TIME = 600000; -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java
r477 r495 17 17 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 18 18 19 public abstract class AbstractPowerInterface implements PowerInterface{19 public class ComputingResourcePowerInterface implements PowerInterface{ 20 20 21 21 protected PowerStateName currentPowerState; … … 23 23 protected ComputingResource resource; 24 24 25 public AbstractPowerInterface(ComputingResource resource, PowerProfile powerProfile){25 public ComputingResourcePowerInterface(ComputingResource resource, PowerProfile powerProfile){ 26 26 this.resource = resource; 27 27 this.powerProfile = powerProfile; -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java
r477 r495 7 7 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 8 8 9 public class DataCenterPowerInterface extends AbstractPowerInterface{9 public class DataCenterPowerInterface extends ComputingResourcePowerInterface{ 10 10 11 12 13 14 11 public DataCenterPowerInterface(ComputingResource resource, PowerProfile pp){ 15 12 super(resource, pp); -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java
r494 r495 1 1 package schedframe.resources.computing.profiles.energy.power.ui; 2 2 3 import gridsim.dcworms.DCWormsTags;4 3 5 4 import java.util.Map; … … 16 15 import schedframe.resources.units.StandardResourceUnitName; 17 16 18 public class ProcessorPowerInterface extends AbstractPowerInterface {17 public class ProcessorPowerInterface extends ComputingResourcePowerInterface { 19 18 20 19 protected PState currentPState;
Note: See TracChangeset
for help on using the changeset viewer.