[477] | 1 | package schedframe.scheduling.queue; |
---|
| 2 | |
---|
[481] | 3 | import gridsim.gssim.DCWormsTags; |
---|
[477] | 4 | import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; |
---|
| 5 | |
---|
| 6 | import org.joda.time.DateTime; |
---|
| 7 | |
---|
[481] | 8 | import schedframe.scheduling.tasks.TaskInterface; |
---|
[477] | 9 | |
---|
[481] | 10 | public class TaskQueue extends AbstractStatsSupportingQueue<TaskInterface<?>> implements Queue<TaskInterface<?>>{ |
---|
[477] | 11 | |
---|
| 12 | private static final long serialVersionUID = 6576299222910508209L; |
---|
| 13 | |
---|
| 14 | protected String name; |
---|
| 15 | protected int priority; |
---|
| 16 | protected boolean supportReservation; |
---|
| 17 | |
---|
| 18 | public TaskQueue (boolean supportReservation){ |
---|
[481] | 19 | this.name = "Queue"; |
---|
| 20 | this.priority = 0; |
---|
[477] | 21 | this.supportReservation = supportReservation; |
---|
| 22 | } |
---|
| 23 | |
---|
[481] | 24 | public boolean add(TaskInterface<?> task){ |
---|
[477] | 25 | try { |
---|
[481] | 26 | task.setStatus(DCWormsTags.QUEUED); |
---|
[477] | 27 | } catch(Exception e){ |
---|
| 28 | throw new RuntimeException(e); |
---|
| 29 | } |
---|
[481] | 30 | return super.add(task); |
---|
[477] | 31 | } |
---|
| 32 | |
---|
[481] | 33 | public void add(int pos, TaskInterface<?> task){ |
---|
[477] | 34 | try { |
---|
[481] | 35 | task.setStatus(DCWormsTags.QUEUED); |
---|
[477] | 36 | } catch(Exception e){ |
---|
| 37 | throw new RuntimeException(e); |
---|
| 38 | } |
---|
[481] | 39 | super.add(pos, task); |
---|
[477] | 40 | } |
---|
| 41 | |
---|
| 42 | public DateTime getArrivalTime(int pos) throws IndexOutOfBoundsException { |
---|
[481] | 43 | return get(pos).getSubmissionTimeToBroker(); |
---|
[477] | 44 | } |
---|
| 45 | |
---|
| 46 | public String getName() { |
---|
| 47 | return name; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | public int getPriority() { |
---|
| 51 | return priority; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | public void setName(String name) { |
---|
| 55 | this.name = name; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | public void setPriority(int priority) { |
---|
| 59 | this.priority = priority; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | public boolean supportReservations() { |
---|
| 63 | return supportReservation; |
---|
| 64 | } |
---|
| 65 | } |
---|