use of org.ovirt.engine.core.bll.scheduling.utils.VdsCpuUsageComparator in project ovirt-engine by oVirt.
the class CpuAndMemoryBalancingPolicyUnit method getUnderUtilizedCPUHosts.
/**
* Get hosts where the CPU is currently loaded to less than lowUtilization percents,
* and which were over-utilized (in average) for more than cpuOverCommitDurationMinutes.
*
* Also filter out hosts with less than minVmCount VMs.
*
* minVmCount is useful for using this method to find a source of VMs for migration
* (we do not care about hosts that have no VMs in that case). If you are looking
* for a destination candidates, pass 0 there.
*
* @param relevantHosts - candidate hosts
* @param lowUtilization - load threshold in percent
* @param minVmCount - minimal number of VMs on a host
* @param cpuOverCommitDurationMinutes - time limit in minutes
*/
protected List<VDS> getUnderUtilizedCPUHosts(Collection<VDS> relevantHosts, final int lowUtilization, final int minVmCount, final int cpuOverCommitDurationMinutes) {
List<VDS> underUtilizedHosts = relevantHosts.stream().filter(p -> (p.getUsageCpuPercent() + calcSpmCpuConsumption(p)) < lowUtilization && p.getVmCount() >= minVmCount && (p.getCpuOverCommitTimestamp() == null || (getTime().getTime() - p.getCpuOverCommitTimestamp().getTime()) >= TimeUnit.MINUTES.toMillis(cpuOverCommitDurationMinutes))).collect(Collectors.toList());
if (underUtilizedHosts.size() > 1) {
// Assume all hosts belong to the same cluster
Cluster cluster = clusterDao.get(underUtilizedHosts.get(0).getClusterId());
Collections.sort(underUtilizedHosts, new VdsCpuUsageComparator(cluster != null && cluster.getCountThreadsAsCores(), slaValidator));
}
return underUtilizedHosts;
}
use of org.ovirt.engine.core.bll.scheduling.utils.VdsCpuUsageComparator in project ovirt-engine by oVirt.
the class CpuAndMemoryBalancingPolicyUnit method getOverUtilizedCPUHosts.
/**
* Get hosts where the CPU has been utilized to more than highUtilization percentage for
* more than cpuOverCommitDurationMinutes minutes.
*
* @param relevantHosts - candidate hosts
* @param highUtilization - threshold cpu usage in percents
* @param cpuOverCommitDurationMinutes - time limit in minutes
* @return - over utilized hosts
*/
protected List<VDS> getOverUtilizedCPUHosts(Collection<VDS> relevantHosts, final int highUtilization, final int cpuOverCommitDurationMinutes) {
List<VDS> overUtilizedHosts = relevantHosts.stream().filter(p -> (p.getUsageCpuPercent() + calcSpmCpuConsumption(p)) >= highUtilization && p.getCpuOverCommitTimestamp() != null && (getTime().getTime() - p.getCpuOverCommitTimestamp().getTime()) >= TimeUnit.MINUTES.toMillis(cpuOverCommitDurationMinutes) && p.getVmCount() > 0).collect(Collectors.toList());
if (overUtilizedHosts.size() > 1) {
// Assume all hosts belong to the same cluster
Cluster cluster = clusterDao.get(overUtilizedHosts.get(0).getClusterId());
Collections.sort(overUtilizedHosts, new VdsCpuUsageComparator(cluster != null && cluster.getCountThreadsAsCores(), slaValidator).reversed());
}
return overUtilizedHosts;
}
Aggregations