Commit 17dd17f5 authored by Rafael Vieira Falcão's avatar Rafael Vieira Falcão
Browse files

Implementing new SLA/Creation of Tight hosts algorithm

parent bbe1814b
......@@ -19,7 +19,8 @@ import org.cloudbus.cloudsim.vms.Vm;
* versa.
*
* The creation of the 'Tight' hosts is dynamic. Although,
* the maximum number of 'Tight' hosts is static
* the maximum number of 'Tight' hosts is static and depends of
* the variable 'vmsThreshold'.
*
* For more information, please refer to this paper:
*
......@@ -29,10 +30,13 @@ import org.cloudbus.cloudsim.vms.Vm;
public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPolicyMigrationSla {
private int vmsThreshold = 0;
private int limitTightHosts = 0;
private int actualTightHosts = 0;
public VmAllocationPolicyMigrationSlaFixedTightHost(VmAllocationPolicy allocationPolicy, int migrationTime, int vmTresshold) {
public VmAllocationPolicyMigrationSlaFixedTightHost(VmAllocationPolicy allocationPolicy, int migrationTime, int vmTresshold, int limitTightHosts) {
super(allocationPolicy, migrationTime);
setVmsThreshold(vmTresshold);
setLimitTightHosts(limitTightHosts);
}
@Override
......@@ -41,16 +45,24 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
int numberCreditVms = getVmsWithEnoughCredit(getHostsWithLooseSla()).size();
if(numberCreditVms >= getVmsThreshold()) {
// Check if the number of vms with credit also consider the vms with credit that are
// in the Tight hosts (Check vms that are current migrating)
if(numberCreditVms >= getVmsThreshold() && actualTightHosts < getLimitTightHosts()) {
// The Tight host can be created
// Select the Loose host with more credit Vms
Host bestCandidateHost = getHostCandidate();
// Make it a Tight host
bestCandidateHost.setIopsProvisioner(new ResourceProvisionerShared());
// Increse the number of Tight hosts
actualTightHosts++;
}
// Run Migration Sla Algorithm
return super.getOptimizedAllocationMap(vmList);
Map<Vm, Host> migrationMap = super.getOptimizedAllocationMap(vmList);
// Consolidate Loose hosts
return migrationMap;
}
/*
......@@ -64,18 +76,19 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
final double clock = getDatacenter().getSimulation().clock();
int actualHighestCreditVms = 0;
int currentHighestCreditVms = 0;
Host bestCandidateHost = null;
for (Host host : looseHosts) {
for (Host host : looseHosts) {
// Check how good candidate this host is
int creditVms = 0;
for (Vm vm : host.getVmList()) {
if (vm.getMonitor().getVmCredit(clock) - getMIGRATION_TIME() > 0) {
creditVms++;
}
}
if(creditVms > actualHighestCreditVms) {
actualHighestCreditVms = creditVms;
if(creditVms > currentHighestCreditVms) {
currentHighestCreditVms = creditVms;
bestCandidateHost = host;
}
}
......@@ -83,6 +96,10 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
return bestCandidateHost;
}
private boolean isTightHost(Host host) {
return host.getIopsProvisioner() instanceof ResourceProvisionerShared;
}
private int getVmsThreshold() {
return vmsThreshold;
}
......@@ -91,4 +108,11 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
this.vmsThreshold = newThreshold;
}
private int getLimitTightHosts() {
return limitTightHosts;
}
private void setLimitTightHosts(int newLimit) {
this.limitTightHosts = newLimit;
}
}
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