org.cloudbus.cloudsim.allocationpolicies.migration.VmAllocationPolicyMigrationInterQuartileRange Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudsim-plus Show documentation
Show all versions of cloudsim-plus Show documentation
CloudSim Plus: A modern, highly extensible and easier-to-use Java 8 Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.allocationpolicies.migration;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.selectionpolicies.power.PowerVmSelectionPolicy;
import org.cloudbus.cloudsim.util.MathUtil;
/**
* A VM allocation policy that uses Inter Quartile Range (IQR) to compute
* a dynamic threshold in order to detect host over utilization.
* It's a Best Fit policy which selects the Host with most efficient power usage to place a given VM.
*
*
*
If you are using any algorithms, policies or workload included in the power package please cite
* the following paper:
*
*
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 3.0
*/
public class VmAllocationPolicyMigrationInterQuartileRange extends VmAllocationPolicyMigrationDynamicUpperThresholdFirstFit {
// 12 has been suggested as a safe value
private static final int MIN_NUM_OF_HISTORY_ENTRIES_TO_COMPUTE_IRQ = 12;
/**
* Creates a VmAllocationPolicyMigrationInterQuartileRange
* with a {@link #getSafetyParameter() safety parameter} equals to 0
* and no {@link #getFallbackVmAllocationPolicy() fallback policy}.
*
* @param vmSelectionPolicy the policy that defines how VMs are selected for migration
*/
public VmAllocationPolicyMigrationInterQuartileRange(final PowerVmSelectionPolicy vmSelectionPolicy) {
super(vmSelectionPolicy);
}
/**
* Creates a VmAllocationPolicyMigrationInterQuartileRange.
*
* @param vmSelectionPolicy the policy that defines how VMs are selected for migration
* @param safetyParameter the safety parameter
* @param fallbackPolicy the fallback VM allocation policy to be used when
* the over utilization host detection doesn't have data to be computed
*/
public VmAllocationPolicyMigrationInterQuartileRange(
final PowerVmSelectionPolicy vmSelectionPolicy,
final double safetyParameter, final
VmAllocationPolicyMigration fallbackPolicy)
{
super(vmSelectionPolicy, safetyParameter, fallbackPolicy);
}
/**
* Computes the host utilization IRQ used for generating the host over utilization threshold.
*
* @param host the host
* @return the host CPU utilization percentage IQR
*/
@Override
public double computeHostUtilizationMeasure(final Host host) throws IllegalArgumentException {
final double[] data = host.getUtilizationHistory();
if (MathUtil.countNonZeroBeginning(data) >= MIN_NUM_OF_HISTORY_ENTRIES_TO_COMPUTE_IRQ) {
return MathUtil.iqr(data);
}
throw new IllegalArgumentException("There is not enough Host history to compute Host utilization IRQ");
}
}