package schedframe.scheduling.queue; import gridsim.dcworms.DCWormsTags; import org.joda.time.DateTime; import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; import schedframe.scheduling.tasks.TaskInterface; public class TaskQueue extends AbstractStatsSupportingQueue> implements Queue>{ private static final long serialVersionUID = 6576299222910508209L; protected String name; protected int priority; protected boolean supportReservation; public TaskQueue (boolean supportReservation){ this.name = "Queue"; this.priority = 0; this.supportReservation = supportReservation; } public boolean add(TaskInterface task){ try { task.setStatus(DCWormsTags.QUEUED); } catch(Exception e){ throw new RuntimeException(e); } return super.add(task); } public void add(int pos, TaskInterface task){ try { task.setStatus(DCWormsTags.QUEUED); } catch(Exception e){ throw new RuntimeException(e); } super.add(pos, task); } public DateTime getArrivalTime(int pos) throws IndexOutOfBoundsException { return get(pos).getSubmissionTimeToBroker(); } public String getName() { return name; } public int getPriority() { return priority; } public void setName(String name) { this.name = name; } public void setPriority(int priority) { this.priority = priority; } public boolean supportReservations() { return supportReservation; } }