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
RevLine 
[477]1package example.energy;
2
[580]3import schedframe.resources.ResourceStatus;
[477]4import schedframe.resources.computing.Processor;
[1415]5import schedframe.resources.computing.profiles.energy.ResourceEvent;
[477]6import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
[1207]7import schedframe.resources.devices.PhysicalResource;
[477]8import schedframe.scheduling.manager.tasks.JobRegistry;
9
[901]10public class ProcessorEnergyEstimationPlugin extends BaseEnergyEstimationPlugin  {
[477]11
[1415]12        public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
[1207]13                        PhysicalResource resource) {
[1555]14                double powerConsumption = 0;
[1207]15
[477]16                Processor cpu = (Processor)resource;
[497]17                if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
[532]18                        powerConsumption = 0;
[497]19                else {
[883]20                        if(resource.getStatus() == ResourceStatus.BUSY){
21                                try {
22
[580]23                                        powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState());
[883]24                                } catch (NoSuchFieldException e) {
25                                        try {
[1555]26                                                if(cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState()) != -1)
27                                                        powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState());
[883]28                                        } catch (NoSuchFieldException e1) {
29                                                powerConsumption = 10;
30                                        }
[580]31                                }
[883]32                        } else{
[497]33                                try {
[1555]34                                        if(cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState()) != -1)
35                                                powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState());
36                                } catch (NoSuchFieldException e1) {
37                                        powerConsumption = 0;
[497]38                                }
[477]39                        }
[883]40                       
[497]41                }
[1415]42                if(cpu.getLoadInterface().getRecentUtilization().getValue() != 0.0){
43                        powerConsumption = powerConsumption * cpu.getLoadInterface().getRecentUtilization().getValue()/100;                     
44                }
[532]45                return powerConsumption;
[477]46        }
47
48}
Note: See TracBrowser for help on using the repository browser.