All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudbus.cloudsim.allocationpolicies.migration.VmAllocationPolicyMigrationBestFitStaticThreshold Maven / Gradle / Ivy

Go to download

CloudSim Plus: A modern, highly extensible and easier-to-use Java 8 Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services

There is a newer version: 8.0.0
Show newest version
/*
 * 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.Comparator;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Stream;

/**
 * A {@link VmAllocationPolicy} that uses a Static CPU utilization Threshold (THR) to
 * detect host {@link #getUnderUtilizationThreshold() under} and
 * {@link #getOverUtilizationThreshold(Host)} over} utilization.
 *
 * 

It's a Best Fit policy which selects the Host having the most used amount of CPU * MIPS to place a given VM, disregarding energy consumption.

* * @author Anton Beloglazov * @author Manoel Campos da Silva Filho * @since CloudSim Plus 1.0 */ public class VmAllocationPolicyMigrationBestFitStaticThreshold extends VmAllocationPolicyMigrationStaticThreshold { public VmAllocationPolicyMigrationBestFitStaticThreshold( 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 VmAllocationPolicyMigrationBestFitStaticThreshold( final PowerVmSelectionPolicy vmSelectionPolicy, final double overUtilizationThreshold, final BiFunction> findHostForVmFunction) { super(vmSelectionPolicy, overUtilizationThreshold, findHostForVmFunction); } /** * Gets the Host having the least available MIPS capacity (max used MIPS). * *

This method is ignoring the additional filtering performed by the super class. * This way, Host selection is performed ignoring energy consumption. * However, all the basic filters defined in the super class are ensured, since * this method is called just after they are applied. *

* * @param vm {@inheritDoc} * @param hostStream {@inheritDoc} * @return {@inheritDoc} */ @Override protected Optional findHostForVmInternal(final Vm vm, final Stream hostStream) { /*It's ignoring the super class intentionally to avoid the additional filtering performed there * and to apply a different method to select the Host to place the VM.*/ return hostStream.max(Comparator.comparingDouble(Host::getUtilizationOfCpuMips)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy