Commit 163c51e4 authored by Anton Beloglazov's avatar Anton Beloglazov

- Added handling null migrationMap

parent ef051eb2
...@@ -147,25 +147,27 @@ public class PowerDatacenter extends Datacenter { ...@@ -147,25 +147,27 @@ public class PowerDatacenter extends Datacenter {
if (!isDisableMigrations()) { if (!isDisableMigrations()) {
List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(getVmList()); List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(getVmList());
for (Map<String, Object> migrate : migrationMap) { if (migrationMap != null) {
Vm vm = (Vm) migrate.get("vm"); for (Map<String, Object> migrate : migrationMap) {
PowerHost targetHost = (PowerHost) migrate.get("host"); Vm vm = (Vm) migrate.get("vm");
PowerHost oldHost = (PowerHost) vm.getHost(); PowerHost targetHost = (PowerHost) migrate.get("host");
PowerHost oldHost = (PowerHost) vm.getHost();
targetHost.addMigratingInVm(vm);
targetHost.addMigratingInVm(vm);
if (oldHost == null) {
Log.formatLine("%.2f: Migration of VM #%d to Host #%d is started", CloudSim.clock(), vm.getId(), targetHost.getId()); if (oldHost == null) {
} else { Log.formatLine("%.2f: Migration of VM #%d to Host #%d is started", CloudSim.clock(), vm.getId(), targetHost.getId());
Log.formatLine("%.2f: Migration of VM #%d from Host #%d to Host #%d is started", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId()); } else {
Log.formatLine("%.2f: Migration of VM #%d from Host #%d to Host #%d is started", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId());
}
incrementMigrationCount();
vm.setInMigration(true);
/** VM migration delay = RAM / bandwidth + C (C = 10 sec) **/
send(getId(), vm.getRam() / ((double) vm.getBw() / 8000) + 0, CloudSimTags.VM_MIGRATE, migrate);
} }
incrementMigrationCount();
vm.setInMigration(true);
/** VM migration delay = RAM / bandwidth + C (C = 10 sec) **/
send(getId(), vm.getRam() / ((double) vm.getBw() / 8000) + 0, CloudSimTags.VM_MIGRATE, migrate);
} }
} }
......
...@@ -121,25 +121,27 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter { ...@@ -121,25 +121,27 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter {
if (!isDisableMigrations()) { if (!isDisableMigrations()) {
List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(getVmList()); List<Map<String, Object>> migrationMap = getVmAllocationPolicy().optimizeAllocation(getVmList());
for (Map<String, Object> migrate : migrationMap) { if (migrationMap != null) {
Vm vm = (Vm) migrate.get("vm"); for (Map<String, Object> migrate : migrationMap) {
PowerHost targetHost = (PowerHost) migrate.get("host"); Vm vm = (Vm) migrate.get("vm");
PowerHost oldHost = (PowerHost) vm.getHost(); PowerHost targetHost = (PowerHost) migrate.get("host");
PowerHost oldHost = (PowerHost) vm.getHost();
targetHost.addMigratingInVm(vm);
targetHost.addMigratingInVm(vm);
if (oldHost == null) {
Log.formatLine("%.2f: Migration of VM #%d to Host #%d is started", CloudSim.clock(), vm.getId(), targetHost.getId()); if (oldHost == null) {
} else { Log.formatLine("%.2f: Migration of VM #%d to Host #%d is started", CloudSim.clock(), vm.getId(), targetHost.getId());
Log.formatLine("%.2f: Migration of VM #%d from Host #%d to Host #%d is started", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId()); } else {
Log.formatLine("%.2f: Migration of VM #%d from Host #%d to Host #%d is started", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId());
}
incrementMigrationCount();
vm.setInMigration(true);
/** VM migration delay = RAM / bandwidth + C (C = 10 sec) **/
send(getId(), vm.getRam() / ((double) vm.getBw() / 8000) + 10, CloudSimTags.VM_MIGRATE, migrate);
} }
incrementMigrationCount();
vm.setInMigration(true);
/** VM migration delay = RAM / bandwidth + C (C = 10 sec) **/
send(getId(), vm.getRam() / ((double) vm.getBw() / 8000) + 10, CloudSimTags.VM_MIGRATE, migrate);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment