source: DCWoRMS/branches/coolemall/src/experiments/e2dc2014/NodeEnergyEstimationPlugin.java @ 1501

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