diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-10-05 14:44:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-05 14:44:43 +0200 |
| commit | c2047d09b27b0c05f5c203509dde524e17d3b729 (patch) | |
| tree | 3903d8aed5e87850c92e1b2dce8379ea99bdfa6d /opendc-faas | |
| parent | ec3b5b462c1b8296ba18a3872f56d569fa70e45b (diff) | |
| parent | be176910eb870209576326ffaad8bf21241fccbd (diff) | |
merge: Extract scheduler from simulation coroutine dispatcher (#106)
This pull request extracts the scheduler from the `SimulationCoroutineDispatcher` into
a separate `SimulationScheduler` class which allows users to re-use the scheduler
between different coroutine dispatchers.
We implement the `SimulationScheduler` in Java, removing the explicit dependency on
Kotlin or `kotlinx-coroutines`. The scheduler uses a separate specialized priority queue
implementation that eliminates allocation in the hot path of the simulator.
## Implementation Notes :hammer_and_pick:
* Add Java-based simulator core
* Use SimulationScheduler in coroutine dispatcher
* Rename runBlockingSimulation to runSimulation
## External Dependencies :four_leaf_clover:
* N/A
## Breaking API Changes :warning:
* The Kotlin API for simulation has been moved to `org.opendc.simulator.kotlin`.
* `runBlockingSImulation` renamed to `runSimulation`
Diffstat (limited to 'opendc-faas')
2 files changed, 13 insertions, 13 deletions
diff --git a/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt b/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt index 560039c1..28234cf4 100644 --- a/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt +++ b/opendc-faas/opendc-faas-service/src/test/kotlin/org/opendc/faas/service/FaaSServiceTest.kt @@ -31,7 +31,7 @@ import org.opendc.faas.api.FaaSFunction import org.opendc.faas.service.deployer.FunctionDeployer import org.opendc.faas.service.deployer.FunctionInstance import org.opendc.faas.service.deployer.FunctionInstanceState -import org.opendc.simulator.core.runBlockingSimulation +import org.opendc.simulator.kotlin.runSimulation import java.util.* /** @@ -40,7 +40,7 @@ import java.util.* internal class FaaSServiceTest { @Test - fun testClientState() = runBlockingSimulation { + fun testClientState() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = assertDoesNotThrow { service.newClient() } @@ -54,7 +54,7 @@ internal class FaaSServiceTest { } @Test - fun testClientInvokeUnknown() = runBlockingSimulation { + fun testClientInvokeUnknown() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -63,7 +63,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionCreation() = runBlockingSimulation { + fun testClientFunctionCreation() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -74,7 +74,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionQuery() = runBlockingSimulation { + fun testClientFunctionQuery() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -87,7 +87,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionFindById() = runBlockingSimulation { + fun testClientFunctionFindById() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -100,7 +100,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionFindByName() = runBlockingSimulation { + fun testClientFunctionFindByName() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -113,7 +113,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionDuplicateName() = runBlockingSimulation { + fun testClientFunctionDuplicateName() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -124,7 +124,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionDelete() = runBlockingSimulation { + fun testClientFunctionDelete() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -138,7 +138,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionCannotInvokeDeleted() = runBlockingSimulation { + fun testClientFunctionCannotInvokeDeleted() = runSimulation { val service = FaaSService(coroutineContext, clock, mockk(), mockk(), mockk()) val client = service.newClient() @@ -150,7 +150,7 @@ internal class FaaSServiceTest { } @Test - fun testClientFunctionInvoke() = runBlockingSimulation { + fun testClientFunctionInvoke() = runSimulation { val deployer = mockk<FunctionDeployer>() val service = FaaSService(coroutineContext, clock, deployer, mockk(), mockk(relaxUnitFun = true)) diff --git a/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt b/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt index 5b730089..317eb0aa 100644 --- a/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt +++ b/opendc-faas/opendc-faas-simulator/src/test/kotlin/org/opendc/faas/simulator/SimFaaSServiceTest.kt @@ -42,7 +42,7 @@ import org.opendc.simulator.compute.model.ProcessingNode import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.workload.SimRuntimeWorkload import org.opendc.simulator.compute.workload.SimWorkload -import org.opendc.simulator.core.runBlockingSimulation +import org.opendc.simulator.kotlin.runSimulation import java.time.Duration import java.util.* @@ -64,7 +64,7 @@ internal class SimFaaSServiceTest { } @Test - fun testSmoke() = runBlockingSimulation { + fun testSmoke() = runSimulation { val random = Random(0) val workload = spyk(object : SimFaaSWorkload, SimWorkload by SimRuntimeWorkload(1000) { override suspend fun invoke() { |
