source: DCWoRMS/trunk/src/example/globalplugin/BaseGlobalPlugin.java @ 497

Revision 497, 1.5 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package example.globalplugin;
2
3import schedframe.Parameters;
4import schedframe.PluginConfiguration;
5import schedframe.events.scheduling.SchedulingEventType;
6import schedframe.scheduling.TaskList;
7import schedframe.scheduling.manager.resources.ResourceManager;
8import schedframe.scheduling.plugin.SchedulingPluginConfiguration;
9import schedframe.scheduling.plugin.grid.GlobalSchedulingPlugin;
10import schedframe.scheduling.plugin.grid.ModuleList;
11import schedframe.scheduling.queue.TaskQueue;
12import schedframe.scheduling.queue.TaskQueueList;
13import schedframe.scheduling.tasks.TaskInterface;
14import schemas.StringValueWithUnit;
15
16public 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}
Note: See TracBrowser for help on using the repository browser.