Revision 241,
1.3 KB
checked in by piontek, 13 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Rev | Line | |
---|
[104] | 1 | package example.energy; |
---|
| 2 | |
---|
[241] | 3 | import gssim.schedframe.scheduling.ExecTaskInterface; |
---|
| 4 | |
---|
| 5 | import java.util.List; |
---|
[104] | 6 | import java.util.Properties; |
---|
| 7 | |
---|
| 8 | import schedframe.resources.PowerState; |
---|
| 9 | import test.rewolucja.energy.EnergyEvent; |
---|
| 10 | import test.rewolucja.resources.ResourceStatus; |
---|
| 11 | import test.rewolucja.resources.physical.base.ComputingResource; |
---|
[206] | 12 | import test.rewolucja.resources.physical.implementation.Processor; |
---|
[104] | 13 | import test.rewolucja.scheduling.JobRegistryInterface; |
---|
| 14 | |
---|
| 15 | public class CPUEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { |
---|
| 16 | |
---|
| 17 | @Override |
---|
| 18 | public double estimatePowerConsumption(EnergyEvent event, JobRegistryInterface jobRegistry, |
---|
| 19 | ComputingResource resource) { |
---|
[206] | 20 | Processor cpu = (Processor)resource; |
---|
[241] | 21 | |
---|
[104] | 22 | if(resource.getPowerInterface().getPowerState() == PowerState.OFF) |
---|
| 23 | return 0; |
---|
[241] | 24 | |
---|
| 25 | double factor = 1.3; |
---|
| 26 | |
---|
[104] | 27 | if(resource.getStatus() == ResourceStatus.BUSY) |
---|
[241] | 28 | { |
---|
| 29 | List<ExecTaskInterface> tasks = jobRegistry.getRunningTasks(); |
---|
| 30 | int type = Integer.parseInt( tasks.get(0).getJobId()); |
---|
| 31 | |
---|
| 32 | switch( type % 4) |
---|
| 33 | { |
---|
| 34 | default: factor = 1.3; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | return cpu.getPowerInterface().getPState().getPower() * factor; |
---|
| 38 | } |
---|
[104] | 39 | else |
---|
[241] | 40 | return cpu.getPowerInterface().getPState().getPower(); |
---|
[104] | 41 | } |
---|
| 42 | |
---|
| 43 | public String getName() { |
---|
[151] | 44 | return getClass().getName(); |
---|
[104] | 45 | } |
---|
| 46 | |
---|
| 47 | public void init(Properties properties) { |
---|
| 48 | // TODO Auto-generated method stub |
---|
| 49 | |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.