org.cloudbus.cloudsim.selectionpolicies.VmSelectionPolicyMinimumMigrationTime 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;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.vms.Vm;
import java.util.List;
/**
* A VM selection policy that selects for migration the VM with Minimum Migration Time (MMT).
*
*
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 VmSelectionPolicyMinimumMigrationTime implements VmSelectionPolicy {
@Override
public Vm getVmToMigrate(final Host host) {
final List migratableVms = host.getMigratableVms();
if (migratableVms.isEmpty()) {
return Vm.NULL;
}
Vm vmToMigrate = Vm.NULL;
double minMetric = Double.MAX_VALUE;
for (final Vm vm : migratableVms) {
if (vm.isInMigration()) {
continue;
}
/*@TODO It must compute the migration time based on the current RAM usage, not the capacity.
* It should also consider the VM size.*/
final double metric = vm.getRam().getCapacity();
if (metric < minMetric) {
minMetric = metric;
vmToMigrate = vm;
}
}
return vmToMigrate;
}
}