source: DCWoRMS/trunk/build/classes/example/localplugin/FCFS_BFLocalPlugin.java @ 539

Revision 539, 1.4 KB checked in by wojtekp, 12 years ago (diff)
  • Property svn:mime-type set to text/plain
RevLine 
[477]1package example.localplugin;
2
[539]3import gridsim.dcworms.DCWormsTags;
[477]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
[539]14public 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
Note: See TracBrowser for help on using the repository browser.