[477] | 1 | package example.localplugin; |
---|
| 2 | |
---|
[493] | 3 | import gridsim.dcworms.DCWormsTags; |
---|
[477] | 4 | import schedframe.events.scheduling.SchedulingEvent; |
---|
| 5 | import schedframe.scheduling.manager.resources.ClusterResourceManager; |
---|
| 6 | import schedframe.scheduling.manager.resources.ResourceManager; |
---|
| 7 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
| 8 | import schedframe.scheduling.plan.SchedulingPlanInterface; |
---|
| 9 | import schedframe.scheduling.plan.impl.SchedulingPlan; |
---|
| 10 | import schedframe.scheduling.plugin.grid.ModuleList; |
---|
| 11 | import schedframe.scheduling.queue.TaskQueue; |
---|
| 12 | import schedframe.scheduling.queue.TaskQueueList; |
---|
| 13 | import schedframe.scheduling.tasks.TaskInterface; |
---|
| 14 | |
---|
[525] | 15 | public class FCFSBF_RackPlugin extends BaseLocalSchedulingPlugin { |
---|
[477] | 16 | |
---|
[525] | 17 | public FCFSBF_RackPlugin() { |
---|
[477] | 18 | } |
---|
| 19 | |
---|
[481] | 20 | public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, |
---|
[477] | 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++) { |
---|
[513] | 37 | TaskInterface<?> task = q.get(i); |
---|
[477] | 38 | // if status of the tasks in READY |
---|
[481] | 39 | if (task.getStatus() == DCWormsTags.READY) { |
---|
[477] | 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 | } |
---|