From 78bf43a33ade79ccd412ee849c15069fdb728608 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 20 May 2020 15:10:15 +0200 Subject: Make replay smarter --- .../opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt index 9e675e80..59acfce2 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt @@ -3,7 +3,6 @@ package com.atlarge.opendc.compute.virt.service.allocation import com.atlarge.opendc.compute.virt.service.HypervisorView import com.atlarge.opendc.compute.virt.service.SimpleVirtProvisioningService import mu.KotlinLogging -import kotlin.random.Random private val logger = KotlinLogging.logger {} @@ -13,7 +12,7 @@ private val logger = KotlinLogging.logger {} * Within each cluster, the active servers on each node determine which node gets * assigned the VM image. */ -class ReplayAllocationPolicy(val vmPlacements: Map, val random: Random = Random(0)) : AllocationPolicy { +class ReplayAllocationPolicy(val vmPlacements: Map) : AllocationPolicy { override fun invoke(): AllocationPolicy.Logic = object : AllocationPolicy.Logic { override fun select( hypervisors: Set, @@ -25,7 +24,7 @@ class ReplayAllocationPolicy(val vmPlacements: Map, val random: if (machinesInCluster.isEmpty()) { logger.info { "Could not find any machines belonging to cluster $clusterName for image ${image.name}, assigning randomly." } - return hypervisors.random(random) + return hypervisors.maxBy { it.availableMemory } } return machinesInCluster.maxBy { it.availableMemory } -- cgit v1.2.3