source: DCWoRMS/branches/coolemall/src/example/energy/ProcessorEnergyEstimationPlugin.java @ 1555

Revision 1555, 1.8 KB checked in by wojtekp, 9 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package example.energy;
2
3import schedframe.resources.ResourceStatus;
4import schedframe.resources.computing.Processor;
5import schedframe.resources.computing.profiles.energy.ResourceEvent;
6import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
7import schedframe.resources.devices.PhysicalResource;
8import schedframe.scheduling.manager.tasks.JobRegistry;
9
10public class ProcessorEnergyEstimationPlugin extends BaseEnergyEstimationPlugin  {
11
12        public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
13                        PhysicalResource resource) {
14                double powerConsumption = 0;
15
16                Processor cpu = (Processor)resource;
17                if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
18                        powerConsumption = 0;
19                else {
20                        if(resource.getStatus() == ResourceStatus.BUSY){
21                                try {
22
23                                        powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState());
24                                } catch (NoSuchFieldException e) {
25                                        try {
26                                                if(cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState()) != -1)
27                                                        powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState());
28                                        } catch (NoSuchFieldException e1) {
29                                                powerConsumption = 10;
30                                        }
31                                }
32                        } else{
33                                try {
34                                        if(cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState()) != -1)
35                                                powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState());
36                                } catch (NoSuchFieldException e1) {
37                                        powerConsumption = 0;
38                                }
39                        }
40                       
41                }
42                if(cpu.getLoadInterface().getRecentUtilization().getValue() != 0.0){
43                        powerConsumption = powerConsumption * cpu.getLoadInterface().getRecentUtilization().getValue()/100;                     
44                }
45                return powerConsumption;
46        }
47
48}
Note: See TracBrowser for help on using the repository browser.