source: DCWoRMS/trunk/src/example/localplugin/FCFSBF_LocalPlugin.java @ 531

Revision 531, 1.3 KB checked in by wojtekp, 12 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package example.localplugin;
2
3import gridsim.dcworms.DCWormsTags;
4import schedframe.events.scheduling.SchedulingEvent;
5import schedframe.scheduling.manager.resources.ResourceManager;
6import schedframe.scheduling.manager.tasks.JobRegistry;
7import schedframe.scheduling.plan.impl.SchedulingPlan;
8import schedframe.scheduling.plugin.grid.ModuleList;
9import schedframe.scheduling.queue.TaskQueue;
10import schedframe.scheduling.queue.TaskQueueList;
11import schedframe.scheduling.tasks.TaskInterface;
12
13public 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                // Chose 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
Note: See TracBrowser for help on using the repository browser.