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