1 | package schedframe.resources.computing.profiles.load.ui; |
---|
2 | |
---|
3 | import java.util.List; |
---|
4 | |
---|
5 | import org.joda.time.DateTimeUtils; |
---|
6 | |
---|
7 | import schedframe.resources.computing.profiles.energy.MeasurementHistory; |
---|
8 | import schedframe.resources.computing.profiles.load.LoadProfile; |
---|
9 | import schedframe.resources.computing.profiles.load.ResourceLoadCalendar; |
---|
10 | import schedframe.resources.devices.PhysicalResource; |
---|
11 | |
---|
12 | public class ComputingResourceLoadInterface implements LoadInterface{ |
---|
13 | |
---|
14 | protected PhysicalResource resource; |
---|
15 | protected LoadProfile loadProfile; |
---|
16 | |
---|
17 | public ComputingResourceLoadInterface(PhysicalResource resource, LoadProfile loadProfile){ |
---|
18 | this.resource = resource; |
---|
19 | this.loadProfile = loadProfile; |
---|
20 | } |
---|
21 | |
---|
22 | public MeasurementHistory getRecentUtilization() { |
---|
23 | MeasurementHistory load = null; |
---|
24 | int lastIdx = getUtilizationHistory().size() - 1; |
---|
25 | if(lastIdx >= 0) |
---|
26 | load = getUtilizationHistory().get(lastIdx); |
---|
27 | else { |
---|
28 | load = new MeasurementHistory(DateTimeUtils.currentTimeMillis(), 0); |
---|
29 | } |
---|
30 | return load; |
---|
31 | } |
---|
32 | |
---|
33 | public List<MeasurementHistory> getUtilizationHistory(){ |
---|
34 | return loadProfile.getUtilizationHistory(); |
---|
35 | } |
---|
36 | |
---|
37 | public ResourceLoadCalendar getLoadCalendar() { |
---|
38 | if(loadProfile == null) { |
---|
39 | return new ResourceLoadCalendar(); |
---|
40 | } |
---|
41 | return loadProfile.getLoadCalendar(); |
---|
42 | } |
---|
43 | } |
---|