source: DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ExecutionPhase.java @ 1415

Revision 1415, 2.8 KB checked in by wojtekp, 11 years ago (diff)
RevLine 
[883]1package schedframe.scheduling.tasks.phases;
2
3import java.util.ArrayList;
[1129]4import java.util.HashMap;
[883]5import java.util.List;
[1129]6import java.util.Map;
[883]7
8import org.qcg.broker.schemas.resreqs.ComputingResourceBaseTypeItem;
9import org.qcg.broker.schemas.resreqs.ComputingResourceParameterType;
10import org.qcg.broker.schemas.resreqs.PhaseBehaviourType;
[1207]11import org.qcg.broker.schemas.resreqs.StringParameterType;
12
[883]13import org.qcg.broker.schemas.resreqs.ResourceConsumptionType;
14
[1415]15public class ExecutionPhase {
[883]16
17        protected String id;
[1129]18    protected Map<String, String> referenceHardware;
[1415]19    protected long originDuration;
20    protected long lenght;
21    protected List<PhaseSystemLoad> systemLoad;
[883]22   
[1415]23    public ExecutionPhase(long duration, ComputingResourceBaseTypeItem item[]){
[883]24        this.id = null;
25        this.referenceHardware = null;
[1415]26        this.originDuration = duration;
27        this.systemLoad = new ArrayList<PhaseSystemLoad>();
[883]28        for(ComputingResourceBaseTypeItem compResItem: item){
29                ComputingResourceParameterType hostParameter = compResItem.getHostParameter();
[1415]30                PhaseSystemLoad pb = new PhaseSystemLoad(hostParameter.getName().toString());
31                systemLoad.add(pb);
[883]32        }
[1415]33        this.lenght = duration;
[883]34    }
35   
[1415]36    public ExecutionPhase(ResourceConsumptionType resConsumptionType){
[883]37        this.id = resConsumptionType.getId();
[1129]38        this.referenceHardware = new HashMap<String, String>();
[1415]39        this.originDuration = resConsumptionType.getDuration().toLong() / 1000;
40       
41        double speed = 1;
[1129]42        if(resConsumptionType.getReferenceHardware() != null){
43                for (int i = 0; i < resConsumptionType.getReferenceHardware().getReference().length; i++){
[1207]44                        StringParameterType spt = resConsumptionType.getReferenceHardware().getReference(i);
[1415]45                        this.referenceHardware.put(spt.getName(), spt.getContent());
46                if(spt.getName().equals("cpu_maxfreq")){
47                        speed = new Double(spt.getContent());
48                }
[1129]49                }
50        }
[1415]51        this.systemLoad = new ArrayList<PhaseSystemLoad>();
52        int nrOfThreads = 1;
[883]53        for(PhaseBehaviourType pbt: resConsumptionType.getBehaviour()){
[1415]54                PhaseSystemLoad pb = new PhaseSystemLoad(pbt);
55                this.systemLoad.add(pb);
56                if(pbt.getName().equals("PM_Threads")){
57                        nrOfThreads = new Double(pbt.getParameterTypeChoice().getParameterTypeChoiceItem(0).getParameterValue().getContent()).intValue();
58                }
[883]59        }
[1415]60        this.lenght = (long) (originDuration * nrOfThreads * speed);
[883]61    }
62   
63        public String getId() {
64                return id;
65        }
66
67        public void setId(String id) {
68                this.id = id;
69        }
70
[1129]71        public Map<String, String> getReferenceHardware() {
[883]72                return referenceHardware;
73        }
74
75        public long getDuration() {
[1415]76                return originDuration;
[883]77        }
78
[1415]79        public List<PhaseSystemLoad> getSystemLoad() {
80                return systemLoad;
[883]81        }
82
[1415]83        public long getLenght() {
84                return lenght;
85        }
86
[883]87}
Note: See TracBrowser for help on using the repository browser.