diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-01-08 13:44:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-08 13:44:09 +0100 |
| commit | 616017ba78a0882fe38b9b171b2b0f68e593cd8d (patch) | |
| tree | 9cc4c20078ae10d169c90cbce5b898226a7eee9d /opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner | |
| parent | c57468c5040a838de6901972b6e49a8548d908d6 (diff) | |
refactored opendc-experiment-compute (#190)
* removed experiment-compute and integrated all components into opendc-compute
* updated workflow gradle file
* removed unneeded code
Diffstat (limited to 'opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner')
3 files changed, 0 insertions, 209 deletions
diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/Provisioner.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/Provisioner.kt deleted file mode 100644 index eae5806e..00000000 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/Provisioner.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.experiments.provisioner - -import org.opendc.common.Dispatcher -import org.opendc.experiments.MutableServiceRegistry -import org.opendc.experiments.ServiceRegistry -import org.opendc.experiments.internal.ServiceRegistryImpl -import java.util.ArrayDeque -import java.util.SplittableRandom - -/** - * A helper class to set up the experimental environment in a reproducible manner. - * - * With this class, users describe the environment using multiple [ProvisioningStep]s. These re-usable - * [ProvisioningStep]s are executed sequentially and ensure that the necessary infrastructure is configured and teared - * down after the simulation completes. - * - * @param dispatcher The [Dispatcher] implementation for scheduling future tasks. - * @param seed A seed for initializing the randomness of the environment. - */ -public class Provisioner(dispatcher: Dispatcher, seed: Long) : AutoCloseable { - /** - * Implementation of [ProvisioningContext]. - */ - private val context = object : ProvisioningContext { - override val dispatcher: Dispatcher = dispatcher - override val seeder: SplittableRandom = SplittableRandom(seed) - override val registry: MutableServiceRegistry = ServiceRegistryImpl() - - override fun toString(): String = "Provisioner.ProvisioningContext" - } - - /** - * The stack of handles to run during the clean-up process. - */ - private val stack = ArrayDeque<AutoCloseable>() - - /** - * The [ServiceRegistry] containing the services registered in this environment. - */ - public val registry: ServiceRegistry - get() = context.registry - - /** - * Run a single [ProvisioningStep] for this environment. - * - * @param step The step to apply to the environment. - */ - public fun runStep(step: ProvisioningStep) { - val handle = step.apply(context) - stack.push(handle) - } - - /** - * Run multiple [ProvisioningStep]s for this environment. - * - * @param steps The steps to apply to the environment. - */ - public fun runSteps(vararg steps: ProvisioningStep) { - val ctx = context - val stack = stack - for (step in steps) { - val handle = step.apply(ctx) - stack.push(handle) - } - } - - /** - * Clean-up the environment. - */ - override fun close() { - val stack = stack - while (stack.isNotEmpty()) { - stack.pop().close() - } - } -} diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/ProvisioningContext.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/ProvisioningContext.kt deleted file mode 100644 index e53044ce..00000000 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/ProvisioningContext.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.experiments.provisioner - -import org.opendc.common.Dispatcher -import org.opendc.experiments.MutableServiceRegistry -import java.util.SplittableRandom -import java.util.random.RandomGenerator - -/** - * The [ProvisioningContext] class provides access to shared state between subsequent [ProvisioningStep]s, as well as - * access to the simulation dispatcher, the virtual clock, and a randomness seeder to allow - * the provisioning steps to initialize the (simulated) resources. - */ -public interface ProvisioningContext { - /** - * The [Dispatcher] provided by the provisioner to schedule future events during the simulation. - */ - public val dispatcher: Dispatcher - - /** - * A [SplittableRandom] instance used to seed the provisioners. - */ - public val seeder: RandomGenerator - - /** - * A [MutableServiceRegistry] where the provisioned services are registered. - */ - public val registry: MutableServiceRegistry -} diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/ProvisioningStep.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/ProvisioningStep.kt deleted file mode 100644 index e78f8d4f..00000000 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/provisioner/ProvisioningStep.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.experiments.provisioner - -import org.eclipse.microprofile.config.Config - -/** - * A provisioning step is responsible for provisioning (acquiring or configuring) infrastructure necessary for a - * simulation experiment. - */ -public fun interface ProvisioningStep { - /** - * Apply the step by provisioning the required resources for the experiment using the specified - * [ProvisioningContext][ctx]. - * - * @param ctx The environment in which the resources should be provisioned. - * @return A handle that is invoked once the simulation completes, so that the resources can be cleaned up. - */ - public fun apply(ctx: ProvisioningContext): AutoCloseable - - /** - * A factory interface for [ProvisioningStep] instances. - * - * @param S The type that describes the input for constructing a [ProvisioningStep]. - */ - public abstract class Provider<S>(public val type: Class<S>) { - /** - * The name that identifies the provisioning step. - */ - public abstract val name: String - - /** - * Construct a [ProvisioningStep] with the specified [spec]. - * - * @param spec The specification that describes the provisioner to be created. - * @param config The external configuration of the experiment runner. - * @return The [ProvisioningStep] constructed according to [spec]. - */ - public abstract fun create(spec: S, config: Config): ProvisioningStep - } -} |
