diff options
Diffstat (limited to 'simulator/opendc-compute')
2 files changed, 3 insertions, 3 deletions
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ComparableAllocationPolicyLogic.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ComparableAllocationPolicyLogic.kt index 6aff2bab..8defe8b7 100644 --- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ComparableAllocationPolicyLogic.kt +++ b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ComparableAllocationPolicyLogic.kt @@ -44,6 +44,6 @@ public interface ComparableAllocationPolicyLogic : AllocationPolicy.Logic { val fitsCpu = hv.server.flavor.cpuCount >= image.flavor.cpuCount fitsMemory && fitsCpu } - .minWith(comparator.thenBy { it.server.uid }) + .minWithOrNull(comparator.thenBy { it.server.uid }) } } diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ReplayAllocationPolicy.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ReplayAllocationPolicy.kt index fda863bb..5312f4da 100644 --- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ReplayAllocationPolicy.kt +++ b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/allocation/ReplayAllocationPolicy.kt @@ -46,10 +46,10 @@ public class ReplayAllocationPolicy(private val vmPlacements: Map<String, String 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 hypervisors.maxByOrNull { it.availableMemory } } - return machinesInCluster.maxBy { it.availableMemory } + return machinesInCluster.maxByOrNull { it.availableMemory } ?: throw IllegalStateException("Cloud not find any machine and could not randomly assign") } } |
