diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-05-20 15:10:15 +0200 |
|---|---|---|
| committer | Georgios Andreadis <info@gandreadis.com> | 2020-05-20 16:02:43 +0200 |
| commit | 78bf43a33ade79ccd412ee849c15069fdb728608 (patch) | |
| tree | a27be777dfd611377f11e2ed86c51bf87d4cb80a /opendc | |
| parent | 1e24e8934396bf2947c0d3bd244c29c0ecff98a1 (diff) | |
Make replay smarter
Diffstat (limited to 'opendc')
| -rw-r--r-- | opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt | 5 |
1 files 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<String, String>, val random: Random = Random(0)) : AllocationPolicy { +class ReplayAllocationPolicy(val vmPlacements: Map<String, String>) : AllocationPolicy { override fun invoke(): AllocationPolicy.Logic = object : AllocationPolicy.Logic { override fun select( hypervisors: Set<HypervisorView>, @@ -25,7 +24,7 @@ class ReplayAllocationPolicy(val vmPlacements: Map<String, String>, 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 } |
