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.SchedulerEvent;
10 public abstract class AbstractScheduler {
12 // should move to SchedulerType Class later on
15 // the following types are only needed for correct
17 protected String schedulerName;
18 protected String scenario;
19 protected int numInSourced;
20 protected int numOutSourced;
22 // this map saves the following Type of Events:
23 // start of an Application, end of an Application
24 // (start outSourced, end outSourced, start inSourced, end inSourced)
25 protected Map<Long, LinkedList<SchedulerEvent>> eventMap;
27 // Scheduler has an internal Time "Abstraction"
28 // at every point in time it checks for Events in his "EventList"
29 // and handles them (via the individual scheduling algorithm)
30 protected long currTime;
32 // the timestamp at which the Scheduler is finished
33 // it is updated with every added "EndEvent"
34 protected long endTime;
36 // Initialize Scheduler with Data from CSV
37 // CSV will be parsed and sent as List<Application> to Scheduler
38 public String initAndStart(List<Application> apps) {
39 for (Application a : apps) {
40 // read start timestamp
41 // save as Event in Map
44 return doEndLogging();
47 protected void startScheduling() {
49 LinkedList<SchedulerEvent> events = eventMap.get(currTime);
52 //advance Time to next Event
53 if (currTime == endTime) {
54 // reached last Event, Scheduler will shut down
60 // this method is where the Scheduling Algorithm resides
61 // it reads the Events (start & stop of applications)
62 protected abstract void handleEvents(LinkedList<SchedulerEvent> events);
64 protected void doStateLogging() {
65 // at every timestamp (after handle Event)
68 // this creates the total summary which should be written to a CSV at the
70 protected String doEndLogging() {