From 439d63e0d0556677d9d8ae5b08283386ba9edc8c Mon Sep 17 00:00:00 2001 From: Sabir Mohammedi Taieb <52837091+Sabir97@users.noreply.github.com> Date: Wed, 4 Mar 2020 12:49:26 +0100 Subject: [PATCH 1/3] Migration Time and Migration Energy Added new methods to get the migration time and migration energy from the simulation --- .../cloudsim/power/PowerDatacenter.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java b/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java index 5462077de..e4c03fc33 100644 --- a/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java +++ b/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java @@ -51,6 +51,12 @@ public class PowerDatacenter extends Datacenter { /** The VM migration count. */ private int migrationCount; + + // Migration Time + public double Tmigr = 0; + + // Migration Energy + public double Emigr; /** * Instantiates a new PowerDatacenter. @@ -100,6 +106,13 @@ protected void updateCloudletProcessing() { Vm vm = (Vm) migrate.get("vm"); PowerHost targetHost = (PowerHost) migrate.get("host"); PowerHost oldHost = (PowerHost) vm.getHost(); + + // Calculates migration time and energy + double Cj = vm.getRam(); + double BWj = vm.getBw(); + Tmigr = Tmigr + Cj/BWj; + sum = sum + Pm*(Cj/BWj); + Emigr = 4*sum; if (oldHost == null) { Log.formatLine( @@ -140,6 +153,8 @@ protected void updateCloudletProcessing() { setLastProcessTime(currentTime); } + setMigrationTime(Tmigr); // Update Total Migration Time + setMigrationEnergy(Emigr); // Update Total Migration Energy } /** @@ -355,5 +370,22 @@ protected void setMigrationCount(int migrationCount) { protected void incrementMigrationCount() { setMigrationCount(getMigrationCount() + 1); } + + // sets migration time + public void setMigrationTime(double Tm){ + Tmigr = Tm; + } + //gets migration time + public double getMigrationTime(){ + return Tmigr; + } + //sets migration Energy + public void setMigrationEnergy(double Em){ + Emigr = Em; + } + //gets total migration energy + public double getMigrationEnergy(){ + return Emigr; + } } From 085310b174040b87c57083a2f3a7373faa8a207c Mon Sep 17 00:00:00 2001 From: Sabir Mohammedi Taieb <52837091+Sabir97@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:05:49 +0100 Subject: [PATCH 2/3] Update PowerDatacenter.java --- .../main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java b/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java index e4c03fc33..120e9317f 100644 --- a/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java +++ b/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java @@ -90,6 +90,8 @@ protected void updateCloudletProcessing() { return; } double currentTime = CloudSim.clock(); + double Pm = 4.5; // Unit of energy communication between Vms + double sum = 0; // if some time passed since last processing if (currentTime > getLastProcessTime()) { From 22b0e3c3ef20632b8bc10dca1cc1b1c735d48a55 Mon Sep 17 00:00:00 2001 From: Sabir Mohammedi Taieb <52837091+Sabir97@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:07:15 +0100 Subject: [PATCH 3/3] Update PowerDatacenter.java --- .../main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java b/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java index 120e9317f..94349ac86 100644 --- a/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java +++ b/modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java @@ -90,7 +90,7 @@ protected void updateCloudletProcessing() { return; } double currentTime = CloudSim.clock(); - double Pm = 4.5; // Unit of energy communication between Vms + double Pm = 4.5; // VMs communication energy unit double sum = 0; // if some time passed since last processing