summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-service/src/main
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-03-05 13:23:57 +0100
committerGitHub <noreply@github.com>2024-03-05 13:23:57 +0100
commit5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec (patch)
tree5b2773b8dc21c2e1b526fb70f829c376dd80532a /opendc-compute/opendc-compute-service/src/main
parentd28002a3c151d198298574312f32f1cb43f3a660 (diff)
Updated package versions, updated web server tests. (#207)
* Updated all package versions including kotlin. Updated all web-server tests to run. * Changed the java version of the tests. OpenDC now only supports java 19. * small update * test update * new update * updated docker version to 19 * updated docker version to 19
Diffstat (limited to 'opendc-compute/opendc-compute-service/src/main')
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt91
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/FilterScheduler.kt51
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ReplayScheduler.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/ComputeFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/DifferentHostFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/HostFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/InstanceCountFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/SameHostFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/CoreRamWeigher.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/HostWeigher.kt12
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/InstanceCountWeigher.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/RamWeigher.kt5
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt6
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuWeigher.kt6
17 files changed, 142 insertions, 84 deletions
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt
index 2f071c13..18947146 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt
@@ -37,48 +37,61 @@ import java.util.random.RandomGenerator
/**
* Create a [ComputeScheduler] for the experiment.
*/
-public fun createComputeScheduler(name: String, seeder: RandomGenerator, placements: Map<String, String> = emptyMap()): ComputeScheduler {
+public fun createComputeScheduler(
+ name: String,
+ seeder: RandomGenerator,
+ placements: Map<String, String> = emptyMap(),
+): ComputeScheduler {
val cpuAllocationRatio = 16.0
val ramAllocationRatio = 1.5
return when (name) {
- "mem" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(RamWeigher(multiplier = 1.0))
- )
- "mem-inv" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(RamWeigher(multiplier = -1.0))
- )
- "core-mem" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(CoreRamWeigher(multiplier = 1.0))
- )
- "core-mem-inv" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(CoreRamWeigher(multiplier = -1.0))
- )
- "active-servers" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(InstanceCountWeigher(multiplier = -1.0))
- )
- "active-servers-inv" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(InstanceCountWeigher(multiplier = 1.0))
- )
- "provisioned-cores" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = 1.0))
- )
- "provisioned-cores-inv" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = -1.0))
- )
- "random" -> FilterScheduler(
- filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
- weighers = emptyList(),
- subsetSize = Int.MAX_VALUE,
- random = SplittableRandom(seeder.nextLong())
- )
+ "mem" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(RamWeigher(multiplier = 1.0)),
+ )
+ "mem-inv" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(RamWeigher(multiplier = -1.0)),
+ )
+ "core-mem" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(CoreRamWeigher(multiplier = 1.0)),
+ )
+ "core-mem-inv" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(CoreRamWeigher(multiplier = -1.0)),
+ )
+ "active-servers" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(InstanceCountWeigher(multiplier = -1.0)),
+ )
+ "active-servers-inv" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(InstanceCountWeigher(multiplier = 1.0)),
+ )
+ "provisioned-cores" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = 1.0)),
+ )
+ "provisioned-cores-inv" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = -1.0)),
+ )
+ "random" ->
+ FilterScheduler(
+ filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
+ weighers = emptyList(),
+ subsetSize = Int.MAX_VALUE,
+ random = SplittableRandom(seeder.nextLong()),
+ )
"replay" -> ReplayScheduler(placements)
else -> throw IllegalArgumentException("Unknown policy $name")
}
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 18a319e9..cdcd1af0 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
@@ -46,7 +46,7 @@ public class FilterScheduler(
private val filters: List<HostFilter>,
private val weighers: List<HostWeigher>,
private val subsetSize: Int = 1,
- private val random: RandomGenerator = SplittableRandom(0)
+ private val random: RandomGenerator = SplittableRandom(0),
) : ComputeScheduler {
/**
* The pool of hosts available to the scheduler.
@@ -69,36 +69,37 @@ public class FilterScheduler(
val hosts = hosts
val filteredHosts = hosts.filter { host -> filters.all { filter -> filter.test(host, server) } }
- val subset = if (weighers.isNotEmpty()) {
- val results = weighers.map { it.getWeights(filteredHosts, server) }
- val weights = DoubleArray(filteredHosts.size)
+ val subset =
+ if (weighers.isNotEmpty()) {
+ val results = weighers.map { it.getWeights(filteredHosts, server) }
+ val weights = DoubleArray(filteredHosts.size)
- for (result in results) {
- val min = result.min
- val range = (result.max - min)
+ for (result in results) {
+ val min = result.min
+ val range = (result.max - min)
- // Skip result if all weights are the same
- if (range == 0.0) {
- continue
- }
+ // Skip result if all weights are the same
+ if (range == 0.0) {
+ continue
+ }
- val multiplier = result.multiplier
- val factor = multiplier / range
+ val multiplier = result.multiplier
+ val factor = multiplier / range
- for ((i, weight) in result.weights.withIndex()) {
- weights[i] += factor * (weight - min)
+ for ((i, weight) in result.weights.withIndex()) {
+ weights[i] += factor * (weight - min)
+ }
}
- }
- weights.indices
- .asSequence()
- .sortedByDescending { weights[it] }
- .map { filteredHosts[it] }
- .take(subsetSize)
- .toList()
- } else {
- filteredHosts
- }
+ weights.indices
+ .asSequence()
+ .sortedByDescending { weights[it] }
+ .map { filteredHosts[it] }
+ .take(subsetSize)
+ .toList()
+ } else {
+ filteredHosts
+ }
return when (val maxSize = min(subsetSize, subset.size)) {
0 -> null
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ReplayScheduler.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ReplayScheduler.kt
index 4339b3de..a6703c89 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ReplayScheduler.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ReplayScheduler.kt
@@ -49,8 +49,9 @@ public class ReplayScheduler(private val vmPlacements: Map<String, String>) : Co
}
override fun select(server: Server): HostView? {
- val clusterName = vmPlacements[server.name]
- ?: throw IllegalStateException("Could not find placement data in VM placement file for VM ${server.name}")
+ val clusterName =
+ vmPlacements[server.name]
+ ?: throw IllegalStateException("Could not find placement data in VM placement file for VM ${server.name}")
val machinesInCluster = hosts.filter { it.host.name.contains(clusterName) }
if (machinesInCluster.isEmpty()) {
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 b562f838..23590c13 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
@@ -30,7 +30,10 @@ import org.opendc.compute.service.driver.HostState
* A [HostFilter] that filters on active hosts.
*/
public class ComputeFilter : HostFilter {
- override fun test(host: HostView, server: Server): Boolean {
+ override fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean {
return host.host.state == HostState.UP
}
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/DifferentHostFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/DifferentHostFilter.kt
index 4a9f41c5..df67a19f 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/DifferentHostFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/DifferentHostFilter.kt
@@ -30,7 +30,10 @@ import java.util.UUID
* A [HostFilter] that ensures an instance is scheduled on a different host from a set of instances.
*/
public class DifferentHostFilter : HostFilter {
- override fun test(host: HostView, server: Server): Boolean {
+ override fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean {
@Suppress("UNCHECKED_CAST")
val affinityUUIDs = server.meta["scheduler_hint:different_host"] as? Set<UUID> ?: return true
return host.host.instances.none { it.uid in affinityUUIDs }
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/HostFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/HostFilter.kt
index 78010fee..902c760e 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/HostFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/HostFilter.kt
@@ -34,5 +34,8 @@ public fun interface HostFilter {
* Test whether the specified [host] should be included in the selection
* for scheduling the specified [server].
*/
- public fun test(host: HostView, server: Server): Boolean
+ public fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean
}
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/InstanceCountFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/InstanceCountFilter.kt
index 5aa38a88..d9348802 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/InstanceCountFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/InstanceCountFilter.kt
@@ -31,7 +31,10 @@ import org.opendc.compute.service.HostView
* @param limit The maximum number of instances on the host.
*/
public class InstanceCountFilter(private val limit: Int) : HostFilter {
- override fun test(host: HostView, server: Server): Boolean {
+ override fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean {
return host.instanceCount < limit
}
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 275e8f1c..4792a7a0 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
@@ -31,7 +31,10 @@ import org.opendc.compute.service.HostView
* @param allocationRatio Virtual RAM to physical RAM allocation ratio.
*/
public class RamFilter(private val allocationRatio: Double) : HostFilter {
- override fun test(host: HostView, server: Server): Boolean {
+ override fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean {
val requested = server.flavor.memorySize
val available = host.availableMemory
val total = host.host.model.memoryCapacity
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/SameHostFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/SameHostFilter.kt
index c3753866..4c31c66a 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/SameHostFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/SameHostFilter.kt
@@ -30,7 +30,10 @@ import java.util.UUID
* A [HostFilter] that ensures an instance is scheduled on the same host as all other instances in a set of instances.
*/
public class SameHostFilter : HostFilter {
- override fun test(host: HostView, server: Server): Boolean {
+ override fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean {
@Suppress("UNCHECKED_CAST")
val affinityUUIDs = server.meta["scheduler_hint:same_host"] as? Set<UUID> ?: return true
return host.host.instances.any { it.uid in affinityUUIDs }
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt
index d4dff76b..e3397e50 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt
@@ -30,7 +30,10 @@ import org.opendc.compute.service.HostView
* capacity on the host.
*/
public class VCpuCapacityFilter : HostFilter {
- override fun test(host: HostView, server: Server): Boolean {
+ override fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean {
val requiredCapacity = server.flavor.meta["cpu-capacity"] as? Double
val hostModel = host.host.model
val availableCapacity = hostModel.cpuCapacity / hostModel.cpuCount
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt
index 448a6189..5d02873f 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt
@@ -31,7 +31,10 @@ import org.opendc.compute.service.HostView
* @param allocationRatio Virtual CPU to physical CPU allocation ratio.
*/
public class VCpuFilter(private val allocationRatio: Double) : HostFilter {
- override fun test(host: HostView, server: Server): Boolean {
+ override fun test(
+ host: HostView,
+ server: Server,
+ ): Boolean {
val requested = server.flavor.cpuCount
val total = host.host.model.cpuCount
val limit = total * allocationRatio
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/CoreRamWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/CoreRamWeigher.kt
index f79d6d88..d6aafbc7 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/CoreRamWeigher.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/CoreRamWeigher.kt
@@ -33,7 +33,10 @@ import org.opendc.compute.service.HostView
* memory.
*/
public class CoreRamWeigher(override val multiplier: Double = 1.0) : HostWeigher {
- override fun getWeight(host: HostView, server: Server): Double {
+ override fun getWeight(
+ host: HostView,
+ server: Server,
+ ): Double {
return host.availableMemory.toDouble() / host.host.model.cpuCount
}
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/HostWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/HostWeigher.kt
index 01799122..825cfff9 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/HostWeigher.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/HostWeigher.kt
@@ -38,12 +38,18 @@ public interface HostWeigher {
/**
* Obtain the weight of the specified [host] when scheduling the specified [server].
*/
- public fun getWeight(host: HostView, server: Server): Double
+ public fun getWeight(
+ host: HostView,
+ server: Server,
+ ): Double
/**
* Obtain the weights for [hosts] when scheduling the specified [server].
*/
- public fun getWeights(hosts: List<HostView>, server: Server): Result {
+ public fun getWeights(
+ hosts: List<HostView>,
+ server: Server,
+ ): Result {
val weights = DoubleArray(hosts.size)
var min = Double.MAX_VALUE
var max = Double.MIN_VALUE
@@ -70,6 +76,6 @@ public interface HostWeigher {
public val weights: DoubleArray,
public val min: Double,
public val max: Double,
- public val multiplier: Double
+ public val multiplier: Double,
)
}
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/InstanceCountWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/InstanceCountWeigher.kt
index bfb583a2..9e0a9517 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/InstanceCountWeigher.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/InstanceCountWeigher.kt
@@ -29,7 +29,10 @@ import org.opendc.compute.service.HostView
* A [HostWeigher] that weighs the hosts based on the number of instances on the host.
*/
public class InstanceCountWeigher(override val multiplier: Double = 1.0) : HostWeigher {
- override fun getWeight(host: HostView, server: Server): Double {
+ override fun getWeight(
+ host: HostView,
+ server: Server,
+ ): Double {
return host.instanceCount.toDouble()
}
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/RamWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/RamWeigher.kt
index bb837fbe..fca2e893 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/RamWeigher.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/RamWeigher.kt
@@ -32,7 +32,10 @@ import org.opendc.compute.service.HostView
* available memory, and a negative number will result in the scheduler preferring hosts with less memory.
*/
public class RamWeigher(override val multiplier: Double = 1.0) : HostWeigher {
- override fun getWeight(host: HostView, server: Server): Double {
+ override fun getWeight(
+ host: HostView,
+ server: Server,
+ ): Double {
return host.availableMemory.toDouble()
}
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt
index f15f60c9..2912ce49 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt
@@ -29,8 +29,10 @@ import org.opendc.compute.service.HostView
* A [HostWeigher] that weighs the hosts based on the difference required vCPU capacity and the available CPU capacity.
*/
public class VCpuCapacityWeigher(override val multiplier: Double = 1.0) : HostWeigher {
-
- override fun getWeight(host: HostView, server: Server): Double {
+ override fun getWeight(
+ host: HostView,
+ server: Server,
+ ): Double {
val model = host.host.model
val requiredCapacity = server.flavor.meta["cpu-capacity"] as? Double ?: 0.0
return model.cpuCapacity / model.cpuCount - requiredCapacity / server.flavor.cpuCount
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuWeigher.kt
index 169ad8cb..be93458f 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuWeigher.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuWeigher.kt
@@ -31,12 +31,14 @@ import org.opendc.compute.service.HostView
* @param allocationRatio Virtual CPU to physical CPU allocation ratio.
*/
public class VCpuWeigher(private val allocationRatio: Double, override val multiplier: Double = 1.0) : HostWeigher {
-
init {
require(allocationRatio > 0.0) { "Allocation ratio must be greater than zero" }
}
- override fun getWeight(host: HostView, server: Server): Double {
+ override fun getWeight(
+ host: HostView,
+ server: Server,
+ ): Double {
return host.host.model.cpuCount * allocationRatio - host.provisionedCores
}