1 package at.ac.tuwien.lsdc.sched;
3 import java.util.LinkedList;
7 import at.ac.tuwien.lsdc.types.Application;
8 import at.ac.tuwien.lsdc.types.ScenarioData;
9 import at.ac.tuwien.lsdc.types.SchedulerEvent;
11 public abstract class AbstractScheduler {
13 // the following types are only needed for correct
15 protected String schedulerName;
16 protected String scenario;
17 protected int numInSourced;
18 protected int numOutSourced;
20 // this map saves the following Type of Events:
21 // start of an Application, end of an Application
22 // (start outSourced, end outSourced, start inSourced, end inSourced)
23 protected Map<Long, LinkedList<SchedulerEvent>> eventMap;
25 // Scheduler has an internal Time "Abstraction"
26 // at every point in time it checks for Events in his "EventList"
27 // and handles them (via the individual scheduling algorithm)
28 protected long currTime;
30 // the timestamp at which the Scheduler is finished
31 // it is updated with every added "EndEvent"
32 protected long endTime;
34 // Initialize Scheduler with Data from CSV
35 // CSV will be parsed and sent as List<Application> to Scheduler
36 public ScenarioData initAndStart(List<Application> apps) {
37 for (Application a : apps) {
38 // read start timestamp
39 // save as Event in Map
42 return doEndLogging();
45 protected void startScheduling() {
47 LinkedList<SchedulerEvent> events = eventMap.get(currTime);
50 //advance Time to next Event
51 if (currTime == endTime) {
52 // reached last Event, Scheduler will shut down
58 // this method is where the Scheduling Algorithm resides
59 // it reads the Events (start & stop of applications)
60 protected abstract void handleEvents(LinkedList<SchedulerEvent> events);
62 protected void doStateLogging() {
63 // at every timestamp (after handle Event)
66 // this creates the total summary which should be written to a CSV at the
68 protected ScenarioData doEndLogging() {
69 return new ScenarioData(schedulerName,scenario,1,1,1,1,1,1);