diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-09-22 10:28:37 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-09-22 14:49:35 +0200 |
| commit | 6171ab09f1df2ab3475a7b28ece383a9f87a77c5 (patch) | |
| tree | 54a7ae4ef7c482dfdc04ba3eef37ab428bee3b33 /opendc-compute/opendc-compute-simulator/src | |
| parent | 507ff6223d277ebc6744b92b4030d94f20a92a02 (diff) | |
refactor(sim/compute): Extract Random dependency from interference model
This change moves the Random dependency outside the interference model,
to allow the interference model to be completely immutable and passable
between different simulations.
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src')
2 files changed, 8 insertions, 3 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt index 628f324b..ece3f752 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt @@ -62,6 +62,7 @@ public class SimHost( context: CoroutineContext, engine: FlowEngine, hypervisorProvider: SimHypervisorProvider, + random: SplittableRandom, scalingGovernor: ScalingGovernor = PerformanceScalingGovernor(), powerDriver: PowerDriver = SimplePowerDriver(ConstantPowerModel(0.0)), private val mapper: SimWorkloadMapper = SimMetaWorkloadMapper(), @@ -92,7 +93,7 @@ public class SimHost( * The hypervisor to run multiple workloads. */ private val hypervisor: SimHypervisor = hypervisorProvider - .create(engine, scalingGovernor = scalingGovernor) + .create(engine, random, scalingGovernor = scalingGovernor) /** * The virtual machines running on the hypervisor. diff --git a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt index 5ba4a667..0b2285e5 100644 --- a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt +++ b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt @@ -67,6 +67,7 @@ internal class SimHostTest { fun testOvercommitted() = runBlockingSimulation { val duration = 5 * 60L val engine = FlowEngine(coroutineContext, clock) + val random = SplittableRandom(1) val host = SimHost( uid = UUID.randomUUID(), name = "test", @@ -74,7 +75,8 @@ internal class SimHostTest { meta = emptyMap(), coroutineContext, engine, - SimFairShareHypervisorProvider() + SimFairShareHypervisorProvider(), + random, ) val vmImageA = MockImage( UUID.randomUUID(), @@ -149,6 +151,7 @@ internal class SimHostTest { fun testFailure() = runBlockingSimulation { val duration = 5 * 60L val engine = FlowEngine(coroutineContext, clock) + val random = SplittableRandom(1) val host = SimHost( uid = UUID.randomUUID(), name = "test", @@ -156,7 +159,8 @@ internal class SimHostTest { meta = emptyMap(), coroutineContext, engine, - SimFairShareHypervisorProvider() + SimFairShareHypervisorProvider(), + random ) val image = MockImage( UUID.randomUUID(), |
