source: xssim/src/example/localplugin/LCFS_EBFLocalPlugin.java @ 104

Revision 104, 1.7 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;
4
5import java.util.List;
6import java.util.Properties;
7
8import schedframe.scheduling.Queue;
9import schedframe.scheduling.TaskInterface;
10import schedframe.scheduling.events.SchedulingEvent;
11import schedframe.scheduling.plugin.local.ResourceUnitsManagerInterface;
12
13public class LCFS_EBFLocalPlugin extends BaseLocalPlugin {
14
15       
16        public LCFS_EBFLocalPlugin(){
17        }
18       
19        public void schedule(SchedulingEvent event,
20                        List<? extends TaskInterface<?>> inExecution,
21                        List<? extends Queue<? extends TaskInterface<?>>> queues,
22                        ResourceUnitsManagerInterface unitsManagerInterface) {
23               
24                // do this trick to make add() method available
25                List <TaskInterface<?>> execute = (List<TaskInterface<?>>) inExecution;
26               
27                // chose the events types to serve.
28                // Different actions for different events are possible.
29                switch(event.getType()){
30                        case START_TASK_EXECUTION:
31                        case TASK_FINISHED:
32                                // our tasks are placed only in first queue (see BaseLocalPlugin.placeTasksInQueues() method)
33                                Queue<? extends TaskInterface<?>> q = queues.get(0);
34                                // check all tasks in queue
35                                for(int i = q.size() - 1; i >= 0; i--){
36                                        TaskInterface<?> task = q.get(i);
37                                        // if status of the tasks in READY
38                                        if(task.getStatus() == Gridlet.READY){
39                                                // then try to execute this task. Add it the execute list.
40                                                if(execute.add(task)){
41                                                        // if task started successfully, then remove it from the queue.
42                                                        q.remove(i);
43                                                }
44                                        }
45                                }
46                                break;
47                }
48               
49        }
50
51        public String getName() {
52                return getClass().getName();
53        }
54
55        public void init(Properties properties) {
56                // no extra initialization is expected.
57        }
58       
59}
Note: See TracBrowser for help on using the repository browser.