package test.powerCapping; import org.joda.time.DateTime; import schedframe.resources.StandardResourceType; import schedframe.resources.computing.ComputingResource; import schedframe.resources.computing.Node; import schedframe.resources.computing.Processor; import schedframe.resources.computing.profiles.energy.EnergyEvent; import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; import schedframe.resources.devices.Device; import schedframe.resources.devices.Fan; import schedframe.resources.devices.PhysicalResource; import schedframe.scheduling.manager.tasks.JobRegistry; import schedframe.scheduling.plan.impl.ScheduledTask; import example.energy.BaseEnergyEstimationPlugin; public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { //private static int OUT_START_ID = 0; //private static int OUT_END_ID = 8; public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { double powerConsumption = 0; Node node = (Node) resource; for(Processor cpu: node.getProcessors()){ try{ powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue(); } catch (Exception e){ } } if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){ //powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){ Fan fan = (Fan) device; if(fan.getChilledResources().contains(node.getFullName())){ if(fan.getPowerInterface().getRecentPowerUsage().getValue() == -1){ try { powerConsumption = powerConsumption + fan.getAirThroughputInterface().getPowerConsumption(fan.getAirThroughputInterface().getAirThroughputState())/getNumberOfWorkingNodes(fan); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else powerConsumption = powerConsumption + fan.getPowerInterface().getRecentPowerUsage().getValue()/getNumberOfWorkingNodes(fan); } } } } return powerConsumption; } private int getNumberOfWorkingNodes(Device device){ int quantity = 0; Fan fan = (Fan) device; for(ComputingResource compRes: device.getComputingResource().getChildren()){ Node node = (Node)compRes; if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) && fan.getChilledResources().contains(node.getFullName())){ quantity++; } } return quantity; } private double getFactor(Device device){ int quantity = 0; double factor = 0;; Fan fan = (Fan) device; for(ComputingResource compRes: device.getComputingResource().getChildren()){ Node node = (Node)compRes; double nrOfComputingProcessor = 0; double meanCurrFrequency = 0; double meanMaxFrequency = 0; if(fan.getChilledResources().contains(node.getFullName()) && node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) ){ quantity++; for(Processor proc: node.getProcessors()){ if(proc.getCores().size() != proc.getFreeCores().size()){ nrOfComputingProcessor++; } meanCurrFrequency = meanCurrFrequency + proc.getPowerInterface().getFrequency(); meanMaxFrequency = meanMaxFrequency + proc.getPowerInterface().getLowestPState().getFrequency(); } meanCurrFrequency = meanCurrFrequency/node.getProcessors().size(); meanMaxFrequency = meanMaxFrequency/node.getProcessors().size(); factor = factor + (meanCurrFrequency /meanMaxFrequency) * (0.5+ nrOfComputingProcessor/node.getProcessors().size()); //System.out.println(meanCurrFrequency + ";" + meanMaxFrequency + ";" + factor); } } return factor; } }