diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-05-21 11:42:56 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-05-21 11:42:56 +0200 |
| commit | 128ee618c81820f5d44f5d309a5b222bf0787acd (patch) | |
| tree | a8c83723dae5223b2c5443f64587fcbc38c492b7 /opendc/opendc-compute | |
| parent | 70ad01d793f88b1bef7d7988d24bff384ddbb3b9 (diff) | |
| parent | f6f685196d6579d9866d2a04c2c01a63e8c169d7 (diff) | |
Merge branch '2.x-azure' into '2.x'
Add Azure trace reader
See merge request opendc/opendc-simulator!68
Diffstat (limited to 'opendc/opendc-compute')
| -rw-r--r-- | opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/allocation/ReplayAllocationPolicy.kt | 13 |
1 files changed, 11 insertions, 2 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 f88eaed8..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 @@ -2,9 +2,12 @@ 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 + +private val logger = KotlinLogging.logger {} /** - * Policy replaying VM-cluster assignnment. + * Policy replaying VM-cluster assignment. * * Within each cluster, the active servers on each node determine which node gets * assigned the VM image. @@ -18,8 +21,14 @@ class ReplayAllocationPolicy(val vmPlacements: Map<String, String>) : Allocation val clusterName = vmPlacements[image.name] ?: throw IllegalStateException("Could not find placement data in VM placement file for VM ${image.name}") val machinesInCluster = hypervisors.filter { it.server.name.contains(clusterName) } + + if (machinesInCluster.isEmpty()) { + logger.info { "Could not find any machines belonging to cluster $clusterName for image ${image.name}, assigning randomly." } + return hypervisors.maxBy { it.availableMemory } + } + return machinesInCluster.maxBy { it.availableMemory } - ?: throw IllegalStateException("Cloud not find any machines belonging to cluster $clusterName for image ${image.name}") + ?: throw IllegalStateException("Cloud not find any machine and could not randomly assign") } } } |
