1 | package example.globalplugin; |
---|
2 | |
---|
3 | import schedframe.Parameters; |
---|
4 | import schedframe.PluginConfiguration; |
---|
5 | import schedframe.events.scheduling.SchedulingEventType; |
---|
6 | import schedframe.scheduling.TaskList; |
---|
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; |
---|
13 | import schedframe.scheduling.tasks.TaskInterface; |
---|
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 | |
---|
24 | public int placeTasksInQueues(TaskList newTasks, TaskQueueList queues, ResourceManager resourceManager, |
---|
25 | ModuleList moduleList) { |
---|
26 | |
---|
27 | // get the first queue from all available queues. |
---|
28 | TaskQueue queue = queues.get(0); |
---|
29 | |
---|
30 | for (int i = 0; i < newTasks.size(); i++) { |
---|
31 | TaskInterface<?> task = newTasks.get(i); |
---|
32 | queue.add(task); |
---|
33 | } |
---|
34 | |
---|
35 | return 0; |
---|
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 | |
---|
48 | public String getName() { |
---|
49 | return getClass().getName(); |
---|
50 | } |
---|
51 | |
---|
52 | } |
---|