summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-workload/src/main/kotlin
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-09-22 22:39:33 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-09-22 22:39:33 +0200
commitd97356cf696dedb6c26fc42d9d7c44a977264dcd (patch)
treef7c8cf2c7e808dfa234c77c25d6fc24b38826d39 /opendc-compute/opendc-compute-workload/src/main/kotlin
parent92787292269783701cb7f1082f0262e7e2851df9 (diff)
refactor(compute): Pass failure model during workload evaluation
This change updates the `ComputeServiceHelper` class to provide the failure model via a parameter to the `run` method instead of constructor parameter. This separates the construction of the topology from the simulation of the workload.
Diffstat (limited to 'opendc-compute/opendc-compute-workload/src/main/kotlin')
-rw-r--r--opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeServiceHelper.kt4
1 files changed, 2 insertions, 2 deletions
diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeServiceHelper.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeServiceHelper.kt
index 3be0217c..4c07b785 100644
--- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeServiceHelper.kt
+++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeServiceHelper.kt
@@ -47,7 +47,6 @@ import kotlin.math.max
* @param context [CoroutineContext] to run the simulation in.
* @param clock [Clock] instance tracking simulation time.
* @param scheduler [ComputeScheduler] implementation to use for the service.
- * @param failureModel A failure model to use for injecting failures.
* @param schedulingQuantum The scheduling quantum of the scheduler.
*/
public class ComputeServiceHelper(
@@ -55,7 +54,6 @@ public class ComputeServiceHelper(
private val clock: Clock,
scheduler: ComputeScheduler,
seed: Long,
- private val failureModel: FailureModel? = null,
schedulingQuantum: Duration = Duration.ofMinutes(5)
) : AutoCloseable {
/**
@@ -89,12 +87,14 @@ public class ComputeServiceHelper(
* @param trace The trace to simulate.
* @param servers A list to which the created servers is added.
* @param submitImmediately A flag to indicate that the servers are scheduled immediately (so not at their start time).
+ * @param failureModel A failure model to use for injecting failures.
* @param interference A flag to indicate that VM interference needs to be enabled.
*/
public suspend fun run(
trace: List<VirtualMachine>,
servers: MutableList<Server>? = null,
submitImmediately: Boolean = false,
+ failureModel: FailureModel? = null,
interference: Boolean = false,
) {
val injector = failureModel?.createInjector(context, clock, service, Random(random.nextLong()))