1 | package test.thermal.recs.plugins.energy; |
---|
2 | |
---|
3 | import java.io.FileNotFoundException; |
---|
4 | import java.io.IOException; |
---|
5 | |
---|
6 | import schedframe.resources.computing.Node; |
---|
7 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
8 | import schedframe.resources.devices.PhysicalResource; |
---|
9 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
10 | |
---|
11 | public class RecsNodeEEP extends RecsNodeBaseEEP { |
---|
12 | |
---|
13 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
14 | double powerConsumption = 0; |
---|
15 | Node node = (Node) resource; |
---|
16 | |
---|
17 | try { |
---|
18 | if(jobRegistry.getRunningTasks().size() > 0) { |
---|
19 | powerConsumption = powerConsumption + getMeasuredPower(createQuery(jobRegistry.getRunningTasks().get(0))); |
---|
20 | } |
---|
21 | else { |
---|
22 | try { |
---|
23 | powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); |
---|
24 | } catch (NoSuchFieldException e) { |
---|
25 | } |
---|
26 | } |
---|
27 | } catch (FileNotFoundException e) { |
---|
28 | // TODO Auto-generated catch block |
---|
29 | e.printStackTrace(); |
---|
30 | } catch (IOException e) { |
---|
31 | // TODO Auto-generated catch block |
---|
32 | e.printStackTrace(); |
---|
33 | } |
---|
34 | |
---|
35 | return powerConsumption; |
---|
36 | } |
---|
37 | |
---|
38 | public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { |
---|
39 | |
---|
40 | double power1 = 0; |
---|
41 | double power2 = 0; |
---|
42 | |
---|
43 | Integer resId = Integer.parseInt(resource.getName().split("_")[1]); |
---|
44 | Node node = (Node)resource; |
---|
45 | //we estimate outlet temperature (related to the temperature of the nodes placed in outlet row) |
---|
46 | for(PhysicalResource compResource: node.getParent().getChildren()){ |
---|
47 | Integer id = Integer.parseInt(compResource.getName().split("_")[1]); |
---|
48 | //we take into account the power of nodes placed "behind" the given nodes |
---|
49 | if(id - resId == 9){ |
---|
50 | power1 = compResource.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
51 | power2 = resource.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
52 | }else if(id - resId == -9){ |
---|
53 | power1 = resource.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
54 | power2 = compResource.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | return ThermalConstants.calculateOutletTemp(power1, power2); |
---|
59 | } |
---|
60 | |
---|
61 | } |
---|