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
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)
}
......
......@@ -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()
......
......@@ -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()
......
......@@ -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
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
}
}
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
......@@ -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) {
......
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