<property name="log.dir" value="logs" />\r
<property name="scen.dir" value="scenarios" />\r
\r
- <property name="numPMs" value="2" />\r
- <property name="numCloudPartners" value="3" />\r
+ <property name="numPMs" value="15" />\r
+ <property name="numCloudPartners" value="0" />\r
\r
<path id="project.classpath">\r
<dirset dir="${build.dir}" />\r
<arg value="A" />\r
<arg value="${numPMs}" />\r
<arg value="${numCloudPartners}" />\r
- <arg value="scenarios/scenarioA.csv" />\r
+ <arg value="scenarios/A.csv" />\r
<arg value="logs/all.csv" />\r
<arg value="logs/schedulerC_scenarioA.csv" />\r
</java>\r
<arg value="B" />\r
<arg value="${numPMs}" />\r
<arg value="${numCloudPartners}" />\r
- <arg value="scenarios/scenarioB.csv" />\r
+ <arg value="scenarios/B.csv" />\r
<arg value="logs/all.csv" />\r
<arg value="logs/schedulerC_scenarioB.csv" />\r
</java>\r
<arg value="C" />\r
<arg value="${numPMs}" />\r
<arg value="${numCloudPartners}" />\r
- <arg value="scenarios/scenarioC.csv" />\r
+ <arg value="scenarios/C.csv" />\r
<arg value="logs/all.csv" />\r
<arg value="logs/schedulerC_scenarioC.csv" />\r
</java>\r
</target>\r
\r
+ <target name="run-scheduler-C-D" depends="compile" description="Run scheduler C on scenario C">\r
+ <java classname="at.ac.tuwien.lsdc.SchedSimulator" fork="true" classpathref="project.classpath">\r
+ <assertions refid="project.assertions" />\r
+ <arg value="C" />\r
+ <arg value="C" />\r
+ <arg value="${numPMs}" />\r
+ <arg value="${numCloudPartners}" />\r
+ <arg value="scenarios/D.csv" />\r
+ <arg value="logs/all.csv" />\r
+ <arg value="logs/schedulerC_scenarioD.csv" />\r
+ </java>\r
+ </target>\r
\r
<target name="run-all-schedulers" depends="run-scheduler-A-A, run-scheduler-A-B, run-scheduler-A-C, run-scheduler-B-A, run-scheduler-B-B, run-scheduler-B-C, run-scheduler-C-A, run-scheduler-C-B, run-scheduler-C-C" description="Run all schedulers and all scenarios">\r
</target>\r
import at.ac.tuwien.lsdc.JobGenerator;
import at.ac.tuwien.lsdc.SchedSimulator;
+import at.ac.tuwien.lsdc.sched.AbstractScheduler;
import at.ac.tuwien.lsdc.sched.SchedulerB;
import at.ac.tuwien.lsdc.types.Application;
* @return true, if application can be outsourced.
*/
public boolean askToOutsource(Application app) {
- LOG.info("askToOutsource():" + app);
- if ((Math.random() * 100) < (10 * numPartners))
+ if ((Math.random() * 100) < (10 * numPartners)) {
+ LOG.info("Outsource:" + app);
return true;
+ }
return false;
}
*/
@SuppressWarnings("unused")
public Application askToInsource() {
- LOG.info("askToOutsource()");
int size;
int ram;
int cpu;
int duration;
+
+ long timestamp = AbstractScheduler.getCurrentTime() + JobGenerator.randomInt(1, 3);
- if ((Math.random() * 100) < (10 * numPartners) && false)
+ if ((Math.random() * 100) < (10 * numPartners)) {
+ LOG.info("Insource app ");
switch (SchedSimulator.getScenario()) {
case A :
size = JobGenerator.randomInt(20, 100);
ram = JobGenerator.randomInt(30, 50);
cpu = JobGenerator.randomInt(50, 100);
duration = JobGenerator.randomInt(1, 50);
- return new Application(0, size, ram, cpu, duration);
+ return new Application(timestamp, size, ram, cpu, duration);
case B :
size = JobGenerator.randomInt(150, 500);
ram = JobGenerator.randomInt(100, 700);
cpu = JobGenerator.randomInt(100, 400);
duration = JobGenerator.randomInt(1, 50);
- return new Application(0, size, ram, cpu, duration);
+ return new Application(timestamp, size, ram, cpu, duration);
default :
size = JobGenerator.randomInt(20, 500);
ram = JobGenerator.randomInt(30, 700);
cpu = JobGenerator.randomInt(50, 400);
duration = JobGenerator.randomInt(1, 50);
- return new Application(0, size, ram, cpu, duration);
+ return new Application(timestamp, size, ram, cpu, duration);
}
+ }
return null;
}
}
* Scheduler has an internal Time "Abstraction" at every point in time it checks for Events in
* his "EventList" and handles them (via the individual scheduling algorithm)
*/
- protected long currTime = 0;
+ protected static long currTime = 0;
/**
* the timestamp at which the Scheduler is finished it is updated with every added "EndEvent"
app);
insertEvent(evt);
}
+
+ /**
+ * Insert a start insourced event into the map, at timestamp when the application should start
+ *
+ * @param timestamp the timestamp when the application should start
+ * @param app the application to start
+ */
+ protected void insertInsourcedStartEvent(long timestamp, Application app) {
+ SchedulerEvent evt = new SchedulerEvent(timestamp, EventType.startInsourcedApplication,
+ app);
+ insertEvent(evt);
+ }
/**
* Insert a stop event into the map, at timestamp when the application should stop.
endTime = timestamp;
}
}
+
+ /**
+ * Insert a stop event into the map, at timestamp when the application should stop.
+ *
+ * @param timestamp the timestamp when the application should stop
+ * @param app the application to stop
+ */
+ protected void insertInsourcedStopEvent(long timestamp, Application app) {
+ SchedulerEvent evt = new SchedulerEvent(timestamp, EventType.endInsourcedApplication, app);
+ insertEvent(evt);
+ if (endTime < timestamp) {
+ endTime = timestamp;
+ }
+ }
private void insertEvent(SchedulerEvent evt) {
LinkedList<SchedulerEvent> list;
handleEndEvents(events.get(EventType.endApplication));
if (events.containsKey(EventType.endOutsourcedApplication))
handleOutsourcedEndEvents(events.get(EventType.endOutsourcedApplication));
+ if (events.containsKey(EventType.endInsourcedApplication))
+ handleInsourcedEndEvents(events.get(EventType.endInsourcedApplication));
handleDelayedApps();
if (events.containsKey(EventType.startOutsourcedApplication))
handleOutsourcedStartEvents(events.get(EventType.startOutsourcedApplication));
if (events.containsKey(EventType.startApplication))
handleStartEvents(events.get(EventType.startApplication));
+ if (events.containsKey(EventType.startInsourcedApplication))
+ handleInsourcedStartEvents(events.get(EventType.startInsourcedApplication));
}
protected void handleDelayedApps() {
}
}
}
+
+ /**
+ * handle running of outsourced apps.
+ *
+ * @param events list of all events that happened in this timeslot.
+ */
+ protected void handleInsourcedStartEvents(LinkedList<SchedulerEvent> events) {
+ for (SchedulerEvent evt : events) {
+ if (evt.getType() == EventType.startInsourcedApplication) {
+ insertInsourcedStopEvent(currTime + evt.getApp().getDuration(), evt.getApp());
+ numCurrInSourced++;
+ numTotalInSourced++;
+ }
+ }
+ }
/**
* handle stopping of outsourced apps.
}
}
}
+
+ /**
+ * handle stopping of outsourced apps.
+ *
+ * @param events list of all events that happened in this timeslot.
+ */
+ protected void handleInsourcedEndEvents(LinkedList<SchedulerEvent> events) {
+ for (SchedulerEvent evt : events) {
+ if (evt.getType() == EventType.endInsourcedApplication) {
+ numCurrInSourced--;
+ }
+ }
+ }
/**
* Does the logging for each timestamp. It uses the CSVLogger to write directly to the specific
}
protected abstract String getSchedulerType();
+
+ public static long getCurrentTime() {
+ return currTime;
+ }
}
if (enoughResources) {
appDeployed = startApp(pm, app);
- log.info("Application " + app.toString() + " started on new pm " + pm.getId());
+// log.info("Application " + app.toString() + " started on new pm " + pm.getId());
} else {
- log.info("Application " + app.toString() + " cannot be run on pm "
- + pm.getId() + ", too little space");
+// log.info("Application " + app.toString() + " cannot be run on pm "
+// + pm.getId() + ", too little space");
}
} else {
// sorting physical machines by resource utilization
if (enoughResources) {
appDeployed = startApp(pm, app);
- log.info("Application " + app.toString() + " started new vm "
- + pm.getLatestVMID() + " on pm " + pm.getId());
+// log.info("Application " + app.toString() + " started new vm "
+// + pm.getLatestVMID() + " on pm " + pm.getId());
break;
}
}
if (enoughResources) {
appDeployed = startApp(pm, app);
- log.info("Application " + app.toString() + " started on new pm "
- + pm.getId());
+// log.info("Application " + app.toString() + " started on new pm "
+// + pm.getId());
} else {
- log.warn("Application " + app.toString() + " cannot be run on pm "
- + pm.getId() + ", too little space");
+// log.warn("Application " + app.toString() + " cannot be run on pm "
+// + pm.getId() + ", too little space");
}
}
}
} else
delayedApps.add(app);
}
- if (!appDeployed)
+ if(appDeployed) {
+ if(manager.countCurrentlyRunningPMs() < manager.getMaxPMs()) {
+ Application application = federation.askToInsource();
+ if(application != null) {
+ insertInsourcedStartEvent(currTime + 1, application);
+ }
+ }
+ }
+ else
log.warn("Application " + app.toString() + " could not be deployed on any pm");
}
*/
@Override
protected void handleEndEvents(LinkedList<SchedulerEvent> events) {
- LOG.debug("stopApps():" + events);
+// LOG.debug("stopApps():" + events);
for (SchedulerEvent evt : events) {
VirtualMachine vm = evt.getApp().getRunningOn();
evt.getApp().setRunningOn(null);
*/
@Override
protected void handleStartEvents(LinkedList<SchedulerEvent> events) {
- LOG.debug("startApps():" + events);
+// LOG.debug("startApps():" + events);
boolean deployed = false;
for (SchedulerEvent evt : events) {
deployed = false;
}
}
}
- if (deployed)
+ if (deployed) {
insertStopEvent(currTime + evt.getApp().getDuration(), evt.getApp());
+
+ if(manager.countCurrentlyRunningPMs() < manager.getMaxPMs()) {
+ Application app = federation.askToInsource();
+ if(app != null) {
+ insertInsourcedStartEvent(currTime + 1, evt.getApp());
+ }
+ }
+ }
}
}
*/
@Override
protected void handleEndEvents(LinkedList<SchedulerEvent> events) {
- LOG.debug("stopApps():" + events);
+// LOG.debug("stopApps():" + events);
for (SchedulerEvent evt : events) {
VirtualMachine vm = evt.getApp().getRunningOn();
evt.getApp().setRunningOn(null);
*/
@Override
protected void handleStartEvents(LinkedList<SchedulerEvent> events) {
- LOG.debug("startApps():" + events);
+// LOG.debug("startApps():" + events);
boolean deployed = false;
for (SchedulerEvent evt : events) {
deployed = false;
}
}
}
- if (deployed)
+ if (deployed) {
insertStopEvent(currTime + evt.getApp().getDuration(), evt.getApp());
+
+ if(manager.countCurrentlyRunningPMs() < manager.getMaxPMs()) {
+ Application app = federation.askToInsource();
+ if(app != null) {
+ insertInsourcedStartEvent(currTime + 1, evt.getApp());
+ }
+ }
+ }
}
}
public class SchedulerEvent {
public enum EventType {
- startApplication, endApplication, startOutsourcedApplication, endOutsourcedApplication
+ startApplication, endApplication, startOutsourcedApplication, endOutsourcedApplication, startInsourcedApplication, endInsourcedApplication
};
final private long timestamp;