Revision 1423,
1.2 KB
checked in by wojtekp, 11 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Line | |
---|
1 | package example.load; |
---|
2 | |
---|
3 | import schedframe.resources.ResourceStatus; |
---|
4 | import schedframe.resources.computing.Core; |
---|
5 | import schedframe.resources.computing.Processor; |
---|
6 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
7 | import schedframe.resources.devices.PhysicalResource; |
---|
8 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
9 | |
---|
10 | public class ProcessorLoadEstimationPlugin extends BaseLoadEstimationPlugin{ |
---|
11 | |
---|
12 | public double estimateUtlization(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
13 | Processor proc = (Processor) resource; |
---|
14 | double sumCoresLoad = 0; |
---|
15 | if(proc.getStatus().equals(ResourceStatus.BUSY)){ |
---|
16 | sumCoresLoad = 1; |
---|
17 | } else { |
---|
18 | if(proc.getCores().size() > 0){ |
---|
19 | for(Core core: proc.getCores()){ |
---|
20 | if(core.getStatus().equals(ResourceStatus.BUSY)){ |
---|
21 | sumCoresLoad = sumCoresLoad + 1; |
---|
22 | } |
---|
23 | } |
---|
24 | sumCoresLoad = sumCoresLoad / proc.getCores().size(); |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | double processorLoad = 100 * sumCoresLoad; |
---|
29 | double calendarLoad = resource.getLoadInterface().getLoadCalendar().getCurrentLoad(); |
---|
30 | double totalLoad = processorLoad + calendarLoad; |
---|
31 | if (totalLoad > 100) |
---|
32 | return 100; |
---|
33 | else return totalLoad; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.