Ignore:
Timestamp:
10/10/12 12:12:06 (13 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/trunk/src/schedframe/resources/computing
Files:
3 added
16 edited
3 moved

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/schedframe/resources/computing/ComputingNode.java

    r477 r495  
    1010import schedframe.resources.computing.extensions.ExtensionType; 
    1111import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    12 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     12import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    1313import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 
    1414import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
     
    2626                 
    2727                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 
    28                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     28                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    2929                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    3030        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java

    r494 r495  
    2828import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    2929import schedframe.resources.computing.profiles.energy.EnergyExtension; 
     30import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    3031import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    3132import schedframe.resources.computing.properties.DefaultPropertiesBuilder; 
     
    6869        } 
    6970 
    70         //TODO remove if possible (check if all scenarios can be realized - statistics issue) , since it's temporary method 
     71        //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 
    7172        private void addFakeProcessors() { 
    7273                if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ 
     
    145146                sec.execute(event); 
    146147 
    147                  
    148148                //old, correctly working method 
    149149                /*if (extensionList != null) { 
     
    188188        } 
    189189         
    190         protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutoff) { 
     190        protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutOff) { 
    191191 
    192192                List<ComputingResource> descendants = new ArrayList<ComputingResource>(); 
     
    198198                                ComputingResource resource = toExamine.pop(); 
    199199                                List<ComputingResource> resources = resource.getChildren(); 
    200                                 /*if (resources == null) 
    201                                         continue;*/ 
    202200                                int numberOfRes = resources.size(); 
    203201                                for (int i = 0; i < numberOfRes; i++) { 
     
    205203                                        if (resourceChild.match(validators)) { 
    206204                                                descendants.add(resourceChild); 
    207                                                 if(cutoff == false) { 
     205                                                if(cutOff == false) { 
    208206                                                        toExamine.addLast(resourceChild); 
    209207                                                } 
     
    243241                return null; 
    244242        } 
     243         
     244        public AirThroughputInterface getAirThroughputInterface(){ 
     245                if (extensionList != null) { 
     246                        for (Extension extension : extensionList) { 
     247                                if (extension.getType() == ExtensionType.ENERGY_EXTENSION) { 
     248                                        EnergyExtension ee = (EnergyExtension)extension; 
     249                                        return ee.getAirThroughputInterface(); 
     250                                } 
     251                        } 
     252                } 
     253                return null; 
     254        } 
    245255 
    246256        public Scheduler getScheduler() { 
     
    257267        } 
    258268 
    259         class SimpleEventHandler implements EventHandler{ 
     269        class ComputingResourceEventHandler implements EventHandler{ 
    260270                 
    261271                public void handleResourceEvent(Event event){ 
     
    282292         
    283293        public EventHandler getEventHandler(){ 
    284                 return new SimpleEventHandler(); 
     294                return new ComputingResourceEventHandler(); 
    285295        } 
    286296         
    287297        public void initiate(){ 
     298                 
    288299                ResourceEventCommand rec = new ResourceEventCommand(this); 
    289                 EnergyEvent event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 
     300                EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); 
    290301                event.setReason(EventReason.SIM_INIT); 
    291302                rec.execute(event); 
     303                 
     304                rec = new ResourceEventCommand(this); 
     305                event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 
     306                event.setReason(EventReason.SIM_INIT); 
     307                rec.execute(event); 
     308                 
    292309                //alternative way 
     310                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 
    293311                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 
    294312        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/Core.java

    r477 r495  
    33import schedframe.resources.computing.description.ComputingResourceDescription; 
    44import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    5 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     5import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    66import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    77import schedframe.resources.units.CpuSpeed; 
     
    1313        public Core (ComputingResourceDescription resDesc) { 
    1414                super(resDesc); 
    15                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     15                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    1616                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    1717        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/DataCenter.java

    r477 r495  
    33import schedframe.resources.computing.description.ComputingResourceDescription; 
    44import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    5 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     5import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    66import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    77 
     
    1111                super(resDesc); 
    1212                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 
    13                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     13                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    1414                accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 
    1515        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/Processor.java

    r477 r495  
    88import schedframe.resources.computing.extensions.ExtensionType; 
    99import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    10 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     10import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    1111import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1212import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface; 
     
    2222                super(resDesc); 
    2323                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 
    24                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     24                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    2525                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    2626        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/Rack.java

    r477 r495  
    66import schedframe.resources.computing.description.ComputingResourceDescription; 
    77import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    8 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     8import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    99import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1010 
     
    1414        public Rack (ComputingResourceDescription resDesc) { 
    1515                super(resDesc); 
    16                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     16                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    1717                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    1818        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ResourceFactory.java

    r481 r495  
    2020                if (resDesc.getType().equals(StandardResourceType.DataCenter)) 
    2121                        return new DataCenter(resDesc); 
     22                else if (resDesc.getType().equals(StandardResourceType.Rack)) 
     23                        return  new Rack(resDesc); 
    2224                else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 
    2325                        return  new ComputingNode(resDesc); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyEventType.java

    r477 r495  
    1515        FREQUENCY_CHANGED(64), 
    1616        VOLTAGE_CHANGED(128), 
    17         RESOURCE_FAILED(256) 
     17         
     18        AIRFLOW_STATE_CHANGED(256), 
     19         
     20        RESOURCE_FAILED(512) 
    1821        ; 
    1922 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java

    r477 r495  
    1111import schedframe.resources.computing.extensions.ExtensionException; 
    1212import schedframe.resources.computing.extensions.ExtensionType; 
     13import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
     14import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    1315import schedframe.resources.computing.profiles.energy.power.PowerProfile; 
    1416import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1517import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    1618 
    17 public class EnergyExtension implements Extension/*, ResourceVisitor */{ 
     19public class EnergyExtension implements Extension{ 
    1820 
    1921        private Log log = LogFactory.getLog(EnergyExtension.class); 
     
    2123        protected PowerInterface powerInterface; 
    2224        protected PowerProfile powerProfile; 
    23  
     25         
     26        protected AirThroughputInterface airFlowInterface; 
     27        protected AirThroughputProfile airFlowProfile; 
     28         
    2429        protected ComputingResource computingResource; 
    2530 
     
    2934        } 
    3035 
    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 
    3245        public boolean supportsEvent(Event event) { 
    3346 
    3447                if(powerProfile == null || powerProfile.getEnergyEstimationPlugin() == null) 
    3548                        return false; 
    36                  
    3749                if(event.getType().getName().equals(EnergyEventType.POWER_STATE_CHANGED.getName())) 
    3850                        return true; 
     
    4355                else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName())) 
    4456                        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                 
    4563                else return false; 
    4664 
    4765        } 
    48          
    4966 
    50         @Override 
    5167        public void handleEvent(Event event) { 
    5268                EnergyEvent enEvent = (EnergyEvent)event; 
     
    87103                        //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 
    88104                        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); 
    90112                        break; 
    91113                } 
    92114        } 
    93          
    94         @Override 
     115 
    95116        public void init(Properties properties) throws ExtensionException { 
    96117                // TODO Auto-generated method stub 
    97118        } 
    98119 
    99         @Override 
    100120        public ExtensionType getType() { 
    101121                return ExtensionType.ENERGY_EXTENSION; 
     
    118138        } 
    119139 
     140        public AirThroughputInterface getAirThroughputInterface() { 
     141                return airFlowInterface; 
     142        } 
     143 
     144        public AirThroughputProfile getAirFlowProfile() { 
     145                return airFlowProfile; 
     146        } 
    120147 
    121148} 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java

    r477 r495  
    11package schedframe.resources.computing.profiles.energy.airthroughput; 
    22 
     3import java.util.ArrayList; 
    34import java.util.List; 
     5 
     6import org.joda.time.DateTimeUtils; 
    47 
    58import schedframe.Parameters; 
     
    710 
    811public class AirThroughputProfile { 
     12         
     13        protected List<AirFlowValue> airFlowHistory; 
    914         
    1015        protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; 
     
    1621                this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 
    1722                this.airThroughputStates = airThroughputStates; 
     23                this.airFlowHistory = new ArrayList<AirFlowValue>(); 
    1824        } 
    1925 
    2026        public List<AirThroughputState> getAirThroughputStates() { 
    2127                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; 
    2256        } 
    2357         
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java

    r477 r495  
    1010        public String getAirThroughputState(); 
    1111         
    12         public boolean setAirThroughputState(String airThrougputState); 
     12        public boolean setAirThroughputState(String airThroughputState); 
    1313         
    1414        public boolean supportAirThroughputState(String powerState); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/DefaultAirThroughputInterface.java

    r477 r495  
    66import schedframe.Parameters; 
    77import schedframe.resources.computing.ComputingResource; 
     8import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     9import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    810import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    911import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    1012 
    11 public class DefaultAirThrougputInterface implements AirThroughputInterface{ 
     13public class DefaultAirThroughputInterface implements AirThroughputInterface{ 
    1214 
    1315        protected String currentAirThroughputState; 
    1416        protected AirThroughputProfile airThroughputProfile; 
    1517        protected ComputingResource resource; 
     18         
     19        public DefaultAirThroughputInterface(ComputingResource resource, AirThroughputProfile airThroughputProfile){ 
     20                this.resource = resource; 
     21                this.airThroughputProfile = airThroughputProfile; 
     22        } 
    1623         
    1724        public String getAirThroughputState() { 
     
    2229                if(supportAirThroughputState(state)){ 
    2330                        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 
    2435                        return true; 
    2536                } 
     
    2839 
    2940        public boolean supportAirThroughputState(String state) { 
    30  
    3141                for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){ 
    3242                        if(airFlowState.getName().equals(state)){ 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java

    r477 r495  
    55import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    66 
    7 public class PowerProfileFactory { 
     7public class PowerInterfaceFactory { 
    88 
    99 
     
    3636                else if (resource.getType().getName().equals(StandardResourceType.Processor.getName())) 
    3737                        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); 
    3940 
    4041                /*switch(resource.getType()){ 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java

    r477 r495  
    2222         
    2323 
    24         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates) { 
     24        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 
    2525                this.energyEstimationPlugin = energyEstimationPlugin; 
    2626                this.powerUsage = new ArrayList<PowerUsage>(); 
    27                 this.supportedPowerStates = supportedPowerStates; 
     27                this.supportedPowerStates = powerStates; 
    2828        } 
    2929         
    30         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates,  List<PState> pStates) { 
     30        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates,  List<PState> pStates) { 
    3131                this.energyEstimationPlugin = energyEstimationPlugin; 
    32                 this.supportedPowerStates = supportedPowerStates; 
     32                this.supportedPowerStates = powerStates; 
    3333                this.powerUsage = new ArrayList<PowerUsage>(); 
    3434                if(pStates.size() > 0) 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerUsage.java

    r477 r495  
    11package schedframe.resources.computing.profiles.energy.power; 
    22 
    3 public class PowerUsage { 
     3import schedframe.resources.computing.profiles.energy.MeasurementHistory; 
    44 
    5         protected long timestamp; 
    6         protected double value; 
     5public class PowerUsage extends MeasurementHistory{ 
    76 
    87        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); 
    239        } 
    2410         
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java

    r477 r495  
    1010import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    1111 
    12 public class ComputingNodePowerInterface extends AbstractPowerInterface{ 
     12public class ComputingNodePowerInterface extends ComputingResourcePowerInterface{ 
    1313 
    1414        public static long START_TIME = 600000; 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java

    r477 r495  
    1717import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    1818 
    19 public abstract class AbstractPowerInterface implements PowerInterface{ 
     19public class ComputingResourcePowerInterface implements PowerInterface{ 
    2020 
    2121        protected PowerStateName currentPowerState; 
     
    2323        protected ComputingResource resource; 
    2424         
    25         public AbstractPowerInterface(ComputingResource resource, PowerProfile powerProfile){ 
     25        public ComputingResourcePowerInterface(ComputingResource resource, PowerProfile powerProfile){ 
    2626                this.resource = resource; 
    2727                this.powerProfile = powerProfile; 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java

    r477 r495  
    77import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    88 
    9 public class DataCenterPowerInterface extends AbstractPowerInterface{ 
     9public class DataCenterPowerInterface extends ComputingResourcePowerInterface{ 
    1010 
    11  
    12  
    13          
    1411        public DataCenterPowerInterface(ComputingResource resource, PowerProfile pp){ 
    1512                super(resource, pp); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r494 r495  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
    3 import gridsim.dcworms.DCWormsTags; 
    43 
    54import java.util.Map; 
     
    1615import schedframe.resources.units.StandardResourceUnitName; 
    1716 
    18 public class ProcessorPowerInterface extends AbstractPowerInterface { 
     17public class ProcessorPowerInterface extends ComputingResourcePowerInterface { 
    1918 
    2019        protected PState currentPState; 
Note: See TracChangeset for help on using the changeset viewer.