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