[477] | 1 | package example.energy; |
---|
| 2 | |
---|
[1555] | 3 | import gridsim.dcworms.DCWormsTags; |
---|
| 4 | |
---|
| 5 | |
---|
[1247] | 6 | import schedframe.resources.computing.Node; |
---|
[477] | 7 | import schedframe.resources.computing.Processor; |
---|
[1415] | 8 | import schedframe.resources.computing.profiles.energy.ResourceEvent; |
---|
[1555] | 9 | import schedframe.resources.computing.profiles.energy.power.plugin.EnergyPluginConfiguration; |
---|
[1207] | 10 | import schedframe.resources.devices.Device; |
---|
| 11 | import schedframe.resources.devices.PhysicalResource; |
---|
[477] | 12 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
[1555] | 13 | import simulator.DataCenterWorkloadSimulator; |
---|
[477] | 14 | |
---|
[1207] | 15 | public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { |
---|
[477] | 16 | |
---|
[1415] | 17 | public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, |
---|
[1207] | 18 | PhysicalResource resource) { |
---|
[532] | 19 | double powerConsumption = 0; |
---|
[1555] | 20 | EnergyPluginConfiguration epConf = (EnergyPluginConfiguration) getConfiguration(); |
---|
[1247] | 21 | Node node = (Node) resource; |
---|
[477] | 22 | for(Processor cpu: node.getProcessors()){ |
---|
| 23 | try{ |
---|
[532] | 24 | powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
[497] | 25 | } catch (Exception e){ |
---|
| 26 | |
---|
[477] | 27 | } |
---|
| 28 | } |
---|
| 29 | try { |
---|
[532] | 30 | powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); |
---|
[1207] | 31 | for(Device dev: node.getResourceCharacteristic().getDevices()){ |
---|
[1555] | 32 | if(dev.getPowerInterface().getRecentPowerUsage().getValue() != -1) |
---|
| 33 | powerConsumption = powerConsumption + dev.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
[1207] | 34 | } |
---|
[477] | 35 | } catch (NoSuchFieldException e) { |
---|
| 36 | } |
---|
| 37 | |
---|
[1555] | 38 | if(epConf.getPowerCapLevel() != -1 && powerConsumption > epConf.getPowerCapLevel()){ |
---|
| 39 | DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_POWER_LIMIT_EXCEEDED, node.getFullName()); |
---|
| 40 | } |
---|
[532] | 41 | return powerConsumption; |
---|
[477] | 42 | } |
---|
| 43 | |
---|
| 44 | } |
---|