summaryrefslogtreecommitdiff
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
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.
-rw-r--r--opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeServiceHelper.kt4
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt3
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt5
-rw-r--r--opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt3
4 files changed, 6 insertions, 9 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()))
diff --git a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt
index 7be09ff5..98702b4c 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt
@@ -74,7 +74,6 @@ public class CapelinRunner(
clock,
computeScheduler,
seed,
- failureModel
)
val topology = clusterTopology(File(envPath, "${scenario.topology.name}.txt"))
@@ -104,7 +103,7 @@ public class CapelinRunner(
runner.apply(topology, optimize = true)
// Run the workload trace
- runner.run(vms, servers, interference = operationalPhenomena.hasInterference)
+ runner.run(vms, servers, failureModel = failureModel, interference = operationalPhenomena.hasInterference)
// Stop the metric collection
exporter?.close()
diff --git a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
index af846dd6..bf8c2758 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
@@ -226,8 +226,7 @@ class CapelinIntegrationTest {
coroutineContext,
clock,
computeScheduler,
- seed,
- grid5000(Duration.ofDays(7))
+ seed
)
val topology = createTopology("single")
val workload = createTestWorkload(0.25, seed)
@@ -236,7 +235,7 @@ class CapelinIntegrationTest {
try {
simulator.apply(topology)
- simulator.run(workload, servers)
+ simulator.run(workload, servers, failureModel = grid5000(Duration.ofDays(7)))
val serviceMetrics = simulator.service.getSchedulerStats()
println(
diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt
index b7e550ef..570920f3 100644
--- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt
+++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt
@@ -221,7 +221,6 @@ public class OpenDCRunner(
clock,
computeScheduler,
seed = 0L,
- failureModel
)
val servers = mutableListOf<Server>()
val reader = ComputeMetricReader(this, clock, simulator.service, servers, monitor)
@@ -230,7 +229,7 @@ public class OpenDCRunner(
// Instantiate the topology onto the simulator
simulator.apply(topology)
// Run workload trace
- simulator.run(vms, servers, interference = phenomena.interference)
+ simulator.run(vms, servers, failureModel = failureModel, interference = phenomena.interference)
val serviceMetrics = simulator.service.getSchedulerStats()
logger.debug {