[1501] | 1 | package experiments.e2dc2014; |
---|
[1323] | 2 | |
---|
| 3 | import org.joda.time.DateTime; |
---|
| 4 | |
---|
| 5 | import schedframe.resources.StandardResourceType; |
---|
| 6 | import schedframe.resources.computing.ComputingResource; |
---|
| 7 | import schedframe.resources.computing.Node; |
---|
| 8 | import schedframe.resources.computing.Processor; |
---|
[1420] | 9 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
[1323] | 10 | import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; |
---|
| 11 | import schedframe.resources.devices.Device; |
---|
| 12 | import schedframe.resources.devices.Fan; |
---|
| 13 | import schedframe.resources.devices.PhysicalResource; |
---|
| 14 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
| 15 | import example.energy.BaseEnergyEstimationPlugin; |
---|
| 16 | |
---|
| 17 | public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { |
---|
| 18 | |
---|
| 19 | //private static int OUT_START_ID = 0; |
---|
| 20 | //private static int OUT_END_ID = 8; |
---|
| 21 | |
---|
[1420] | 22 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, |
---|
[1323] | 23 | PhysicalResource resource) { |
---|
| 24 | double powerConsumption = 0; |
---|
| 25 | Node node = (Node) resource; |
---|
| 26 | for(Processor cpu: node.getProcessors()){ |
---|
| 27 | try{ |
---|
| 28 | powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 29 | } catch (Exception e){ |
---|
| 30 | |
---|
| 31 | } |
---|
| 32 | } |
---|
| 33 | if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){ |
---|
| 34 | //powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; |
---|
| 35 | for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ |
---|
| 36 | if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ |
---|
| 37 | Fan fan = (Fan) device; |
---|
| 38 | if(fan.getChilledResources().contains(node.getFullName())){ |
---|
| 39 | if(fan.getPowerInterface().getRecentPowerUsage().getValue() == -1){ |
---|
| 40 | try { |
---|
[1577] | 41 | powerConsumption = powerConsumption + fan.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState()) * (getFactor(fan)/(double)fan.getChilledResources().size())/getNumberOfWorkingNodes(fan); |
---|
[1323] | 42 | } catch (NoSuchFieldException e) { |
---|
| 43 | // TODO Auto-generated catch block |
---|
| 44 | e.printStackTrace(); |
---|
| 45 | } |
---|
| 46 | }else |
---|
| 47 | powerConsumption = powerConsumption + fan.getPowerInterface().getRecentPowerUsage().getValue()/getNumberOfWorkingNodes(fan); |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | return powerConsumption; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | private int getNumberOfWorkingNodes(Device device){ |
---|
| 58 | int quantity = 0; |
---|
| 59 | Fan fan = (Fan) device; |
---|
| 60 | for(ComputingResource compRes: device.getComputingResource().getChildren()){ |
---|
| 61 | Node node = (Node)compRes; |
---|
| 62 | if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) && fan.getChilledResources().contains(node.getFullName())){ |
---|
| 63 | quantity++; |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | return quantity; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | private double getFactor(Device device){ |
---|
| 70 | |
---|
| 71 | double factor = 0;; |
---|
| 72 | Fan fan = (Fan) device; |
---|
| 73 | for(ComputingResource compRes: device.getComputingResource().getChildren()){ |
---|
| 74 | Node node = (Node)compRes; |
---|
| 75 | double nrOfComputingProcessor = 0; |
---|
| 76 | double meanCurrFrequency = 0; |
---|
| 77 | double meanMaxFrequency = 0; |
---|
| 78 | if(fan.getChilledResources().contains(node.getFullName()) && node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) ){ |
---|
| 79 | for(Processor proc: node.getProcessors()){ |
---|
| 80 | if(proc.getCores().size() != proc.getFreeCores().size()){ |
---|
| 81 | nrOfComputingProcessor++; |
---|
[1577] | 82 | meanCurrFrequency = meanCurrFrequency + proc.getPowerInterface().getFrequency(); |
---|
| 83 | meanMaxFrequency = meanMaxFrequency + proc.getPowerInterface().getLowestPState().getFrequency(); |
---|
| 84 | } else { |
---|
| 85 | meanCurrFrequency = meanCurrFrequency + proc.getPowerInterface().getHighestPState().getFrequency(); |
---|
| 86 | meanMaxFrequency = meanMaxFrequency + proc.getPowerInterface().getLowestPState().getFrequency(); |
---|
[1323] | 87 | } |
---|
| 88 | } |
---|
| 89 | meanCurrFrequency = meanCurrFrequency/node.getProcessors().size(); |
---|
| 90 | meanMaxFrequency = meanMaxFrequency/node.getProcessors().size(); |
---|
[1577] | 91 | factor = factor + (meanCurrFrequency/meanMaxFrequency) * (0.5 + nrOfComputingProcessor/node.getProcessors().size()); |
---|
[1323] | 92 | } |
---|
| 93 | } |
---|
| 94 | return factor; |
---|
| 95 | } |
---|
| 96 | } |
---|