Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration Time and Migration Energy #136

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -84,6 +90,8 @@ protected void updateCloudletProcessing() {
return;
}
double currentTime = CloudSim.clock();
double Pm = 4.5; // VMs communication energy unit
double sum = 0;

// if some time passed since last processing
if (currentTime > getLastProcessTime()) {
Expand All @@ -100,6 +108,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(
Expand Down Expand Up @@ -140,6 +155,8 @@ protected void updateCloudletProcessing() {

setLastProcessTime(currentTime);
}
setMigrationTime(Tmigr); // Update Total Migration Time
setMigrationEnergy(Emigr); // Update Total Migration Energy
}

/**
Expand Down Expand Up @@ -355,5 +372,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;
}

}