Skip to content
Snippets Groups Projects
Commit fb8da795 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

minor code enhancements

parent 8210e678
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!85Introduce new Benchmark class and Patcher,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -2,7 +2,6 @@ package theodolite.benchmark ...@@ -2,7 +2,6 @@ package theodolite.benchmark
import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.client.DefaultKubernetesClient import io.fabric8.kubernetes.client.DefaultKubernetesClient
import org.apache.kafka.clients.admin.NewTopic
import theodolite.k8s.K8sResourceLoader import theodolite.k8s.K8sResourceLoader
import theodolite.patcher.PatcherManager import theodolite.patcher.PatcherManager
import theodolite.util.* import theodolite.util.*
...@@ -22,7 +21,7 @@ class KubernetesBenchmark(): Benchmark { ...@@ -22,7 +21,7 @@ class KubernetesBenchmark(): Benchmark {
private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> { private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> {
val basePath = "./../../../resources/main/yaml/" val basePath = "./../../../resources/main/yaml/"
var parser = YamlParser() var parser = YamlParser()
val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace("default")) val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace("theodolite-she"))
return resources return resources
.map { resource -> .map { resource ->
val resourcePath = "$basePath/$resource" val resourcePath = "$basePath/$resource"
...@@ -33,11 +32,9 @@ class KubernetesBenchmark(): Benchmark { ...@@ -33,11 +32,9 @@ class KubernetesBenchmark(): Benchmark {
} }
override fun buildDeployment(load: LoadDimension, res: Resource, configurationOverrides: List<ConfigurationOverride>): BenchmarkDeployment { override fun buildDeployment(load: LoadDimension, res: Resource, configurationOverrides: List<ConfigurationOverride>): BenchmarkDeployment {
// TODO("set node selector")
val resources = loadKubernetesResources(this.appResource + this.loadGenResource) val resources = loadKubernetesResources(this.appResource + this.loadGenResource)
val patcherManager = PatcherManager() val patcherManager = PatcherManager()
// patch res and load // patch res and load
patcherManager.createAndApplyPatcher(res.getType(), this.resourceTypes, resources, res.get()) patcherManager.createAndApplyPatcher(res.getType(), this.resourceTypes, resources, res.get())
patcherManager.createAndApplyPatcher(load.getType(), this.loadTypes, resources, load.get().toString()) patcherManager.createAndApplyPatcher(load.getType(), this.loadTypes, resources, load.get().toString())
...@@ -46,8 +43,8 @@ class KubernetesBenchmark(): Benchmark { ...@@ -46,8 +43,8 @@ class KubernetesBenchmark(): Benchmark {
configurationOverrides.forEach{ override -> patcherManager.applyPatcher(listOf(override.patcher), resources, override.value)} configurationOverrides.forEach{ override -> patcherManager.applyPatcher(listOf(override.patcher), resources, override.value)}
return KubernetesBenchmarkDeployment( return KubernetesBenchmarkDeployment(
resources.map { r -> r.second }, resources = resources.map { r -> r.second },
kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapSever), kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer),
zookeeperConfig = zookeeperConfig["server"].toString(), zookeeperConfig = zookeeperConfig["server"].toString(),
topics = kafkaConfig.topics) topics = kafkaConfig.topics)
} }
......
...@@ -16,7 +16,7 @@ class KubernetesBenchmarkDeployment( ...@@ -16,7 +16,7 @@ class KubernetesBenchmarkDeployment(
): BenchmarkDeployment { ): BenchmarkDeployment {
private val workloadGeneratorStateCleaner = WorkloadGeneratorStateCleaner(this.zookeeperConfig) private val workloadGeneratorStateCleaner = WorkloadGeneratorStateCleaner(this.zookeeperConfig)
private val kafkaController = TopicManager(this.kafkaConfig) 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() { override fun setup() {
this.workloadGeneratorStateCleaner.deleteState() this.workloadGeneratorStateCleaner.deleteState()
......
...@@ -4,7 +4,7 @@ import theodolite.benchmark.Benchmark ...@@ -4,7 +4,7 @@ import theodolite.benchmark.Benchmark
import theodolite.util.* import theodolite.util.*
import java.time.Duration 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 { override fun runExperiment(load: LoadDimension, res: Resource): Boolean {
val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides)
benchmarkDeployment.setup() benchmarkDeployment.setup()
......
...@@ -3,7 +3,6 @@ package theodolite.util ...@@ -3,7 +3,6 @@ package theodolite.util
import org.apache.kafka.clients.admin.NewTopic import org.apache.kafka.clients.admin.NewTopic
class KafkaConfig() { class KafkaConfig() {
lateinit var bootstrapSever: String lateinit var bootstrapServer: String
lateinit var topics: List<NewTopic> lateinit var topics: List<NewTopic>
} }
\ No newline at end of file
package theodolite.util package theodolite.util
data class LoadDimension(private val number: Int, private val type: String) { data class LoadDimension(private val number: Int, private val type: String) {
public fun get(): Int { fun get(): Int {
return this.number; return this.number;
} }
public fun getType(): String { fun getType(): String {
return this.type return this.type
} }
} }
package theodolite.util package theodolite.util
data class Resource(private val number: Int, private val type: String) { data class Resource(private val number: Int, private val type: String) {
public fun get(): Int { fun get(): Int {
return this.number; return this.number;
} }
public fun getType(): String { fun getType(): String {
return this.type return this.type
} }
} }
\ No newline at end of file
...@@ -5,18 +5,17 @@ import theodolite.util.Resource ...@@ -5,18 +5,17 @@ import theodolite.util.Resource
import kotlin.math.exp import kotlin.math.exp
class Results { class Results {
// load, instances private val results: MutableMap<Pair<LoadDimension, Resource>, Boolean> = mutableMapOf()
private val results: MutableMap<Pair<LoadDimension, Resource>, Boolean> = mutableMapOf() // multi map guava
public fun setResult(experiment: Pair<LoadDimension, Resource>, successful: Boolean) { fun setResult(experiment: Pair<LoadDimension, Resource>, successful: Boolean) {
this.results[experiment] = successful this.results[experiment] = successful
} }
public fun getResult (experiment: Pair<LoadDimension, Resource>): Boolean? { fun getResult (experiment: Pair<LoadDimension, Resource>): Boolean? {
return this.results[experiment] 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) if (this.results.isEmpty()) return Resource(Int.MIN_VALUE, resourceTyp)
var requiredInstances: Resource? = Resource(Int.MAX_VALUE, resourceTyp) var requiredInstances: Resource? = Resource(Int.MAX_VALUE, resourceTyp)
...@@ -32,7 +31,7 @@ class Results { ...@@ -32,7 +31,7 @@ class Results {
return requiredInstances return requiredInstances
} }
public fun getMaxBenchmarkedLoad(load: LoadDimension): LoadDimension? { fun getMaxBenchmarkedLoad(load: LoadDimension): LoadDimension? {
var maxBenchmarkedLoad: LoadDimension? = null; var maxBenchmarkedLoad: LoadDimension? = null;
for(experiment in results) { for(experiment in results) {
if (experiment.value) { if (experiment.value) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment