From b35d5ebb6834281b721188dc36e8361ee923d187 Mon Sep 17 00:00:00 2001 From: Andreas Egger Date: Mon, 24 Jun 2013 20:05:56 +0200 Subject: [PATCH] Adding start / stop output --- build.xml | 2 +- .../tuwien/lsdc/sched/AbstractScheduler.java | 10 ++++++++-- .../sched/AbstractSchedulerWithMigration.java | 2 +- src/at/ac/tuwien/lsdc/sched/SchedulerA.java | 1 + src/at/ac/tuwien/lsdc/sched/SchedulerB.java | 20 ++++++++++--------- src/at/ac/tuwien/lsdc/types/ScenarioData.java | 20 +++++++++++++++++-- src/at/ac/tuwien/lsdc/util/CSVLogger.java | 2 +- 7 files changed, 41 insertions(+), 16 deletions(-) diff --git a/build.xml b/build.xml index 0d3e25b..5ebb72f 100644 --- a/build.xml +++ b/build.xml @@ -7,7 +7,7 @@ - + diff --git a/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java b/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java index 4e286a2..1739694 100644 --- a/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java +++ b/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java @@ -39,6 +39,8 @@ public abstract class AbstractScheduler { protected int numCurrOutSourced; protected int numStarted; protected int numStopped; + protected int numTotalStarted; + protected int numTotalStopped; protected double totalConsumption; protected MachineManager manager; @@ -204,7 +206,7 @@ public abstract class AbstractScheduler { // advance Time to next step currTime++; - if (currTime > endTime) { + if (currTime > endTime && delayedApps.size() == 0) { // reached last Event, Scheduler will shut down log.info("Last event reached at time " + currTime); break; @@ -235,6 +237,9 @@ public abstract class AbstractScheduler { handleStartEvents(events.get(EventType.startApplication)); if (events.containsKey(EventType.startInsourcedApplication)) handleInsourcedStartEvents(events.get(EventType.startInsourcedApplication)); + + numTotalStarted += numStarted; + numTotalStopped += numStopped; } protected void handleDelayedApps() { @@ -334,7 +339,8 @@ public abstract class AbstractScheduler { protected ScenarioData doEndLogging() { return new ScenarioData(getSchedulerType(), scenario.toString(), manager.getTotalPMs(), manager.getTotalVMs(), endTime, NumberUtils.roundDouble(totalConsumption), - numTotalInSourced, numTotalOutSourced, MachineManager.getTotalResizeCalls(), totalDelayedApps); + numTotalInSourced, numTotalOutSourced, MachineManager.getTotalResizeCalls(), totalDelayedApps, + numTotalStarted, numTotalStopped); } protected abstract String getSchedulerType(); diff --git a/src/at/ac/tuwien/lsdc/sched/AbstractSchedulerWithMigration.java b/src/at/ac/tuwien/lsdc/sched/AbstractSchedulerWithMigration.java index 6161786..afe7484 100644 --- a/src/at/ac/tuwien/lsdc/sched/AbstractSchedulerWithMigration.java +++ b/src/at/ac/tuwien/lsdc/sched/AbstractSchedulerWithMigration.java @@ -23,7 +23,7 @@ public abstract class AbstractSchedulerWithMigration extends AbstractScheduler { @Override protected void handleEvents(HashMap> events) { super.handleEvents(events); - runMigration(); +// runMigration(); } /** diff --git a/src/at/ac/tuwien/lsdc/sched/SchedulerA.java b/src/at/ac/tuwien/lsdc/sched/SchedulerA.java index 45afeb3..e636259 100644 --- a/src/at/ac/tuwien/lsdc/sched/SchedulerA.java +++ b/src/at/ac/tuwien/lsdc/sched/SchedulerA.java @@ -88,6 +88,7 @@ public class SchedulerA extends AbstractScheduler { } if (!appDeployed) { if (federation.askToOutsource(app)) { + log.debug("OUTSOURCE !!!!!!!!!!!"); insertOutsourcedStartEvent(currTime + 1, app); appDeployed = true; } else diff --git a/src/at/ac/tuwien/lsdc/sched/SchedulerB.java b/src/at/ac/tuwien/lsdc/sched/SchedulerB.java index b445c6c..f0b6d9f 100644 --- a/src/at/ac/tuwien/lsdc/sched/SchedulerB.java +++ b/src/at/ac/tuwien/lsdc/sched/SchedulerB.java @@ -46,7 +46,7 @@ public class SchedulerB extends AbstractSchedulerWithMigration { @Override protected boolean deployApp(VirtualMachine vm, Application app) { - VirtualMachine current = app.getRunningOn(); +// VirtualMachine current = app.getRunningOn(); boolean deployed = false; if (!vm.enoughResources(app)) { try { @@ -58,10 +58,11 @@ public class SchedulerB extends AbstractSchedulerWithMigration { deployed = vm.startApplication(app); if (deployed) { app.setRunningOn(vm); - if (current != null) { - current.stopApplication(app); - current.resizeDown(app); - } + insertStopEvent(currTime + app.getDuration(), app); +// if (current != null) { +// current.stopApplication(app); +// current.resizeDown(app); +// } } return deployed; } @@ -76,10 +77,11 @@ public class SchedulerB extends AbstractSchedulerWithMigration { // LOG.debug("stopApps():" + events); for (SchedulerEvent evt : events) { VirtualMachine vm = evt.getApp().getRunningOn(); - evt.getApp().setRunningOn(null); vm.stopApplication(evt.getApp()); vm.resizeDown(evt.getApp()); + numStopped ++; + if (vm.getApplications().size() == 0) { PhysicalMachine pm = vm.getRunningOn(); pm.stopVirtualMachine(vm); @@ -120,15 +122,15 @@ public class SchedulerB extends AbstractSchedulerWithMigration { if (federation.askToOutsource(evt.getApp())) { insertOutsourcedStartEvent(currTime + 1, evt.getApp()); } else { - LOG.info("delaying the start of:" + evt.getApp()); +// LOG.info("delaying the start of:" + evt.getApp()); delayedApps.add(evt.getApp()); return; } } } if (deployed) { - insertStopEvent(currTime + evt.getApp().getDuration(), evt.getApp()); - + numStarted ++; + if(manager.countCurrentlyRunningPMs() < manager.getMaxPMs()) { Application app = federation.askToInsource(); if(app != null) { diff --git a/src/at/ac/tuwien/lsdc/types/ScenarioData.java b/src/at/ac/tuwien/lsdc/types/ScenarioData.java index 2078116..7c80e70 100644 --- a/src/at/ac/tuwien/lsdc/types/ScenarioData.java +++ b/src/at/ac/tuwien/lsdc/types/ScenarioData.java @@ -20,6 +20,8 @@ public class ScenarioData { private int totalOutSourced; private int totalResizeCalls; private int totalDelayedApps; + private int totalStarted; + private int totalStopped; public ScenarioData(String scheduler, String scenario, long totalPMs, long totalVMs, long totalDuration, double totalConsumption, @@ -44,6 +46,18 @@ public class ScenarioData { this(scheduler, scenario, totalPMs, totalVMs, totalDuration, totalConsumption, totalInSourced, totalOutSourced, totalResizeCalls); this.totalDelayedApps = totalDelayedApps; } + + public ScenarioData(String scheduler, String scenario, long totalPMs, + long totalVMs, long totalDuration, double totalConsumption, + int totalInSourced, int totalOutSourced, + int totalResizeCalls, int totalDelayedApps, + int totalStarted, int totalStopped) { + + this(scheduler, scenario, totalPMs, totalVMs, totalDuration, totalConsumption, totalInSourced, + totalOutSourced, totalResizeCalls, totalDelayedApps); + this.totalStarted = totalStarted; + this.totalStopped = totalStopped; + } public String[] toStringArray() { // LOG.info("total Consumption = "+totalConsumption+ ", string: "+String.valueOf(totalConsumption)); @@ -51,7 +65,8 @@ public class ScenarioData { return new String[] { scheduler, scenario, String.valueOf(totalPMs), String.valueOf(totalVMs), String.valueOf(totalDuration), df.format(totalConsumption), String.valueOf(totalInSourced), - String.valueOf(totalOutSourced), String.valueOf(totalResizeCalls), String.valueOf(totalDelayedApps) }; + String.valueOf(totalOutSourced), String.valueOf(totalResizeCalls), String.valueOf(totalDelayedApps) , + String.valueOf(totalStarted), String.valueOf(totalStopped) }; } @Override @@ -62,7 +77,8 @@ public class ScenarioData { + ", totalConsumption=" + totalConsumption + ", totalInSourced=" + totalInSourced + ", totalOutSourced=" + totalOutSourced + ", totalResizeCalls=" + totalResizeCalls - + ", delayedApps=" + totalDelayedApps + "]"; + + ", delayedApps=" + totalDelayedApps + + ", totalStarted=" + totalStarted + "totalStopped=" + totalStopped + "]"; } } diff --git a/src/at/ac/tuwien/lsdc/util/CSVLogger.java b/src/at/ac/tuwien/lsdc/util/CSVLogger.java index f5bf6b3..5c67a67 100644 --- a/src/at/ac/tuwien/lsdc/util/CSVLogger.java +++ b/src/at/ac/tuwien/lsdc/util/CSVLogger.java @@ -34,7 +34,7 @@ public class CSVLogger { private void writeScenarioDataHeader() throws IOException { String[] header = new String[] { "Scheduler", "Scenario", "TotalPMs", "TotalVMs", "TotalDuration", "TotalPowerConsumption", "TotalInSourced", "TotalOutSourced", - "TotalResizeEvents", "TotalDelayedApps" }; + "TotalResizeEvents", "TotalDelayedApps", "TotalStarted", "TotalStopped"}; writeCSVLine(header); } -- 2.43.0