package example.localplugin; import gridsim.Gridlet; import java.util.List; import java.util.Properties; import schedframe.scheduling.Queue; import schedframe.scheduling.TaskInterface; import schedframe.scheduling.events.SchedulingEvent; import schedframe.scheduling.plugin.local.ResourceUnitsManagerInterface; public class LCFS_EBFLocalPlugin extends BaseLocalPlugin { public LCFS_EBFLocalPlugin(){ } public void schedule(SchedulingEvent event, List> inExecution, List>> queues, ResourceUnitsManagerInterface unitsManagerInterface) { // do this trick to make add() method available List > execute = (List>) inExecution; // chose the events types to serve. // Different actions for different events are possible. switch(event.getType()){ case START_TASK_EXECUTION: case TASK_FINISHED: // our tasks are placed only in first queue (see BaseLocalPlugin.placeTasksInQueues() method) Queue> q = queues.get(0); // check all tasks in queue for(int i = q.size() - 1; i >= 0; i--){ TaskInterface task = q.get(i); // if status of the tasks in READY if(task.getStatus() == Gridlet.READY){ // then try to execute this task. Add it the execute list. if(execute.add(task)){ // if task started successfully, then remove it from the queue. q.remove(i); } } } break; } } public String getName() { return getClass().getName(); } public void init(Properties properties) { // no extra initialization is expected. } }