[477] | 1 | package example.localplugin; |
---|
| 2 | |
---|
[493] | 3 | import gridsim.dcworms.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 | |
---|
[525] | 13 | public class FCFSBF_LocalPlugin extends BaseLocalSchedulingPlugin { |
---|
[477] | 14 | |
---|
| 15 | public SchedulingPlan schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, |
---|
| 16 | ResourceManager resManager, ModuleList modules) { |
---|
| 17 | |
---|
| 18 | SchedulingPlan plan = new SchedulingPlan(); |
---|
[574] | 19 | // Choose the events types to serve. Different actions for different events are possible. |
---|
[477] | 20 | switch (event.getType()) { |
---|
| 21 | case START_TASK_EXECUTION: |
---|
| 22 | case TASK_FINISHED: |
---|
| 23 | |
---|
[531] | 24 | // our tasks are placed only in first queue (see BaseLocalSchedulingPlugin.placeJobsInQueues() method) |
---|
[477] | 25 | TaskQueue q = queues.get(0); |
---|
| 26 | |
---|
| 27 | // check all tasks in queue |
---|
| 28 | for (int i = 0; i < q.size(); i++) { |
---|
[513] | 29 | TaskInterface<?> task = q.get(i); |
---|
[477] | 30 | |
---|
| 31 | // if status of the tasks in READY |
---|
[481] | 32 | if (task.getStatus() == DCWormsTags.READY) { |
---|
[477] | 33 | addToSchedulingPlan(plan, task); |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | break; |
---|
| 37 | } |
---|
| 38 | return plan; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | } |
---|
| 42 | |
---|