org.cloudbus.cloudsim.selectionpolicies.power.PowerVmSelectionPolicyRandomSelection 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.selectionpolicies.power;
import java.util.List;
import org.cloudbus.cloudsim.distributions.ContinuousDistribution;
import org.cloudbus.cloudsim.distributions.UniformDistr;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.vms.Vm;
/**
* A VM selection policy that randomly select VMs to migrate from a host.
*
*
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 PowerVmSelectionPolicyRandomSelection extends PowerVmSelectionPolicy {
private final ContinuousDistribution rand;
public PowerVmSelectionPolicyRandomSelection(){
super();
rand = new UniformDistr();
}
@Override
public Vm getVmToMigrate(Host host) {
final List migratableVms = getMigratableVms(host);
if (migratableVms.isEmpty()) {
return Vm.NULL;
}
final int index = (int)rand.sample()*migratableVms.size();
return migratableVms.get(index);
}
}