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