summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-service/src
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-03-19 20:26:04 +0100
committerGitHub <noreply@github.com>2024-03-19 20:26:04 +0100
commitdff30fa60809c018101052f395b09cf17cb83ccb (patch)
tree2c5f67b9424547061aaa0c6b6b85af9a125ec263 /opendc-compute/opendc-compute-service/src
parent960b3d8a13c67ac4b7f479d5764b0b618fc9ea09 (diff)
Scenario and Portfolio update (#209)
* Initial commit * Implemented a new systems of defining and running scenarios / portfolios. Scenarios and Portfolios can now be defined using JSON files similar to topologies. This allows user to define experiments without changing any KotLin code. * Ran spotlessApply
Diffstat (limited to 'opendc-compute/opendc-compute-service/src')
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt44
1 files changed, 32 insertions, 12 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 4d234b1b..7fcc670f 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
@@ -34,65 +34,85 @@ import org.opendc.compute.service.scheduler.weights.VCpuWeigher
import java.util.SplittableRandom
import java.util.random.RandomGenerator
+public enum class ComputeSchedulerEnum {
+ Mem,
+ MemInv,
+ CoreMem,
+ CoreMemInv,
+ ActiveServers,
+ ActiveServersInv,
+ ProvisionedCores,
+ ProvisionedCoresInv,
+ Random,
+ Replay,
+}
+
+public fun createComputeScheduler(
+ name: String,
+ seeder: RandomGenerator,
+ placements: Map<String, String> = emptyMap(),
+): ComputeScheduler {
+ return createComputeScheduler(ComputeSchedulerEnum.valueOf(name.uppercase()), seeder, placements)
+}
+
/**
* Create a [ComputeScheduler] for the experiment.
*/
public fun createComputeScheduler(
- name: String,
+ name: ComputeSchedulerEnum,
seeder: RandomGenerator,
placements: Map<String, String> = emptyMap(),
): ComputeScheduler {
val cpuAllocationRatio = 1.0
val ramAllocationRatio = 1.5
return when (name) {
- "mem" ->
+ ComputeSchedulerEnum.Mem ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(RamWeigher(multiplier = 1.0)),
)
- "mem-inv" ->
+ ComputeSchedulerEnum.MemInv ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(RamWeigher(multiplier = -1.0)),
)
- "core-mem" ->
+ ComputeSchedulerEnum.CoreMem ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(CoreRamWeigher(multiplier = 1.0)),
)
- "core-mem-inv" ->
+ ComputeSchedulerEnum.CoreMemInv ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(CoreRamWeigher(multiplier = -1.0)),
)
- "active-servers" ->
+ ComputeSchedulerEnum.ActiveServers ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(InstanceCountWeigher(multiplier = -1.0)),
)
- "active-servers-inv" ->
+ ComputeSchedulerEnum.ActiveServersInv ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(InstanceCountWeigher(multiplier = 1.0)),
)
- "provisioned-cores" ->
+ ComputeSchedulerEnum.ProvisionedCores ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = 1.0)),
)
- "provisioned-cores-inv" ->
+ ComputeSchedulerEnum.ProvisionedCoresInv ->
FilterScheduler(
filters = listOf(ComputeFilter(), VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)),
weighers = listOf(VCpuWeigher(cpuAllocationRatio, multiplier = -1.0)),
)
- "random" ->
+ ComputeSchedulerEnum.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")
+ ComputeSchedulerEnum.Replay -> ReplayScheduler(placements)
}
}