diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-05-07 12:33:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-07 12:33:39 +0200 |
| commit | ad20465a5df47b49561bb0afbdda5cd65c5da4b8 (patch) | |
| tree | 268f0fde5924b71ca2750dbbbba4cbe24c361f12 /opendc-compute/opendc-compute-service/src/main/kotlin | |
| parent | 7c0691eb6c348d2e49da3ef354b652cf26604905 (diff) | |
Revamped failure models (#228)
Diffstat (limited to 'opendc-compute/opendc-compute-service/src/main/kotlin')
3 files changed, 12 insertions, 8 deletions
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt index cdcd1af0..41118386 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt @@ -101,6 +101,7 @@ public class FilterScheduler( filteredHosts } + // fixme: currently finding no matching hosts can result in an error return when (val maxSize = min(subsetSize, subset.size)) { 0 -> null 1 -> subset[0] diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/ComputeFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/ComputeFilter.kt index 23590c13..dd707f60 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/ComputeFilter.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/ComputeFilter.kt @@ -34,7 +34,8 @@ public class ComputeFilter : HostFilter { host: HostView, server: Server, ): Boolean { - return host.host.state == HostState.UP + val result = host.host.state == HostState.UP + return result } override fun toString(): String = "ComputeFilter" diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt index 4792a7a0..d8c3d540 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt @@ -35,19 +35,21 @@ public class RamFilter(private val allocationRatio: Double) : HostFilter { host: HostView, server: Server, ): Boolean { - val requested = server.flavor.memorySize - val available = host.availableMemory - val total = host.host.model.memoryCapacity + val requestedMemory = server.flavor.memorySize + val availableMemory = host.availableMemory + val memoryCapacity = host.host.model.memoryCapacity // Do not allow an instance to overcommit against itself, only against // other instances. - if (requested > total) { + if (requestedMemory > memoryCapacity) { return false } - val limit = total * allocationRatio - val used = total - available + val limit = memoryCapacity * allocationRatio + val used = memoryCapacity - availableMemory val usable = limit - used - return usable >= requested + + val result = usable >= requestedMemory + return result } } |
