[477] | 1 | package example.localplugin; |
---|
| 2 | |
---|
[481] | 3 | import gridsim.gssim.DCWormsTags; |
---|
[477] | 4 | import schedframe.events.scheduling.SchedulingEvent; |
---|
| 5 | import schedframe.scheduling.manager.resources.ResourceManager; |
---|
| 6 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
| 7 | import schedframe.scheduling.plan.impl.SchedulingPlan; |
---|
| 8 | import schedframe.scheduling.plugin.grid.ModuleList; |
---|
| 9 | import schedframe.scheduling.queue.TaskQueue; |
---|
| 10 | import schedframe.scheduling.queue.TaskQueueList; |
---|
| 11 | import schedframe.scheduling.tasks.TaskInterface; |
---|
| 12 | import schedframe.scheduling.tasks.WorkloadUnit; |
---|
| 13 | |
---|
| 14 | public class FCFS_BFLocalPlugin extends BaseLocalSchedulingPlugin { |
---|
| 15 | |
---|
| 16 | public SchedulingPlan schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, |
---|
| 17 | ResourceManager resManager, ModuleList modules) { |
---|
| 18 | |
---|
| 19 | SchedulingPlan plan = new SchedulingPlan(); |
---|
| 20 | // Chose the events types to serve. Different actions for different events are possible. |
---|
| 21 | switch (event.getType()) { |
---|
| 22 | case START_TASK_EXECUTION: |
---|
| 23 | case TASK_FINISHED: |
---|
| 24 | //case TIMER: |
---|
| 25 | |
---|
| 26 | // our tasks are placed only in first queue (see BaseLocalPlugin.placeJobsInQueues() method) |
---|
| 27 | TaskQueue q = queues.get(0); |
---|
| 28 | |
---|
| 29 | // check all tasks in queue |
---|
| 30 | for (int i = 0; i < q.size(); i++) { |
---|
[478] | 31 | WorkloadUnit job = q.get(i); |
---|
[477] | 32 | TaskInterface<?> task = (TaskInterface<?>) job; |
---|
| 33 | |
---|
| 34 | // if status of the tasks in READY |
---|
[481] | 35 | if (task.getStatus() == DCWormsTags.READY) { |
---|
[477] | 36 | addToSchedulingPlan(plan, task); |
---|
| 37 | } |
---|
| 38 | } |
---|
| 39 | break; |
---|
| 40 | } |
---|
| 41 | return plan; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | } |
---|
| 45 | |
---|