1 | package example.energy; |
---|
2 | |
---|
3 | import schedframe.Parameters; |
---|
4 | import schedframe.PluginConfiguration; |
---|
5 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
6 | import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; |
---|
7 | import schedframe.resources.computing.profiles.energy.power.plugin.EnergyPluginConfiguration; |
---|
8 | import schedframe.resources.devices.PhysicalResource; |
---|
9 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
10 | import schemas.StringValueWithUnit; |
---|
11 | |
---|
12 | public abstract class BaseEnergyEstimationPlugin implements EnergyEstimationPlugin { |
---|
13 | |
---|
14 | EnergyPluginConfiguration plugConf; |
---|
15 | |
---|
16 | @Override |
---|
17 | public PluginConfiguration getConfiguration() { |
---|
18 | return plugConf; |
---|
19 | } |
---|
20 | |
---|
21 | @Override |
---|
22 | public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
23 | throw new RuntimeException("Not implemented."); |
---|
24 | } |
---|
25 | |
---|
26 | @Override |
---|
27 | public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
28 | throw new RuntimeException("Not implemented."); |
---|
29 | } |
---|
30 | |
---|
31 | public void init(Parameters parameters) { |
---|
32 | plugConf = new EnergyPluginConfiguration(); |
---|
33 | try{ |
---|
34 | StringValueWithUnit powerCapLevel = parameters.get("powerCapLevel").get(0); |
---|
35 | plugConf.setPowerCapLevel(Double.valueOf(powerCapLevel.getContent()).doubleValue()); |
---|
36 | } catch(Exception e){ |
---|
37 | plugConf.setPowerCapLevel(-1); |
---|
38 | } |
---|
39 | try{ |
---|
40 | StringValueWithUnit powerFloorLevel = parameters.get("powerFloorLevel").get(0); |
---|
41 | plugConf.setPowerFloorLevel(Double.valueOf(powerFloorLevel.getContent()).doubleValue()); |
---|
42 | } catch(Exception e){ |
---|
43 | plugConf.setPowerFloorLevel(-1); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | public String getName() { |
---|
48 | return getClass().getName(); |
---|
49 | } |
---|
50 | } |
---|