org.cloudbus.cloudsim.allocationpolicies.migration.VmAllocationPolicyMigrationStaticThreshold 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.allocationpolicies.VmAllocationPolicy;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.selectionpolicies.power.PowerVmSelectionPolicy;
import org.cloudbus.cloudsim.vms.Vm;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
/**
* A VM allocation policy that uses a static CPU utilization threshold to detect
* host over utilization.
* It's a First Fit policy which selects the first found 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 VmAllocationPolicyMigrationStaticThreshold extends VmAllocationPolicyMigrationAbstract {
/**
* @see #getOverUtilizationThreshold(Host)
*/
private double overUtilizationThreshold = 0.9;
/**
* Creates a VmAllocationPolicyMigrationStaticThreshold.
*
* @param vmSelectionPolicy the policy that defines how VMs are selected for migration
* @param overUtilizationThreshold the over utilization threshold
*/
public VmAllocationPolicyMigrationStaticThreshold(
final PowerVmSelectionPolicy vmSelectionPolicy,
final double overUtilizationThreshold)
{
this(vmSelectionPolicy, overUtilizationThreshold, null);
}
/**
* Creates a new VmAllocationPolicy, changing the {@link Function} to select a Host for a Vm.
* @param vmSelectionPolicy the policy that defines how VMs are selected for migration
* @param overUtilizationThreshold the over utilization threshold
* @param findHostForVmFunction a {@link Function} to select a Host for a given Vm.
* Passing null makes the Function to be set as the default {@link #findHostForVm(Vm)}.
* @see VmAllocationPolicy#setFindHostForVmFunction(java.util.function.BiFunction)
*/
public VmAllocationPolicyMigrationStaticThreshold(
final PowerVmSelectionPolicy vmSelectionPolicy,
final double overUtilizationThreshold,
final BiFunction> findHostForVmFunction)
{
super(vmSelectionPolicy, findHostForVmFunction);
setOverUtilizationThreshold(overUtilizationThreshold);
}
/**
* Sets the static host CPU utilization threshold to detect over
* utilization.
*
* @param overUtilizationThreshold the overUtilizationThreshold to set
*/
public final void setOverUtilizationThreshold(final double overUtilizationThreshold) {
this.overUtilizationThreshold = overUtilizationThreshold;
}
/**
* Gets the static host CPU utilization threshold to detect over
* utilization. It is a percentage value from 0 to 1 that can be changed
* when creating an instance of the class.
*
*
* This implementation always returns the same over utilization threshold for any
* given host
*
* @param host {@inheritDoc}
* @return {@inheritDoc} (that is the same for any given host)
*/
@Override
public double getOverUtilizationThreshold(Host host) {
return overUtilizationThreshold;
}
}