[477] | 1 | package example.globalplugin; |
---|
| 2 | |
---|
| 3 | import schedframe.Parameters; |
---|
| 4 | import schedframe.PluginConfiguration; |
---|
| 5 | import schedframe.events.scheduling.SchedulingEventType; |
---|
[490] | 6 | import schedframe.scheduling.TaskList; |
---|
[477] | 7 | import schedframe.scheduling.manager.resources.ResourceManager; |
---|
| 8 | import schedframe.scheduling.plugin.SchedulingPluginConfiguration; |
---|
| 9 | import schedframe.scheduling.plugin.grid.GlobalSchedulingPlugin; |
---|
| 10 | import schedframe.scheduling.plugin.grid.ModuleList; |
---|
| 11 | import schedframe.scheduling.queue.TaskQueue; |
---|
| 12 | import schedframe.scheduling.queue.TaskQueueList; |
---|
[481] | 13 | import schedframe.scheduling.tasks.TaskInterface; |
---|
[477] | 14 | import schemas.StringValueWithUnit; |
---|
| 15 | |
---|
| 16 | public abstract class BaseGlobalPlugin implements GlobalSchedulingPlugin { |
---|
| 17 | |
---|
| 18 | SchedulingPluginConfiguration plugConf; |
---|
| 19 | |
---|
| 20 | public PluginConfiguration getConfiguration() { |
---|
| 21 | return plugConf; |
---|
| 22 | } |
---|
| 23 | |
---|
[516] | 24 | public boolean placeTasksInQueues(TaskList newTasks, TaskQueueList queues, ResourceManager resourceManager, |
---|
[477] | 25 | ModuleList moduleList) { |
---|
| 26 | |
---|
| 27 | // get the first queue from all available queues. |
---|
| 28 | TaskQueue queue = queues.get(0); |
---|
| 29 | |
---|
[481] | 30 | for (int i = 0; i < newTasks.size(); i++) { |
---|
| 31 | TaskInterface<?> task = newTasks.get(i); |
---|
[477] | 32 | queue.add(task); |
---|
| 33 | } |
---|
| 34 | |
---|
[516] | 35 | return true; |
---|
[477] | 36 | } |
---|
| 37 | |
---|
| 38 | public void init(Parameters parameters) { |
---|
| 39 | plugConf = new SchedulingPluginConfiguration(); |
---|
| 40 | try{ |
---|
| 41 | StringValueWithUnit freq = parameters.get("frequency").get(0); |
---|
| 42 | plugConf.addServedEvent(SchedulingEventType.TIMER, Double.valueOf(freq.getContent()).intValue()); |
---|
| 43 | } catch(Exception e){ |
---|
| 44 | |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | |
---|
[497] | 48 | public String getName() { |
---|
| 49 | return getClass().getName(); |
---|
| 50 | } |
---|
[477] | 51 | |
---|
| 52 | } |
---|