source: DCWoRMS/branches/coolemall/src/test/drs_tst/recs/plugins/energy/AmdNodeEEP.java @ 1420

Revision 1420, 1.7 KB checked in by wojtekp, 11 years ago (diff)
Line 
1package test.drs_tst.recs.plugins.energy;
2
3import java.io.FileNotFoundException;
4import java.io.IOException;
5
6import schedframe.resources.computing.Node;
7import schedframe.resources.computing.Processor;
8import schedframe.resources.computing.profiles.energy.ResourceEvent;
9import schedframe.resources.devices.PhysicalResource;
10import schedframe.scheduling.manager.tasks.JobRegistry;
11import test.drs_tst.recs.utils.appprofiles.ApplicationProfileBase;
12import test.drs_tst.recs.utils.appprofiles.ProfileGetter;
13
14public class AmdNodeEEP extends RecsNodeBaseEEP {
15
16        public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
17                        PhysicalResource resource) {
18                double powerConsumption = 0;
19               
20                Node node = (Node) resource;
21                try {
22                        if(jobRegistry.getRunningTasks().size() > 0) {
23                                powerConsumption = powerConsumption + getMeasuredPower(createQuery(jobRegistry.getRunningTasks().get(0)));
24                        }
25                        else {
26                                for(Processor cpu: node.getProcessors()){
27                                        try{
28                                                //powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
29                                        } catch (Exception e){
30                                               
31                                        }
32                                }
33                                try {
34                                        powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
35                                } catch (NoSuchFieldException e) {
36                                }
37                        }
38                } catch (FileNotFoundException e) {
39                        // TODO Auto-generated catch block
40                        e.printStackTrace();
41                } catch (IOException e) {
42                        // TODO Auto-generated catch block
43                        e.printStackTrace();
44                }
45                return powerConsumption;
46        }
47       
48        protected ApplicationProfileBase getProfile(String name){
49                ApplicationProfileBase profile = ProfileGetter.getProfileWithName(name);
50                profile.setGetDefault(true);
51                return profile;
52        }
53
54}
Note: See TracBrowser for help on using the repository browser.