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

Revision 477, 1.5 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package example.localplugin;
2
3import gridsim.Gridlet;
4import schedframe.events.scheduling.SchedulingEvent;
5import schedframe.scheduling.manager.resources.ResourceManager;
6import schedframe.scheduling.manager.tasks.JobRegistry;
7import schedframe.scheduling.plan.SchedulingPlanInterface;
8import schedframe.scheduling.plan.impl.SchedulingPlan;
9import schedframe.scheduling.plugin.grid.ModuleList;
10import schedframe.scheduling.queue.TaskQueue;
11import schedframe.scheduling.queue.TaskQueueList;
12import schedframe.scheduling.tasks.TaskInterface;
13import schedframe.scheduling.tasks.WorkloadUnit;
14
15public class FCFS_BFLocalPlugin extends BaseLocalPlugin {
16
17        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
18                         ResourceManager resManager, ModuleList modules) {
19
20                SchedulingPlan plan = new SchedulingPlan();
21                // chose the events types to serve.
22                // Different actions for different events are possible.
23                switch (event.getType()) {
24                case START_TASK_EXECUTION:
25                case TASK_FINISHED:
26                //case TIMER:
27                        // our tasks are placed only in first queue (see BaseLocalPlugin.placeJobsInQueues() method)
28                       
29                        TaskQueue q = queues.get(0);
30                        // check all tasks in queue
31                        for (int i = 0; i < q.size(); i++) {
32                                WorkloadUnit<?> job = q.get(i);
33                                TaskInterface<?> task = (TaskInterface<?>) job;
34                               
35                                // if status of the tasks in READY
36                                if (task.getStatus() == Gridlet.READY) {
37                                        addToSchedulingPlan(plan, task);
38                                }
39                        }
40                        break;
41                }
42                return plan;
43        }
44
45        public String getName() {
46                return getClass().getName();
47        }
48
49
50}
51
Note: See TracBrowser for help on using the repository browser.