source: DCWoRMS/branches/coolemall/src/test/powerCapping/NodeEnergyEstimationPlugin.java @ 1399

Revision 1399, 3.9 KB checked in by wojtekp, 11 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.powerCapping;
2
3import org.joda.time.DateTime;
4
5import schedframe.resources.StandardResourceType;
6import schedframe.resources.computing.ComputingResource;
7import schedframe.resources.computing.Node;
8import schedframe.resources.computing.Processor;
9import schedframe.resources.computing.profiles.energy.EnergyEvent;
10import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
11import schedframe.resources.devices.Device;
12import schedframe.resources.devices.Fan;
13import schedframe.resources.devices.PhysicalResource;
14import schedframe.scheduling.manager.tasks.JobRegistry;
15import schedframe.scheduling.plan.impl.ScheduledTask;
16import example.energy.BaseEnergyEstimationPlugin;
17
18public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
19
20        //private static int OUT_START_ID = 0;
21        //private static int OUT_END_ID = 8;
22       
23        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
24                        PhysicalResource resource) {
25                double powerConsumption = 0;
26                Node node = (Node) resource;
27                for(Processor cpu: node.getProcessors()){
28                        try{
29                                powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
30                        } catch (Exception e){
31                               
32                        }
33                }
34                if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){
35                        //powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
36                        for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
37                                if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
38                                        Fan fan = (Fan) device;
39                                        if(fan.getChilledResources().contains(node.getFullName())){
40                                                if(fan.getPowerInterface().getRecentPowerUsage().getValue() == -1){
41                                                        try {
42                                                                powerConsumption = powerConsumption + fan.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState())/getNumberOfWorkingNodes(fan);
43                                                        } catch (NoSuchFieldException e) {
44                                                                // TODO Auto-generated catch block
45                                                                e.printStackTrace();
46                                                        }
47                                                }else
48                                                        powerConsumption = powerConsumption + fan.getPowerInterface().getRecentPowerUsage().getValue()/getNumberOfWorkingNodes(fan);
49                                        }
50                                }
51                        }
52                }
53
54                return powerConsumption;
55        }
56       
57       
58        private int getNumberOfWorkingNodes(Device device){
59                int quantity = 0;
60                Fan fan = (Fan) device;
61                for(ComputingResource compRes: device.getComputingResource().getChildren()){
62                        Node node = (Node)compRes;
63                        if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) && fan.getChilledResources().contains(node.getFullName())){
64                                quantity++;
65                        }
66                }
67                return quantity;
68        }
69       
70        private double getFactor(Device device){
71                int quantity = 0;
72
73                double factor = 0;;
74                Fan fan = (Fan) device;
75                for(ComputingResource compRes: device.getComputingResource().getChildren()){
76                        Node node = (Node)compRes;
77                        double nrOfComputingProcessor = 0;
78                        double meanCurrFrequency = 0;
79                        double meanMaxFrequency = 0;
80                        if(fan.getChilledResources().contains(node.getFullName()) && node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) ){
81                                quantity++;
82                                for(Processor proc: node.getProcessors()){
83                                        if(proc.getCores().size() != proc.getFreeCores().size()){
84                                                nrOfComputingProcessor++;
85                                        }
86                                        meanCurrFrequency = meanCurrFrequency + proc.getPowerInterface().getFrequency();
87                                        meanMaxFrequency = meanMaxFrequency + proc.getPowerInterface().getLowestPState().getFrequency();
88                                }
89                                meanCurrFrequency = meanCurrFrequency/node.getProcessors().size();
90                                meanMaxFrequency = meanMaxFrequency/node.getProcessors().size();
91                                factor = factor + (meanCurrFrequency /meanMaxFrequency) * (0.5+ nrOfComputingProcessor/node.getProcessors().size());
92                                //System.out.println(meanCurrFrequency + ";" + meanMaxFrequency +  ";" + factor);
93                        }
94                }
95                return factor;
96        }
97}
Note: See TracBrowser for help on using the repository browser.