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

Revision 1286, 2.0 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.ResourceStatus;
4import schedframe.resources.computing.Core;
5import schedframe.resources.computing.Processor;
6import schedframe.resources.computing.profiles.energy.EnergyEvent;
7import schedframe.resources.devices.PhysicalResource;
8import schedframe.scheduling.manager.tasks.JobRegistry;
9import schedframe.scheduling.manager.tasks.JobRegistryImpl;
10import schedframe.scheduling.tasks.phases.PhaseBehaviour;
11import dcworms.schedframe.scheduling.ExecTask;
12
13public class ProcessorLoadEstimationPlugin extends BaseLoadEstimationPlugin{
14
15        @Override
16        public double estimateUtlization(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
17                Processor proc = (Processor) resource;
18                double sumCoresLoad = 0;
19               
20                double nrOfThreadsOnCpu = proc.getCores().size();
21               
22                if(proc.getResourceCharacteristic().getParameters().get("threads") != null){
23                        nrOfThreadsOnCpu = nrOfThreadsOnCpu * Integer.valueOf(proc.getResourceCharacteristic().getParameters().get("threads").get(0).getContent()).intValue();
24                }
25
26                //for(Core core: proc.getCores()){
27                       
28                        //if(core.getStatus().equals(ResourceStatus.BUSY)){
29                                JobRegistry jr = new JobRegistryImpl(proc.getFullName());
30                                for(ExecTask task: jr.getRunningTasks()){
31                                        double cpuUsage = 1 / nrOfThreadsOnCpu;
32                                        double nrOfThreadsOfApplication = 1;
33
34                                        for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){
35                                                if(pb.getResouceName().equals("PM_CPU_Usage")){
36                                                        cpuUsage = pb.getUtilization();
37                                                }
38                                                if(pb.getResouceName().equals("PM_Threads")){
39                                                        nrOfThreadsOfApplication = pb.getUtilization();
40                                                        break;
41                                                }
42                                        }
43                                        sumCoresLoad = sumCoresLoad + cpuUsage;// * (nrOfThreadsOfApplication / nrOfThreadsOnCpu);
44
45                                }
46                //      }
47                //}
48
49                double processorLoad = 100 * sumCoresLoad;     
50                double calendarLoad = resource.getLoadInterface().getLoadCalendar().getCurrentLoad();
51                double totalLoad = processorLoad + calendarLoad;
52                if (totalLoad > 100)
53                        return 100;
54                else return totalLoad;
55        }
56
57
58}
Note: See TracBrowser for help on using the repository browser.