1 package at.ac.tuwien.lsdc.sched;
3 import java.util.LinkedList;
6 import at.ac.tuwien.lsdc.types.Application;
7 import at.ac.tuwien.lsdc.types.ScenarioData;
8 import at.ac.tuwien.lsdc.types.SchedulerEvent;
10 public abstract class AbstractScheduler {
12 // the following types are only needed for correct
14 protected String schedulerName;
15 protected String scenario;
16 protected int numInSourced;
17 protected int numOutSourced;
19 // this map saves the following Type of Events:
20 // start of an Application, end of an Application
21 // (start outSourced, end outSourced, start inSourced, end inSourced)
22 protected Map<Long, LinkedList<SchedulerEvent>> eventMap;
24 // Scheduler has an internal Time "Abstraction"
25 // at every point in time it checks for Events in his "EventList"
26 // and handles them (via the individual scheduling algorithm)
27 protected long currTime;
29 // the timestamp at which the Scheduler is finished
30 // it is updated with every added "EndEvent"
31 protected long endTime;
33 // Initialize Scheduler with Data from CSV
34 // CSV will be parsed and sent as List<Application> to Scheduler
35 public ScenarioData initAndStart(LinkedList<Application> apps) {
36 for (Application a : apps) {
37 System.out.println(a);
38 // read start timestamp
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);