From a836b8f0a69d6e39db025b1f19f39770fbc7066f Mon Sep 17 00:00:00 2001 From: Stefan Derkits Date: Tue, 11 Jun 2013 14:18:28 +0200 Subject: [PATCH] moved handling of delayed Apps into AbstractScheduler --- .../tuwien/lsdc/sched/AbstractScheduler.java | 12 +++++- src/at/ac/tuwien/lsdc/sched/SchedulerA.java | 6 --- src/at/ac/tuwien/lsdc/sched/SchedulerB.java | 42 ------------------- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java b/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java index fc0109c..c6a3779 100644 --- a/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java +++ b/src/at/ac/tuwien/lsdc/sched/AbstractScheduler.java @@ -202,9 +202,17 @@ public abstract class AbstractScheduler { runMigration(); } - protected abstract void handleEndEvents(LinkedList events); + protected void handleDelayedApps() { + LinkedList delayedStartEvents = new LinkedList(); + for (Application app : delayedApps) { + SchedulerEvent evt = new SchedulerEvent(currTime, EventType.startApplication, app); + delayedStartEvents.add(evt); + delayedApps.remove(app); + } + handleStartEvents(delayedStartEvents); + } - protected abstract void handleDelayedApps(); + protected abstract void handleEndEvents(LinkedList events); protected abstract void handleStartEvents(LinkedList events); diff --git a/src/at/ac/tuwien/lsdc/sched/SchedulerA.java b/src/at/ac/tuwien/lsdc/sched/SchedulerA.java index 3a0c479..354bfad 100644 --- a/src/at/ac/tuwien/lsdc/sched/SchedulerA.java +++ b/src/at/ac/tuwien/lsdc/sched/SchedulerA.java @@ -54,12 +54,6 @@ public class SchedulerA extends AbstractScheduler { } } - @Override - protected void handleDelayedApps() { - // TODO Auto-generated method stub - - } - @Override protected void handleStartEvents(LinkedList events) { // sorting applications by amount of resources (descending) diff --git a/src/at/ac/tuwien/lsdc/sched/SchedulerB.java b/src/at/ac/tuwien/lsdc/sched/SchedulerB.java index e71a990..6044677 100644 --- a/src/at/ac/tuwien/lsdc/sched/SchedulerB.java +++ b/src/at/ac/tuwien/lsdc/sched/SchedulerB.java @@ -9,7 +9,6 @@ import org.slf4j.LoggerFactory; import at.ac.tuwien.lsdc.exception.OutOfPMsException; import at.ac.tuwien.lsdc.exception.VMResizeException; -import at.ac.tuwien.lsdc.types.Application; import at.ac.tuwien.lsdc.types.PhysicalMachine; import at.ac.tuwien.lsdc.types.ScenarioType; import at.ac.tuwien.lsdc.types.SchedulerEvent; @@ -42,47 +41,6 @@ public class SchedulerB extends AbstractScheduler { vmType = VMType.Resizable; } - /** - * Check if we have any delayed apps. Try to launch them. - */ - @Override - protected void handleDelayedApps() { - // TODO: probably mostly the same code as handleStartEvents - // TOOD: (namely: use case: "start an application",do merge it - for (Application app : delayedApps) { - VirtualMachine vm = null; - for (PhysicalMachine pm : manager.getPMs()) { - // TODO: choose PM better to get better Utilization - vm = pm.getVirtualMachines().get( - (pm.getVirtualMachines().keySet().toArray(new Integer[0]))[0]); - try { - vm.resizeVM(vm.getSize() + app.getSize(), vm.getRAM() + app.getRam(), - vm.getCPU() + app.getCpu()); - break; - } catch (VMResizeException ex) { - vm = null; - } - } - if (vm == null) { - try { - vm = manager.startPhysicalMachine().startVirtualMachine(app.getSize(), - app.getRam(), app.getCpu(), vmType); - } catch (OutOfPMsException e) { - // LOG.error("failed to start PM.", e); - if (federation.askToOutsource(app)) { - insertOutsourcedStartEvent(currTime + 1, app); - } else - LOG.info("delaying the start of:" + app); - return; - } - } - vm.startApplication(app); - app.setRunningOn(vm); - insertStopEvent(currTime + app.getDuration(), app); - delayedApps.remove(app); - } - } - /** * Check if we can free up a VM to shut it down. */ -- 2.43.0