From fb8da795c93a887573bc9e57b2861d0418bc6df0 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Mon, 8 Mar 2021 10:08:58 +0100 Subject: [PATCH] minor code enhancements --- .../theodolite/benchmark/KubernetesBenchmark.kt | 9 +++------ .../benchmark/KubernetesBenchmarkDeployment.kt | 2 +- .../theodolite/execution/BenchmarkExecutorImpl.kt | 2 +- .../src/main/kotlin/theodolite/util/KafkaConfig.kt | 3 +-- .../src/main/kotlin/theodolite/util/LoadDimension.kt | 4 ++-- .../src/main/kotlin/theodolite/util/Resource.kt | 4 ++-- .../src/main/kotlin/theodolite/util/Results.kt | 11 +++++------ 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index 9c7a27948..7c06856a8 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -2,7 +2,6 @@ package theodolite.benchmark import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.client.DefaultKubernetesClient -import org.apache.kafka.clients.admin.NewTopic import theodolite.k8s.K8sResourceLoader import theodolite.patcher.PatcherManager import theodolite.util.* @@ -22,7 +21,7 @@ class KubernetesBenchmark(): Benchmark { private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> { val basePath = "./../../../resources/main/yaml/" var parser = YamlParser() - val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace("default")) + val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace("theodolite-she")) return resources .map { resource -> val resourcePath = "$basePath/$resource" @@ -33,11 +32,9 @@ class KubernetesBenchmark(): Benchmark { } override fun buildDeployment(load: LoadDimension, res: Resource, configurationOverrides: List<ConfigurationOverride>): BenchmarkDeployment { - // TODO("set node selector") val resources = loadKubernetesResources(this.appResource + this.loadGenResource) val patcherManager = PatcherManager() - // patch res and load patcherManager.createAndApplyPatcher(res.getType(), this.resourceTypes, resources, res.get()) patcherManager.createAndApplyPatcher(load.getType(), this.loadTypes, resources, load.get().toString()) @@ -46,8 +43,8 @@ class KubernetesBenchmark(): Benchmark { configurationOverrides.forEach{ override -> patcherManager.applyPatcher(listOf(override.patcher), resources, override.value)} return KubernetesBenchmarkDeployment( - resources.map { r -> r.second }, - kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapSever), + resources = resources.map { r -> r.second }, + kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer), zookeeperConfig = zookeeperConfig["server"].toString(), topics = kafkaConfig.topics) } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index 54e91fb4b..a0fed2253 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -16,7 +16,7 @@ class KubernetesBenchmarkDeployment( ): BenchmarkDeployment { private val workloadGeneratorStateCleaner = WorkloadGeneratorStateCleaner(this.zookeeperConfig) private val kafkaController = TopicManager(this.kafkaConfig) - private val kubernetesManager = K8sManager(DefaultKubernetesClient().inNamespace("theodolite-she")) // Maybe per resource type + private val kubernetesManager = K8sManager(DefaultKubernetesClient().inNamespace("theodolite-she")) override fun setup() { this.workloadGeneratorStateCleaner.deleteState() diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index ce0295b3f..ee7273c02 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -4,7 +4,7 @@ import theodolite.benchmark.Benchmark import theodolite.util.* import java.time.Duration -class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, val configurationOverrides: List<ConfigurationOverride>) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides) { +class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, private val configurationOverrides: List<ConfigurationOverride>) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) benchmarkDeployment.setup() diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt index 21360e6c6..f75927c0e 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/KafkaConfig.kt @@ -3,7 +3,6 @@ package theodolite.util import org.apache.kafka.clients.admin.NewTopic class KafkaConfig() { - lateinit var bootstrapSever: String + lateinit var bootstrapServer: String lateinit var topics: List<NewTopic> - } \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/LoadDimension.kt index 9804dab40..2f6fcb22e 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, private val type: String) { - public fun get(): Int { + fun get(): Int { return this.number; } - public fun getType(): String { + fun getType(): String { 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 fecb218b2..f315bb54d 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, private val type: String) { - public fun get(): Int { + fun get(): Int { return this.number; } - public fun getType(): String { + fun getType(): String { 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 11f0ba7cc..cf3da20d2 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/Results.kt @@ -5,18 +5,17 @@ import theodolite.util.Resource import kotlin.math.exp class Results { - // load, instances - private val results: MutableMap<Pair<LoadDimension, Resource>, Boolean> = mutableMapOf() // multi map guava + private val results: MutableMap<Pair<LoadDimension, Resource>, Boolean> = mutableMapOf() - public fun setResult(experiment: Pair<LoadDimension, Resource>, successful: Boolean) { + fun setResult(experiment: Pair<LoadDimension, Resource>, successful: Boolean) { this.results[experiment] = successful } - public fun getResult (experiment: Pair<LoadDimension, Resource>): Boolean? { + fun getResult (experiment: Pair<LoadDimension, Resource>): Boolean? { return this.results[experiment] } - public fun getMinRequiredInstances(load: LoadDimension?, resourceTyp: String): Resource? { + fun getMinRequiredInstances(load: LoadDimension?, resourceTyp: String): Resource? { if (this.results.isEmpty()) return Resource(Int.MIN_VALUE, resourceTyp) var requiredInstances: Resource? = Resource(Int.MAX_VALUE, resourceTyp) @@ -32,7 +31,7 @@ class Results { return requiredInstances } - public fun getMaxBenchmarkedLoad(load: LoadDimension): LoadDimension? { + fun getMaxBenchmarkedLoad(load: LoadDimension): LoadDimension? { var maxBenchmarkedLoad: LoadDimension? = null; for(experiment in results) { if (experiment.value) { -- GitLab