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