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

org.cloudbus.cloudsim.allocationpolicies.migration.VmAllocationPolicyMigrationWorstFitStaticThreshold 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 java.util.Comparator;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Stream;

import org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicy;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.vms.Vm;
import org.cloudbus.cloudsim.selectionpolicies.power.PowerVmSelectionPolicy;

/**
 * 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 Worst Fit policy which selects the Host having the least 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 VmAllocationPolicyMigrationWorstFitStaticThreshold extends VmAllocationPolicyMigrationStaticThreshold { public VmAllocationPolicyMigrationWorstFitStaticThreshold( final PowerVmSelectionPolicy vmSelectionPolicy, final double overUtilizationThreshold) { super(vmSelectionPolicy, overUtilizationThreshold); } /** * 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 VmAllocationPolicyMigrationWorstFitStaticThreshold( final PowerVmSelectionPolicy vmSelectionPolicy, final double overUtilizationThreshold, final BiFunction> findHostForVmFunction) { super(vmSelectionPolicy, overUtilizationThreshold, findHostForVmFunction); } /** * Gets the Host having the most available MIPS capacity (min 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 to intentionally avoid the additional filtering performed there * and to apply a different method to select the Host to place the VM.*/ return hostStream.min(Comparator.comparingDouble(Host::getUtilizationOfCpuMips)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy