[477] | 1 | package schedframe.scheduling.queue; |
---|
| 2 | |
---|
| 3 | import gridsim.Gridlet; |
---|
| 4 | import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; |
---|
| 5 | |
---|
| 6 | import org.joda.time.DateTime; |
---|
| 7 | |
---|
| 8 | import schedframe.scheduling.tasks.WorkloadUnit; |
---|
| 9 | |
---|
[478] | 10 | public class TaskQueue extends AbstractStatsSupportingQueue<WorkloadUnit> implements Queue<WorkloadUnit>{ |
---|
[477] | 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 | |
---|
[478] | 27 | public boolean add(WorkloadUnit wu){ |
---|
[477] | 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 | |
---|
[478] | 37 | public void add(int pos, WorkloadUnit wu){ |
---|
[477] | 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 | } |
---|