source: DCWoRMS/trunk/src/example/localplugin/FCFS_BFLocalPlugin.java @ 509

Revision 509, 1.4 KB checked in by wojtekp, 13 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;
12import schedframe.scheduling.tasks.WorkloadUnit;
13
14public 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                       
25                        // our tasks are placed only in first queue (see BaseLocalPlugin.placeJobsInQueues() method)
26                        TaskQueue q = queues.get(0);
27                       
28                        // check all tasks in queue
29                        for (int i = 0; i < q.size(); i++) {
30                                WorkloadUnit job = q.get(i);
31                                TaskInterface<?> task = (TaskInterface<?>) job;
32                               
33                                // if status of the tasks in READY
34                                if (task.getStatus() == DCWormsTags.READY) {
35                                        addToSchedulingPlan(plan, task);
36                                }
37                        }
38                        break;
39                }
40                return plan;
41        }
42
43}
44
Note: See TracBrowser for help on using the repository browser.