Ignore:
Timestamp:
11/26/13 11:56:07 (11 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java

    r1165 r1207  
    77 
    88import schedframe.events.Event; 
    9 import schedframe.resources.computing.ComputingResource; 
    109import schedframe.resources.computing.extensions.Extension; 
    1110import schedframe.resources.computing.extensions.ExtensionException; 
     
    2019import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 
    2120import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
     21import schedframe.resources.devices.PhysicalResource; 
    2222import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
     23import simulator.DataCenterWorkloadSimulator; 
    2324 
    2425public class EnergyExtension implements Extension{ 
     
    3536        protected ThermalProfile thermalProfile; 
    3637         
    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; 
    4144                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, 
    4649                        AirThroughputProfile airFlowProfile) { 
    4750                super(); 
    48                 this.computingResource = computingResource; 
     51                this.resource = resource; 
    4952                this.powerProfile = powerProfile; 
    50                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
     53                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
    5154                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, 
    5659                        AirThroughputProfile airFlowProfile, ThermalProfile thermalProfile) { 
    5760                super(); 
    58                 this.computingResource = computingResource; 
     61                this.resource = resource; 
    5962                this.powerProfile = powerProfile; 
    60                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
     63                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
    6164                this.airFlowProfile = airFlowProfile; 
    62                 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile); 
     65                this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); 
    6366                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         
    67108        public boolean supportsEvent(Event event) { 
    68109 
     
    82123                if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 
    83124                        return true; 
     125                if(event.getType().getName().equals(EnergyEventType.TEMPERATURE_CHANGED.getName())) 
     126                        return true; 
    84127                 
    85128                else return false; 
     
    90133                EnergyEvent enEvent = (EnergyEvent)event; 
    91134                double power = 0; 
    92                 double temperature = 0; 
     135                boolean status = false; 
    93136                try{ 
    94137                        switch (enEvent.getType()) { 
    95138                         
    96139                        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); 
    98141                                /*if(computingResource instanceof ComputingNode){ 
    99142                                        ComputingNode node = (ComputingNode)computingResource; 
     
    109152                                        } 
    110153                                } 
    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); 
    114157                                break; 
    115158                                 
    116159                        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); 
    121162                                break; 
    122163                                 
    123164                        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); 
    128167                                break; 
    129168         
    130169                        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); 
    137172                                break; 
    138173                                 
    139174                        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); 
    144177                                break; 
    145178                                 
    146179                        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); 
    152186                                thermalProfile.addToTemperatureHistory(temperature); 
    153187                                break; 
     
    156190                         
    157191                } 
     192                if(status){ 
     193                        DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, resource.getFullName())); 
     194                } 
    158195        } 
    159196 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputInterfaceFactory.java

    r753 r1207  
    11package schedframe.resources.computing.profiles.energy.airthroughput; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.ComputingResource; 
    45import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    56import schedframe.resources.computing.profiles.energy.airthroughput.ui.ComputingResourceAirThroughputInterface; 
     7import schedframe.resources.devices.PhysicalResource; 
     8import schedframe.resources.devices.PhysicalResourceAirThroughputInterface; 
     9import schedframe.resources.devices.coolemall.FanAirThroughputInterface; 
    610 
    711public class AirThroughputInterfaceFactory { 
    812         
    9         public static AirThroughputInterface createAirThroughputInterface(ComputingResource resource, AirThroughputProfile atp){ 
     13        public static AirThroughputInterface createAirThroughputInterface(PhysicalResource resource, AirThroughputProfile atp){ 
    1014                if(atp == null) 
    1115                        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); 
    1429                return airThroughputInterface; 
    1530        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java

    r495 r1207  
    2828        } 
    2929         
    30         public void addToPowerUsageHistory(double airFlow) { 
     30        public void addToAirFlowHistory(double airFlow) { 
    3131 
    3232                if (airFlowHistory.size() == 0) { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/StandardAirThroughputStateName.java

    r753 r1207  
    33public enum  StandardAirThroughputStateName implements AirThroughputStateName{ 
    44 
    5         FAN_ON, 
    6         FAN_OFF; 
     5        ON, 
     6        OFF; 
    77 
    88        public String getName() { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java

    r754 r1207  
    44 
    55import schedframe.Parameters; 
     6import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    67import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    78import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputStateName; 
     
    910public interface AirThroughputInterface { 
    1011         
    11         public AirThroughputStateName  getAirThroughputState(); 
     12        public AirThroughputStateName getAirThroughputState(); 
    1213         
    1314        public boolean setAirThroughputState(AirThroughputStateName airThroughputState); 
     
    2122        public double getPowerConsumption(AirThroughputStateName state) throws NoSuchFieldException; 
    2223         
     24        public AirFlowValue getRecentAirFlow(); 
     25         
     26        List<AirFlowValue> getAirFlowHistory(); 
     27         
    2328        public Parameters getParameters(); 
     29         
     30         
    2431} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/ComputingResourceAirThroughputInterface.java

    r754 r1207  
    44import java.util.List; 
    55 
     6import org.joda.time.DateTimeUtils; 
     7 
    68import schedframe.Parameters; 
    79import schedframe.resources.computing.ComputingResource; 
    810import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    911import schedframe.resources.computing.profiles.energy.EnergyEventType; 
     12import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    1013import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    1114import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
     
    2225                this.resource = resource; 
    2326                this.airThroughputProfile = airThroughputProfile; 
    24                 this.currentAirThroughputState = StandardAirThroughputStateName.FAN_ON; 
     27                this.currentAirThroughputState = StandardAirThroughputStateName.ON; 
    2528        } 
    2629         
     
    3437                         
    3538                        //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())); 
    3741                        return true; 
    3842                } 
     
    8387        } 
    8488         
     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         
    85108        public Parameters getParameters() { 
    86109                return airThroughputProfile.getParameters(); 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PState.java

    r1119 r1207  
    11package schedframe.resources.computing.profiles.energy.power; 
     2 
     3import java.util.Map; 
     4import java.util.TreeMap; 
    25 
    36public class PState { 
     
    912        protected double powerUsageMin; 
    1013        protected double powerUsageMax; 
    11  
     14        //protected List<LoadPowerUsage> loadPowerUsageList; 
     15        protected Map<Double, Double> loadPowerUsage; 
     16         
    1217        /*public PState(PStateType name, double frequency, double voltage, double power) { 
    1318                super(); 
     
    3843                return powerUsageMax; 
    3944        } 
    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 
    4155        public static class Builder { 
    4256           
     
    4761                protected double powerUsageMin; 
    4862                protected double powerUsageMax; 
     63                //protected List<LoadPowerUsage> loadPowerUsageList = new ArrayList<LoadPowerUsage>(); 
     64                protected Map<Double, Double> loadPowerUsage = new TreeMap<Double, Double>(); 
    4965                 
    5066                public Builder name(String name){this.name = name; return this; } 
     
    5470        public Builder powerUsageMin(double rate){this.powerUsageMin = rate; return this; } 
    5571        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; } 
    5674         
    5775        public PState build() { 
     
    6785                this.powerUsageMin = builder.powerUsageMin; 
    6886                this.powerUsageMax = builder.powerUsageMax; 
     87                //this.loadPowerUsageList = builder.loadPowerUsageList; 
     88                this.loadPowerUsage = builder.loadPowerUsage; 
    6989        } 
     90 
     91 
    7092} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java

    r1104 r1207  
    11package schedframe.resources.computing.profiles.energy.power; 
    22 
    3 import schedframe.resources.CoolEmAllResourceType; 
    43import schedframe.resources.StandardResourceType; 
    54import schedframe.resources.computing.ComputingResource; 
    65import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
     6import schedframe.resources.devices.PhysicalResource; 
     7import schedframe.resources.devices.PhysicalResourcePowerInterface; 
    78 
    89public class PowerInterfaceFactory { 
    910 
    10  
    11  
    12         //new1 
    13         /*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         }*/ 
    2711         
    28         public static PowerInterface createPowerInterface(ComputingResource resource, PowerProfile pp){ 
     12        public static PowerInterface createPowerInterface(PhysicalResource resource, PowerProfile pp){ 
    2913                if(pp == null) 
    3014                        return null; 
    3115                PowerInterface powerInterface; 
    32  
     16                 
    3317                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); 
    3721                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); 
    4135                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); 
    4337 
    4438                /*switch(resource.getType()){ 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java

    r1167 r1207  
    2424        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 
    2525                this.energyEstimationPlugin = energyEstimationPlugin; 
     26                this.supportedPowerStates = powerStates; 
    2627                this.powerUsage = new ArrayList<PowerUsage>(); 
    27                 this.supportedPowerStates = powerStates; 
     28                initDefaultPowerStates(); 
    2829        } 
    2930         
    30         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates,  List<PState> pStates) { 
     31        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, List<PState> pStates) { 
    3132                this.energyEstimationPlugin = energyEstimationPlugin; 
    3233                this.supportedPowerStates = powerStates; 
     
    3738                        supportedPStates.put(pState.getName(), pState); 
    3839                } 
     40                initDefaultPowerStates(); 
    3941        } 
    4042         
     
    6062        } 
    6163         
    62         public List<PowerState> getSupportedPowerStates() throws NoSuchFieldException{ 
     64        public List<PowerState> getSupportedPowerStates() { 
    6365                if(supportedPowerStates == null) 
    64                         throw new NoSuchFieldException("Supported power states are not defined."); 
     66                        return new ArrayList<PowerState>(); 
    6567                return supportedPowerStates; 
    6668        } 
     
    111113        } 
    112114 
    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        } 
    114136} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java

    r477 r1207  
    22 
    33import schedframe.Plugin; 
    4 import schedframe.resources.computing.ComputingResource; 
    54import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     5import schedframe.resources.devices.PhysicalResource; 
    66import schedframe.scheduling.manager.tasks.JobRegistry; 
    77 
    88public interface EnergyEstimationPlugin extends Plugin { 
    99         
    10         public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     10        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1111 
    12         public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     12        public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1313 
    14         public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     14        public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1515 
    1616} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java

    r1166 r1207  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
     3 
     4 
     5import org.joda.time.DateTime; 
     6 
     7import schedframe.SimulatedEnvironment; 
    38import schedframe.resources.ResourceStatus; 
    49import schedframe.resources.computing.ComputingNode; 
     
    3843                 
    3944                if(!pePowerStateChangeStatus){ 
    40                         computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 
     45                        computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getFullName())); 
    4146                } 
    4247 
     
    4853                } 
    4954                //computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 
     55                //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    5056                return true; 
    5157        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java

    r579 r1207  
    44import java.util.List; 
    55 
     6import org.joda.time.DateTime; 
    67import org.joda.time.DateTimeUtils; 
    78 
    89import schedframe.Parameters; 
     10import schedframe.SimulatedEnvironment; 
    911import schedframe.resources.ResourceStatus; 
    1012import schedframe.resources.computing.ComputingResource; 
     
    4648                        } 
    4749                        //notifications from all levels 
    48                         resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName())); 
     50                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 
    4951 
    5052                        //notification from last level 
    5153                        //if (resource.getChildren() == null) resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource)); 
    5254                         
     55                        //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    5356                        return true; 
    5457                } 
     
    7073 
    7174        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; 
    7778                        } 
    78                 } catch (NoSuchFieldException e) { 
    79                         return false; 
    8079                } 
    8180                return false; 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java

    r495 r1207  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
     3import org.joda.time.DateTime; 
     4 
     5import schedframe.SimulatedEnvironment; 
    36import schedframe.resources.computing.ComputingResource; 
    47import schedframe.resources.computing.DataCenter; 
     
    2326                        child.getPowerInterface().setPowerState(state); 
    2427                } 
    25  
     28                //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    2629                return true; 
    2730        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r782 r1207  
    44import java.util.Map; 
    55 
     6import org.joda.time.DateTime; 
     7 
     8import schedframe.SimulatedEnvironment; 
    69import schedframe.resources.ResourceStatus; 
    710import schedframe.resources.computing.ComputingResource; 
     
    1619 
    1720        protected PState currentPState; 
    18  
    1921 
    2022        public ProcessorPowerInterface(ComputingResource resource, PowerProfile pp){ 
     
    3436                                resource.setStatus(ResourceStatus.FREE); 
    3537                        } 
    36                         resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName()));          
     38                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));              
    3739                } 
    3840 
     
    6870                        //speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 
    6971                        //new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED); 
    70                         resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getName())); 
     72                        resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getFullName())); 
    7173                        //resource.getScheduler().sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, resource.getName()); 
     74                         
     75                        //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "PSTATE_CHANGED", pStateName); 
    7276                        return true; 
    7377                } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/thermal/ThermalInterfaceFactory.java

    r803 r1207  
    11package schedframe.resources.computing.profiles.energy.thermal; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.ComputingResource; 
    45import schedframe.resources.computing.profiles.energy.thermal.ui.ComputingResourceThermalInterface; 
    56import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
     7import schedframe.resources.devices.PhysicalResource; 
     8import schedframe.resources.devices.PhysicalResourceThermalInterface; 
    69 
    710public class ThermalInterfaceFactory { 
    8         public static ThermalInterface createThermalInterface(ComputingResource resource, ThermalProfile tp){ 
     11        public static ThermalInterface createThermalInterface(PhysicalResource resource, ThermalProfile tp){ 
    912                if(tp == null) 
    1013                        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); 
    1321                return thermalInterface; 
    1422        } 
Note: See TracChangeset for help on using the changeset viewer.