source: DCWoRMS/trunk/src/example/localplugin/FCFSRackLocalPlugin.java @ 514

Revision 514, 1.8 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.ClusterResourceManager;
6import schedframe.scheduling.manager.resources.ResourceManager;
7import schedframe.scheduling.manager.tasks.JobRegistry;
8import schedframe.scheduling.plan.SchedulingPlanInterface;
9import schedframe.scheduling.plan.impl.SchedulingPlan;
10import schedframe.scheduling.plugin.grid.ModuleList;
11import schedframe.scheduling.queue.TaskQueue;
12import schedframe.scheduling.queue.TaskQueueList;
13import schedframe.scheduling.tasks.TaskInterface;
14
15public class FCFSRackLocalPlugin  extends BaseLocalSchedulingPlugin {
16
17        public FCFSRackLocalPlugin() {
18        }
19
20        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
21                        ResourceManager resManager, ModuleList modules) {
22
23                ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
24                SchedulingPlan plan = new SchedulingPlan();
25                // chose the events types to serve.
26                // Different actions for different events are possible.
27                switch (event.getType()) {
28                case START_TASK_EXECUTION:
29                case TASK_FINISHED:
30                //case TIMER:
31                        // our tasks are placed only in first queue (see
32                        // BaseLocalPlugin.placeJobsInQueues() method)
33                        TaskQueue q = queues.get(0);
34                        // check all tasks in queue
35
36                        for (int i = 0; i < q.size(); i++) {
37                                TaskInterface<?> task = q.get(i);
38                                // if status of the tasks in READY
39                                if (task.getStatus() == DCWormsTags.READY) {
40                                        System.out.println(resourceManager.getSchedulers().get(0).get_name());
41                                        String nodeName = resourceManager.getSchedulers().get(0).get_name();
42                                        if (nodeName != null) {
43                                                addToSchedulingPlan(plan, task, nodeName);
44                                        }
45                                }
46                        }
47
48                        break;
49                }
50                return plan;
51        }
52
53
54}
Note: See TracBrowser for help on using the repository browser.