1 package at.ac.tuwien.lsdc.sched;
4 import java.io.IOException;
7 import at.ac.tuwien.lsdc.types.Application;
8 import at.ac.tuwien.lsdc.types.PhysicalMachine;
9 import at.ac.tuwien.lsdc.types.ScenarioType;
10 import at.ac.tuwien.lsdc.types.VirtualMachine;
12 public abstract class AbstractSchedulerWithMigration extends AbstractScheduler {
14 public AbstractSchedulerWithMigration(int numPMs, int numCloudPartners, File schedulerLog,
15 ScenarioType scenario) throws IOException {
16 super(numPMs, numCloudPartners, schedulerLog, scenario);
20 * Check if we can free up a VM to shut it down.
23 protected void runMigration() {
24 List<PhysicalMachine> pms = manager.getSortedPMs();
25 // iterate through all the PMs (except the one with the highest utilization)
26 for (int i = 0; i < (pms.size() - 1); i++) {
27 PhysicalMachine currentPM = pms.get(i);
28 if (currentPM.isRunning() && (currentPM.getTotalVMs() > 0)) {
29 VirtualMachine currentVM = currentPM.getVirtualMachines().values().iterator()
31 for (Application app : currentVM.getApplications()) {
32 for (int j = i; i < pms.size(); i++) {
33 PhysicalMachine nextPM = pms.get(j);
34 if (nextPM.isRunning() && (nextPM.getTotalVMs() > 0)) {
35 VirtualMachine nextVM = nextPM.getVirtualMachines().values().iterator()
37 if (deployApp(nextVM, app)) {
38 currentVM.stopApplication(app);
44 if (currentVM.getApplications().size() == 0) {
45 currentPM.stopVirtualMachine(currentVM);
46 if (currentPM.getTotalVMs() == 0) {
47 manager.stopPhysicalMachine(currentPM.getId());
54 protected abstract boolean deployApp(VirtualMachine vm, Application app);