diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-03-05 13:23:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-05 13:23:57 +0100 |
| commit | 5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec (patch) | |
| tree | 5b2773b8dc21c2e1b526fb70f829c376dd80532a /opendc-faas/opendc-faas-simulator/src/main | |
| parent | d28002a3c151d198298574312f32f1cb43f3a660 (diff) | |
Updated package versions, updated web server tests. (#207)
* Updated all package versions including kotlin. Updated all web-server tests to run.
* Changed the java version of the tests. OpenDC now only supports java 19.
* small update
* test update
* new update
* updated docker version to 19
* updated docker version to 19
Diffstat (limited to 'opendc-faas/opendc-faas-simulator/src/main')
2 files changed, 38 insertions, 33 deletions
diff --git a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt index 47b4d4fa..c81dc523 100644 --- a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt +++ b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/SimFunctionDeployer.kt @@ -58,14 +58,17 @@ public class SimFunctionDeployer( private val dispatcher: Dispatcher, private val model: MachineModel, private val delayInjector: DelayInjector, - private val mapper: SimFaaSWorkloadMapper = SimMetaFaaSWorkloadMapper() + private val mapper: SimFaaSWorkloadMapper = SimMetaFaaSWorkloadMapper(), ) : FunctionDeployer, AutoCloseable { /** * The [CoroutineScope] of this deployer. */ private val scope = CoroutineScope(dispatcher.asCoroutineDispatcher() + Job()) - override fun deploy(function: FunctionObject, listener: FunctionInstanceListener): Instance { + override fun deploy( + function: FunctionObject, + listener: FunctionInstanceListener, + ): Instance { val instance = Instance(function, listener) instance.start() return instance @@ -84,10 +87,11 @@ public class SimFunctionDeployer( /** * The machine that will execute the workloads. */ - public val machine: SimMachine = SimBareMetalMachine.create( - FlowEngine.create(dispatcher).newGraph(), - model - ) + public val machine: SimMachine = + SimBareMetalMachine.create( + FlowEngine.create(dispatcher).newGraph(), + model, + ) /** * The job associated with the lifecycle of the instance. @@ -134,38 +138,39 @@ public class SimFunctionDeployer( */ internal fun start() { check(state == FunctionInstanceState.Provisioning) { "Invalid state of function instance" } - job = scope.launch { - delay(delayInjector.getColdStartDelay(this@Instance)) - - launch { - try { - machine.runWorkload(workload) - } finally { - state = FunctionInstanceState.Deleted - } - } + job = + scope.launch { + delay(delayInjector.getColdStartDelay(this@Instance)) - while (isActive) { - if (queue.isEmpty()) { - chan.receive() + launch { + try { + machine.runWorkload(workload) + } finally { + state = FunctionInstanceState.Deleted + } } - state = FunctionInstanceState.Active - while (queue.isNotEmpty()) { - val request = queue.poll() - try { - workload.invoke() - request.cont.resume(Unit) - } catch (cause: CancellationException) { - request.cont.resumeWithException(cause) - throw cause - } catch (cause: Throwable) { - request.cont.resumeWithException(cause) + while (isActive) { + if (queue.isEmpty()) { + chan.receive() + } + + state = FunctionInstanceState.Active + while (queue.isNotEmpty()) { + val request = queue.poll() + try { + workload.invoke() + request.cont.resume(Unit) + } catch (cause: CancellationException) { + request.cont.resumeWithException(cause) + throw cause + } catch (cause: Throwable) { + request.cont.resumeWithException(cause) + } } + state = FunctionInstanceState.Idle } - state = FunctionInstanceState.Idle } - } } /** diff --git a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/ColdStartModel.kt b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/ColdStartModel.kt index 624067be..f5035ca2 100644 --- a/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/ColdStartModel.kt +++ b/opendc-faas/opendc-faas-simulator/src/main/kotlin/org/opendc/faas/simulator/delay/ColdStartModel.kt @@ -60,7 +60,7 @@ public enum class ColdStartModel { else -> Pair(0.0, 1.0) } } - }; + }, ; /** * Obtain the stochastic parameters for the cold start models. |
