org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyFirstFit 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;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.vms.Vm;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* An First Fit VM allocation policy
* which finds the first Host having suitable resources to place a given VM.
*
* NOTE: This policy doesn't perform optimization of VM allocation (placement)
* by means of VM migration.
*
* If you are using any algorithms, policies or workload included in the power package please cite
* the following paper:
*
*
*
* @author Anton Beloglazov
* @author Manoel Campos da Silva Filho
* @since CloudSim Toolkit 3.0
*/
public class VmAllocationPolicyFirstFit extends VmAllocationPolicyAbstract implements VmAllocationPolicy {
@Override
public Optional findHostForVm(final Vm vm) {
return this.getHostList()
.stream()
.sorted()
.filter(h -> h.isSuitableForVm(vm))
.findFirst();
}
/**
* This implementation doesn't perform any
* VM placement optimization and, in fact, has no effect.
*
* @param vmList the list of VMs
* @return an empty map to indicate that it never performs optimization
*/
@Override
public Map getOptimizedAllocationMap(final List vmList) {
return Collections.EMPTY_MAP;
}
}