source: DCWoRMS/branches/coolemall/src/example/load/ProcessorLoadEstimationPlugin.java @ 1299

Revision 1299, 1.6 KB checked in by wojtekp, 11 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package example.load;
2
3import schedframe.resources.computing.Processor;
4import schedframe.resources.computing.profiles.energy.EnergyEvent;
5import schedframe.resources.devices.PhysicalResource;
6import schedframe.scheduling.manager.tasks.JobRegistry;
7import schedframe.scheduling.manager.tasks.JobRegistryImpl;
8import schedframe.scheduling.tasks.phases.PhaseBehaviour;
9import dcworms.schedframe.scheduling.ExecTask;
10
11public class ProcessorLoadEstimationPlugin extends BaseLoadEstimationPlugin{
12
13        public double estimateUtlization(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
14                Processor proc = (Processor) resource;
15                double sumCoresLoad = 0;
16               
17                double nrOfThreadsOnCpu = proc.getCores().size();
18               
19                if(proc.getResourceCharacteristic().getParameters().get("threads") != null){
20                        nrOfThreadsOnCpu = nrOfThreadsOnCpu * Integer.valueOf(proc.getResourceCharacteristic().getParameters().get("threads").get(0).getContent()).intValue();
21                }
22
23
24                JobRegistry jr = new JobRegistryImpl(proc.getFullName());
25                for(ExecTask task: jr.getRunningTasks()){
26                        double cpuUsage = 1 / nrOfThreadsOnCpu;
27
28                        for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){
29                                if(pb.getResouceName().equals("PM_CPU_Usage")){
30                                        cpuUsage = pb.getUtilization();
31                                }
32                        }
33                        sumCoresLoad = sumCoresLoad + cpuUsage;
34
35                }
36
37
38                double processorLoad = 100 * sumCoresLoad;     
39                double calendarLoad = resource.getLoadInterface().getLoadCalendar().getCurrentLoad();
40                double totalLoad = processorLoad + calendarLoad;
41                if (totalLoad > 100)
42                        return 100;
43                else return totalLoad;
44        }
45
46
47}
Note: See TracBrowser for help on using the repository browser.