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