Optimizations only on one host !

This commit is contained in:
wescoeur 2016-02-26 11:07:22 +01:00
parent bec2e3b4a0
commit 087a71367d

View File

@ -209,33 +209,33 @@ class Plan {
// 1. Check if a ressource's utilization exceeds threshold. // 1. Check if a ressource's utilization exceeds threshold.
const avgNow = computeRessourcesAverage(hosts, hostsStats, EXECUTION_DELAY) const avgNow = computeRessourcesAverage(hosts, hostsStats, EXECUTION_DELAY)
let exceeded = checkRessourcesThresholds(hosts, avgNow) let exceededHosts = checkRessourcesThresholds(hosts, avgNow)
// No ressource's utilization problem. // No ressource's utilization problem.
if (exceeded.length === 0) { if (exceededHosts.length === 0) {
return return
} }
// 2. Check in the last 30 min interval with ratio. // 2. Check in the last 30 min interval with ratio.
const avgBefore = computeRessourcesAverage(hosts, hostsStats, MINUTES_OF_HISTORICAL_DATA) const avgBefore = computeRessourcesAverage(hosts, hostsStats, MINUTES_OF_HISTORICAL_DATA)
const avgWithRatio = computeRessourcesAverageWithRatio(exceeded, avgNow, avgBefore, 0.75) const avgWithRatio = computeRessourcesAverageWithRatio(exceededHosts, avgNow, avgBefore, 0.75)
exceeded = checkRessourcesThresholds(hosts, avgWithRatio) exceededHosts = checkRessourcesThresholds(exceededHosts, avgWithRatio)
// No ressource's utilization problem. // No ressource's utilization problem.
if (exceeded.length === 0) { if (exceededHosts.length === 0) {
return return
} }
// 3. Reorder the exceeded hosts by priority. // 3. Reorder the exceeded hosts by priority.
exceeded.sort((a, b) => { exceededHosts.sort((a, b) => {
a = avgWithRatio[a.id] a = avgWithRatio[a.id]
b = avgWithRatio[b.id] b = avgWithRatio[b.id]
return (b.cpus - a.cpus) || (a.memoryFree - b.memoryFree) return (b.cpus - a.cpus) || (a.memoryFree - b.memoryFree)
}) })
// 4. Search bests combinations... // 4. Search bests combinations for the worst host.
const optimizations = await this._computeOptimizations(hosts, exceeded, { const optimizations = await this._computeOptimizations(exceededHosts[0], {
now: avgNow, now: avgNow,
before: avgBefore, before: avgBefore,
withRatio: avgWithRatio withRatio: avgWithRatio
@ -249,7 +249,8 @@ class Plan {
throw new Error('not yet implemented') throw new Error('not yet implemented')
} }
async _computeOptimizations (hosts, exceeded, hostsAverages) { async _computeOptimizations (exceededHost, hostsAverages) {
// Get the vms and stats from exceeded hosts.
const vms = await this._getVms(exceeded) const vms = await this._getVms(exceeded)
const vmsStats = await this._getVmsStats(vms, 'minutes') const vmsStats = await this._getVmsStats(vms, 'minutes')