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

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