package example.localplugin; import java.util.Map; import schedframe.resources.units.ResourceUnit; import schedframe.scheduling.TaskInterface; import schedframe.scheduling.events.SchedulingEvent; import schedframe.scheduling.events.SchedulingResponseType; import schedframe.scheduling.plugin.SchedulingPluginConfiguration; import schedframe.scheduling.plugin.configuration.DefaultConfiguration; import schedframe.scheduling.plugin.grid.ModuleList; import schedframe.scheduling.plugin.local.LocalSchedulingPlugin; import schedframe.scheduling.utils.ResourceParameterName; import test.rewolucja.GSSIMJobInterface; import test.rewolucja.resources.manager.interfaces.ResourceManagerInterface; import test.rewolucja.scheduling.JobRegistry; import test.rewolucja.scheduling.plan.AllocationNew; import test.rewolucja.scheduling.plan.ScheduledTaskNew; import test.rewolucja.scheduling.plan.SchedulingPlanNew; import test.rewolucja.scheduling.queue.Queue; import test.rewolucja.scheduling.queue.QueueList; import test.rewolucja.task.JobList; /** * * @author Marcin Krystek * */ public abstract class BaseLocalPlugin implements LocalSchedulingPlugin { public SchedulingPluginConfiguration getConfiguration() { return DefaultConfiguration.forLocalPlugin(); } public SchedulingResponseType handleResourceAllocationViolation(SchedulingEvent event, QueueList queues, JobRegistry jobRegistry, ResourceManagerInterface resourceManager, ModuleList modules){ SchedulingResponseType timeEvent = null; switch(event.getType()){ case TASK_REQUESTED_TIME_EXPIRED: timeEvent = SchedulingResponseType.KILL_TASK; break; } return timeEvent; } public int placeJobsInQueues(JobList newJobs, QueueList queues, ResourceManagerInterface resourceManager, ModuleList moduleList) { // get the first queue from all available queues. Queue queue = queues.get(0); for(int i = 0; i < newJobs.size(); i++){ GSSIMJobInterface task = newJobs.get(i); queue.add(task); } return 0; } public void addToSchedulingPlan(SchedulingPlanNew plan, TaskInterface task, Map choosenResources ){ AllocationNew allocation = new AllocationNew(); allocation.setProcessesCount(1); allocation.setSpecificResources(choosenResources); ScheduledTaskNew scheduledTask = new ScheduledTaskNew(task); scheduledTask.setTaskId(task.getId()); scheduledTask.setJobId(task.getJobId()); scheduledTask.addAllocation(allocation); plan.addTask(scheduledTask); } public void addToSchedulingPlan(SchedulingPlanNew plan, TaskInterface task, String providerName){ AllocationNew allocation = new AllocationNew(); allocation.setProcessesCount(1); allocation.setProviderName(providerName); ScheduledTaskNew scheduledTask = new ScheduledTaskNew(task); scheduledTask.setTaskId(task.getId()); scheduledTask.setJobId(task.getJobId()); scheduledTask.addAllocation(allocation); plan.addTask(scheduledTask); } public void addToSchedulingPlan(SchedulingPlanNew plan, TaskInterface task){ AllocationNew allocation = new AllocationNew(); allocation.setProcessesCount(1); allocation.setProviderName(null); ScheduledTaskNew scheduledTask = new ScheduledTaskNew(task); scheduledTask.setTaskId(task.getId()); scheduledTask.setJobId(task.getJobId()); scheduledTask.addAllocation(allocation); plan.addTask(scheduledTask); } }