source: DCWoRMS/trunk/src/schedframe/scheduling/queue/TaskQueue.java @ 477

Revision 477, 2.0 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.scheduling.queue;
2
3import gridsim.Gridlet;
4import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue;
5
6import org.joda.time.DateTime;
7
8import schedframe.scheduling.tasks.WorkloadUnit;
9
10public class TaskQueue extends AbstractStatsSupportingQueue<WorkloadUnit<?>> implements Queue<WorkloadUnit<?>>{
11
12
13        private static final long serialVersionUID = 6576299222910508209L;
14
15        protected String name;
16        protected int priority;
17        protected boolean supportReservation;
18       
19       
20        public TaskQueue (boolean supportReservation){
21                name = "Queue";
22                priority = 0;
23                this.supportReservation = supportReservation;
24
25        }
26       
27        public boolean add(WorkloadUnit<?> wu){
28                try {
29                        wu.setStatus(Gridlet.QUEUED);
30                } catch(Exception e){
31                        throw new RuntimeException(e);
32                }
33                //updateStats();
34                return super.add(wu);
35        }
36       
37        public void add(int pos, WorkloadUnit<?> wu){
38                try {
39                        wu.setStatus(Gridlet.QUEUED);
40                } catch(Exception e){
41                        throw new RuntimeException(e);
42                }
43                //updateStats();
44                 super.add(pos, wu);
45        }
46       
47        public DateTime getArrivalTime(int pos) throws IndexOutOfBoundsException {
48                //return get(pos).getSubmissionTimeToBroker();
49                return null;
50        }
51
52        public String getName() {
53                return name;
54        }
55
56        public int getPriority() {
57                return priority;
58        }
59
60        public void setName(String name) {
61                this.name = name;
62        }
63
64        public void setPriority(int priority) {
65                this.priority = priority;
66        }
67
68        public boolean supportReservations() {
69                return supportReservation;
70        }
71       
72       
73        /*public boolean contains (WorkloadUnitInterface<?> wu) {
74                for(int i = 0; i< size();i++){
75                        try {
76                                if(get(i).getId().equals(wu.getId()))
77                                        return true;
78                        } catch (NoSuchFieldException e) {
79                                return false;
80                        }
81                }
82                return false;
83        }
84       
85        public boolean remove (WorkloadUnitInterface<?> wu) {
86                boolean found = false;
87                int index = 0;
88                for(int i = 0; i< size() && !found;i++){
89                        try {
90                                if(get(i).getId().equals(wu.getId()))
91                                {
92                                        found = true;
93                                        index = i;
94                                }
95                               
96                        } catch (NoSuchFieldException e) {
97                                return false;
98                        }
99                }
100                remove(index);
101                return true;
102        }*/
103}
Note: See TracBrowser for help on using the repository browser.