From ad12154372cc79e2e9b0423c0d488a916201cd31 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Tue, 23 Feb 2021 22:16:50 +0100 Subject: [PATCH] Introduce a type for loads and resources for example resourceType = Instances, loadType = NumSensors --- .../theodolite/benchmark/BenchmarkContext.kt | 14 +++++++++++-- .../benchmark/KubernetesBenchmark.kt | 2 +- .../theodolite/benchmark/TestBenchmark.kt | 2 +- .../execution/TheodoliteExecutor.kt | 14 ++++++------- .../restriction/LowerBoundRestriction.kt | 4 ++-- .../kotlin/theodolite/util/LoadDimension.kt | 4 ++-- .../main/kotlin/theodolite/util/Resource.kt | 4 ++-- .../main/kotlin/theodolite/util/Results.kt | 6 +++--- .../src/main/resources/yaml/testContext.yaml | 21 ++++++++----------- .../theodolite/CompositeStrategyTest.kt | 18 ++++++++-------- 10 files changed, 48 insertions(+), 41 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt index ef378d98e..c734c22a9 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkContext.kt @@ -7,8 +7,8 @@ import kotlin.properties.Delegates class BenchmarkContext() { lateinit var name: String lateinit var benchmark: String - lateinit var loads: List<Int> - lateinit var resources: List<Int> + lateinit var load: LoadDefinition + lateinit var resources: ResourceDefinition lateinit var slos: List<Slo> lateinit var execution: Execution lateinit var configOverrides: List<ConfigurationOverride> @@ -24,4 +24,14 @@ class BenchmarkContext() { lateinit var sloType: String var threshold by Delegates.notNull<Int>() } + + class LoadDefinition() { + lateinit var loadType: String + lateinit var loadValues: List<Int> + } + + class ResourceDefinition() { + lateinit var resourceType: String + lateinit var resourceValues: List<Int> + } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 545d368f5..b998dcda4 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -49,7 +49,7 @@ class KubernetesBenchmark(): Benchmark { return KubernetesBenchmarkDeployment( resources.map { r -> r.second }, kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapSever), - zookeeperConfig = zookeeperConfig["server"].toString() !!, + zookeeperConfig = zookeeperConfig["server"].toString(), topics = kafkaConfig.topics.map { topic -> NewTopic(topic.name, topic.partition, topic.replication ) }) } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt index abda15822..45802ec8b 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestBenchmark.kt @@ -9,7 +9,7 @@ class TestBenchmark : Benchmark { override fun buildDeployment( load: LoadDimension, res: Resource, - configurationOverride: List<ConfigurationOverride> + configurationOverrides: List<ConfigurationOverride> ): BenchmarkDeployment { return TestBenchmarkDeployment() } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index 92d9a4ed9..c94beee06 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -11,7 +11,7 @@ import theodolite.util.Results import java.time.Duration class TheodoliteExecutor( - private val benchmarkContext: BenchmarkContext, + private val config: BenchmarkContext, private val kubernetesBenchmark: KubernetesBenchmark ) { @@ -20,16 +20,16 @@ class TheodoliteExecutor( val results = Results() val strategyManager = StrategiesManager() - val executionDuration = Duration.ofSeconds(this.benchmarkContext.execution.duration) - val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, this.benchmarkContext.configOverrides) + val executionDuration = Duration.ofSeconds(config.execution.duration) + val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, config.configOverrides) return Config( - loads = benchmarkContext.loads.map { number -> LoadDimension(number) }, - resources = benchmarkContext.resources.map { number -> Resource(number) }, + loads = config.load.loadValues.map { load -> LoadDimension(load, config.load.loadType ) }, + resources = config.resources.resourceValues.map { resource -> Resource(resource, config.load.loadType) }, compositeStrategy = CompositeStrategy( benchmarkExecutor = executor, - searchStrategy = strategyManager.createSearchStrategy(executor, this.benchmarkContext.execution.strategy), - restrictionStrategies = strategyManager.createRestrictionStrategy(results, this.benchmarkContext.execution.restrictions)), + searchStrategy = strategyManager.createSearchStrategy(executor, config.execution.strategy), + restrictionStrategies = strategyManager.createRestrictionStrategy(results, config.execution.restrictions)), executionDuration = executionDuration) } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt index 093ef3b10..aa5878ef2 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/strategies/restriction/LowerBoundRestriction.kt @@ -13,9 +13,9 @@ import theodolite.util.Resource class LowerBoundRestriction(results: Results) : RestrictionStrategy(results) { override fun next(load: LoadDimension, resources: List<Resource>): List<Resource> { val maxLoad: LoadDimension? = this.results.getMaxBenchmarkedLoad(load) - var lowerBound: Resource? = this.results.getMinRequiredInstances(maxLoad) + var lowerBound: Resource? = this.results.getMinRequiredInstances(maxLoad, resources[0].getType()) if(lowerBound == null) { - lowerBound = resources.get(0) + lowerBound = resources[0] } return resources.filter{x -> x.get() >= lowerBound.get()} } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt index 52d865050..9804dab40 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt @@ -1,11 +1,11 @@ package theodolite.util -data class LoadDimension(private val number: Int) { +data class LoadDimension(private val number: Int, private val type: String) { public fun get(): Int { return this.number; } public fun getType(): String { - return "NumSensors" + return this.type } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt index 0afa48851..fecb218b2 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Resource.kt @@ -1,11 +1,11 @@ package theodolite.util -data class Resource(private val number: Int) { +data class Resource(private val number: Int, private val type: String) { public fun get(): Int { return this.number; } public fun getType(): String { - return "Instances" + return this.type } } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt index fdd38896d..11f0ba7cc 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt @@ -16,10 +16,10 @@ class Results { return this.results[experiment] } - public fun getMinRequiredInstances(load: LoadDimension?): Resource? { - if (this.results.isEmpty()) return Resource(Int.MIN_VALUE) + public fun getMinRequiredInstances(load: LoadDimension?, resourceTyp: String): Resource? { + if (this.results.isEmpty()) return Resource(Int.MIN_VALUE, resourceTyp) - var requiredInstances: Resource? = Resource(Int.MAX_VALUE) + var requiredInstances: Resource? = Resource(Int.MAX_VALUE, resourceTyp) for(experiment in results) { if(experiment.key.first == load && experiment.value){ if(requiredInstances == null) { diff --git a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml index 13c0ae375..f3e73ca43 100644 --- a/theodolite-quarkus/src/main/resources/yaml/testContext.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/testContext.yaml @@ -1,11 +1,15 @@ name: "Theodolite Test Context" benchmark: "benchmarkType" -loads: - - 1000 - - 2000 +load: + loadType: "NumSensors" + loadValues: + - 1000 + - 2000 resources: - - 1 - - 2 + resourceType: "Instances" + resourceValues: + - 1 + - 2 slos: - sloType: "slo type" threshold: 1000 @@ -15,13 +19,6 @@ execution: repititions: 1 restrictions: - "LowerBound" -#configOverrides: -# - type: "EnvVarPatcher" -# resource: "workloadGenerator.yaml" -# container: "workload-generator" -# overrides: -# overrideTestA: "8888" -# overrideTestB: "6666" configOverrides: - patcher: type: "EnvVarPatcher" diff --git a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt index 573495037..f982dd18b 100644 --- a/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt +++ b/theodolite-quarkus/src/test/kotlin/theodolite/CompositeStrategyTest.kt @@ -26,8 +26,8 @@ class CompositeStrategyTest { arrayOf( false, false, false, false, false, false, true), arrayOf( false, false, false, false, false, false, false) ) - val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number)} - val mockResources: List<Resource> = (0..6).map{number -> Resource(number)} + val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number, "NumSensors")} + val mockResources: List<Resource> = (0..6).map{number -> Resource(number, "Instances")} val results: Results = Results(); val benchmark = TestBenchmark() val benchmarkExecutor: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results) @@ -36,7 +36,7 @@ class CompositeStrategyTest { val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutor, linearSearch, setOf(lowerBoundRestriction)) val actual: ArrayList<Resource?> = ArrayList<Resource?>() - val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x)}) + val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x, "Instances")}) expected.add(null) for(load in mockLoads) { @@ -57,8 +57,8 @@ class CompositeStrategyTest { arrayOf( false, false, false, false, false, false, true), arrayOf( false, false, false, false, false, false, false) ) - val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number)} - val mockResources: List<Resource> = (0..6).map{number -> Resource(number)} + val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number, "NumSensors")} + val mockResources: List<Resource> = (0..6).map{number -> Resource(number, "Instances")} val results: Results = Results(); val benchmark = TestBenchmark() val benchmarkExecutorImpl: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results) @@ -67,7 +67,7 @@ class CompositeStrategyTest { val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutorImpl, binarySearch, setOf(lowerBoundRestriction)) val actual: ArrayList<Resource?> = ArrayList<Resource?>() - val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x)}) + val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6).map{ x -> Resource(x, "Instances")}) expected.add(null) for(load in mockLoads) { @@ -88,8 +88,8 @@ class CompositeStrategyTest { arrayOf( false, false, false, false, false, false, true, true), arrayOf( false, false, false, false, false, false, false, true) ) - val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number)} - val mockResources: List<Resource> = (0..7).map{number -> Resource(number)} + val mockLoads: List<LoadDimension> = (0..6).map{number -> LoadDimension(number, "NumSensors")} + val mockResources: List<Resource> = (0..7).map{number -> Resource(number, "Instances")} val results: Results = Results(); val benchmark = TestBenchmark() val benchmarkExecutor: TestBenchmarkExecutorImpl = TestBenchmarkExecutorImpl(mockResults, benchmark, results) @@ -98,7 +98,7 @@ class CompositeStrategyTest { val strategy: CompositeStrategy = CompositeStrategy(benchmarkExecutor, binarySearch, setOf(lowerBoundRestriction)) val actual: ArrayList<Resource?> = ArrayList<Resource?>() - val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6,7).map{ x -> Resource(x)}) + val expected: ArrayList<Resource?> = ArrayList(listOf(0,2,2,3,4,6,7).map{ x -> Resource(x, "Instances")}) for(load in mockLoads) { actual.add(strategy.findSuitableResource(load, mockResources)) -- GitLab