1 | package example.energy; |
---|
2 | |
---|
3 | import java.util.Properties; |
---|
4 | |
---|
5 | import schedframe.resources.profile.PowerUsage; |
---|
6 | import test.rewolucja.energy.EnergyEvent; |
---|
7 | import test.rewolucja.energy.plugin.EnergyEstimationPluginInterface; |
---|
8 | import test.rewolucja.resources.physical.base.ComputingResource; |
---|
9 | import test.rewolucja.resources.physical.implementation.CPU; |
---|
10 | import test.rewolucja.resources.physical.implementation.ComputingNode; |
---|
11 | import test.rewolucja.resources.physical.implementation.DataCenter; |
---|
12 | import test.rewolucja.scheduling.JobRegistryInterface; |
---|
13 | import test.rewolucja.scheduling.PluginConfiguration; |
---|
14 | |
---|
15 | public class DataCenterEnergyEstimationPlugin implements EnergyEstimationPluginInterface { |
---|
16 | |
---|
17 | @Override |
---|
18 | public double estimatePowerConsumption(EnergyEvent event, JobRegistryInterface jobRegistry, |
---|
19 | ComputingResource resource) { |
---|
20 | double power = 0; |
---|
21 | for(ComputingResource child:resource.getChildren()){ |
---|
22 | ComputingNode node = (ComputingNode)child; |
---|
23 | PowerUsage powerUsage = node.getPowerInterface().getRecentPowerUsage(); |
---|
24 | power += (powerUsage == null ? 0 : powerUsage.getValue()); |
---|
25 | } |
---|
26 | //power += 100; |
---|
27 | if(power < 140){ |
---|
28 | for(ComputingResource child:resource.getChildren()){ |
---|
29 | ComputingNode node = (ComputingNode)child; |
---|
30 | for(CPU cpu:node.getProcessors()){ |
---|
31 | //cpu.getPowerProfile().setFrequency(2000); |
---|
32 | } |
---|
33 | } |
---|
34 | } |
---|
35 | //System.out.println( new DateTime() + "ENERGY CONSUMPT BY: " + resMan.getResourceName() +" IS: " + power); |
---|
36 | return power; |
---|
37 | } |
---|
38 | |
---|
39 | @Override |
---|
40 | public String getName() { |
---|
41 | // TODO Auto-generated method stub |
---|
42 | return null; |
---|
43 | } |
---|
44 | |
---|
45 | @Override |
---|
46 | public void init(Properties properties) { |
---|
47 | // TODO Auto-generated method stub |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | @Override |
---|
52 | public PluginConfiguration getConfiguration() { |
---|
53 | // TODO Auto-generated method stub |
---|
54 | return null; |
---|
55 | } |
---|
56 | |
---|
57 | @Override |
---|
58 | public double estimateEnergyDissipation(EnergyEvent event, JobRegistryInterface jobRegistry, ComputingResource resourceManager) { |
---|
59 | // TODO Auto-generated method stub |
---|
60 | return 0; |
---|
61 | } |
---|
62 | |
---|
63 | @Override |
---|
64 | public double estimateTemperature(EnergyEvent event, JobRegistryInterface jobRegistry, ComputingResource resourceManager) { |
---|
65 | // TODO Auto-generated method stub |
---|
66 | return 0; |
---|
67 | } |
---|
68 | |
---|
69 | } |
---|