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