source: DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java @ 1207

Revision 1207, 2.3 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 ResourceConsumption {
16
17        protected String id;
18    protected Map<String, String> referenceHardware;
19    protected long duration;
20    protected List<PhaseBehaviour> phaseBehaviourList;
21   
22    public ResourceConsumption(long duration, ComputingResourceBaseTypeItem item[]){
23        this.id = null;
24        this.referenceHardware = null;
25        this.duration = duration;
26        this.phaseBehaviourList = new ArrayList<PhaseBehaviour>();
27        for(ComputingResourceBaseTypeItem compResItem: item){
28                ComputingResourceParameterType hostParameter = compResItem.getHostParameter();
29                PhaseBehaviour pb = new PhaseBehaviour(hostParameter.getName().toString());
30                phaseBehaviourList.add(pb);
31        }
32    }
33   
34    public ResourceConsumption(ResourceConsumptionType resConsumptionType){
35        this.id = resConsumptionType.getId();
36        this.referenceHardware = new HashMap<String, String>();
37        if(resConsumptionType.getReferenceHardware() != null){
38                for (int i = 0; i < resConsumptionType.getReferenceHardware().getReference().length; i++){
39                        StringParameterType spt = resConsumptionType.getReferenceHardware().getReference(i);
40                        referenceHardware.put(spt.getName(), spt.getContent());
41                }
42        }
43        this.duration = resConsumptionType.getDuration().toLong()/1000;
44        this.phaseBehaviourList = new ArrayList<PhaseBehaviour>();
45        for(PhaseBehaviourType pbt: resConsumptionType.getBehaviour()){
46                PhaseBehaviour pb = new PhaseBehaviour(pbt);
47                phaseBehaviourList.add(pb);
48        }
49    }
50   
51        public String getId() {
52                return id;
53        }
54
55        public void setId(String id) {
56                this.id = id;
57        }
58
59        public Map<String, String> getReferenceHardware() {
60                return referenceHardware;
61        }
62
63        public long getDuration() {
64                return duration;
65        }
66
67        public List<PhaseBehaviour> getBehaviourList() {
68                return phaseBehaviourList;
69        }
70
71}
Note: See TracBrowser for help on using the repository browser.