source: DCWoRMS/branches/coolemall/src/experiments/simpat2014/models/article/NodeGroupEnergyEstimationPluginPowerCapping.java @ 1500

Revision 1500, 3.8 KB checked in by wojtekp, 10 years ago (diff)
RevLine 
[1500]1package experiments.simpat2014.models.article;
[1469]2
3import schedframe.resources.StandardResourceType;
4import schedframe.resources.computing.ComputingResource;
5import schedframe.resources.computing.Node;
6import schedframe.resources.computing.Processor;
7import schedframe.resources.computing.coolemall.NodeGroup;
8import schedframe.resources.computing.profiles.energy.ResourceEvent;
9import schedframe.resources.computing.profiles.energy.power.PState;
10import schedframe.resources.devices.Device;
11import schedframe.resources.devices.Fan;
12import schedframe.resources.devices.PhysicalResource;
13import schedframe.scheduling.manager.tasks.JobRegistry;
14import simulator.DataCenterWorkloadSimulator;
15import example.energy.BaseEnergyEstimationPlugin;
[1500]16import experiments.simpat2014.EnvironmentConditions;
[1469]17import gridsim.dcworms.DCWormsTags;
18
19public class NodeGroupEnergyEstimationPluginPowerCapping extends BaseEnergyEstimationPlugin{
20
21        double powerCapLevel = -1;
22        double powerUpgradeLevel = -1;
23       
24        public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
25                        PhysicalResource resource) {
26               
27
28                loadThresholds((ComputingResource)resource);
29               
30                double powerConsumption = 0;
31                NodeGroup nodeGroup = (NodeGroup)resource;
32                for(Node node: nodeGroup.getNodes()){
33                        try{
34                                powerConsumption = powerConsumption + node.getPowerInterface().getRecentPowerUsage().getValue();
35                                powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
36
37                        } catch (Exception e){
38                        }
39                }
40
41                for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
42                        if(device.getType().equals(StandardResourceType.Fan)){
43                                Fan fan = (Fan) device;
44                                powerConsumption = powerConsumption + fan.getPowerInterface().getRecentPowerUsage().getValue();
45                        }
46                }
47               
48                if(powerCapLevel!= -1 && powerConsumption > powerCapLevel){
49                        DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_POWER_LIMIT_EXCEEDED, resource.getFullName());
50                }
51                else if(powerUpgradeLevel != -1 && powerConsumption < powerUpgradeLevel){
52                        DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_POWER_LIMIT_EXCEEDED, resource.getFullName());
53                }
54               
55                return powerConsumption;
56        }
57
58        private void loadThresholds(ComputingResource compResource){
59               
60                NodeGroup ng = (NodeGroup) compResource;
61                double pcLevel = 0;
62                double puLevel = 0;
63                for(Processor proc: ng.getProcessors()){
64                        PState highestPState =  proc.getPowerInterface().getHighestPState();
65                        PState secondHighestPState =  proc.getPowerInterface().getLowestPState();
66                        for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
67                                PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
68                                if(pState.getFrequency()  < secondHighestPState.getFrequency() && pState.getFrequency() > highestPState.getFrequency()){
69                                        secondHighestPState = pState;
70                                }
71                        }
72                        double maxMinPowerUsage = 0;
73                        double powerUsage = 0;
74                       
75                        for(Double load: highestPState.getLoadPowerUsage().keySet()){
76                                powerUsage = highestPState.getLoadPowerUsage().get(load);
77                                if(powerUsage > maxMinPowerUsage){
78                                        maxMinPowerUsage= powerUsage;                           
79                                }
80                        }
81                        pcLevel = pcLevel + maxMinPowerUsage;
82                       
83                        maxMinPowerUsage = 0;
84                        powerUsage = 0;
85                       
86                        for(Double load: secondHighestPState.getLoadPowerUsage().keySet()){
87                                powerUsage = secondHighestPState.getLoadPowerUsage().get(load);
88                                if(powerUsage > maxMinPowerUsage){
89                                        maxMinPowerUsage= powerUsage;                           
90                                }
91                        }
92                        puLevel = puLevel + maxMinPowerUsage;
93                       
94                }
95
96                puLevel = (pcLevel * pcLevel / puLevel);
97
98                //powerCapLevel = pcLevel;
99                //powerUpgradeLevel = puLevel;
100               
101                powerCapLevel = EnvironmentConditions.powerCapLevel;
102                powerUpgradeLevel = EnvironmentConditions.powerUpgradeLevel;
103        }
104}
Note: See TracBrowser for help on using the repository browser.