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

apply review, minor code changes

parent 2f1990d7
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus,!78Resolve "Implement Quarkus/Kotlin protype"
package theodolite.execution
import mu.KotlinLogging
import theodolite.util.Benchmark
import theodolite.util.LoadDimension
import theodolite.util.Resource
import theodolite.util.Results
import java.time.Duration
private val logger = KotlinLogging.logger {}
/**
* The Benchmark Executor runs a single experiment.
*
......@@ -23,4 +26,15 @@ abstract class BenchmarkExecutor(val benchmark: Benchmark, val results: Results,
* @return True, if the number of resources are suitable for the given load, false otherwise.
*/
abstract fun runExperiment(load: LoadDimension, res: Resource): Boolean;
/**
* Wait while the benchmark is running and log the number of minutes executed every 1 minute.
*
*/
fun waitAndLog() {
for (i in 1.rangeTo(executionDuration.toMinutes())) {
Thread.sleep(Duration.ofMinutes(1).toMillis())
logger.info { "Executed: $i minutes" }
}
}
}
\ No newline at end of file
......@@ -7,8 +7,6 @@ import theodolite.util.Resource
import theodolite.util.Results
import java.time.Duration
private val logger = KotlinLogging.logger {}
class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration) : BenchmarkExecutor(benchmark, results, executionDuration) {
override fun runExperiment(load: LoadDimension, res: Resource): Boolean {
benchmark.start(load, res)
......@@ -19,11 +17,4 @@ class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDur
this.results.setResult(Pair(load, res), result)
return result;
}
private fun waitAndLog() {
for (i in 1.rangeTo(executionDuration.toMinutes())) {
Thread.sleep(Duration.ofMinutes(1).toMillis())
logger.info { "Executed: $i minutes" }
}
}
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ class DeploymentManager(private val client: NamespacedKubernetesClient) {
}
/**
* Set the enviroment Variable for a container
* Set the environment Variable for a container
*/
fun setWorkloadEnv(workloadDeployment: Deployment, containerName: String, map: Map<String, String>) {
workloadDeployment.spec.template.spec.containers.filter { it.name == containerName }
......
......@@ -8,8 +8,8 @@ import org.apache.kafka.clients.admin.NewTopic
private val logger = KotlinLogging.logger {}
class TopicManager(boostrapIp: String) {
private val props = hashMapOf<String, Any>(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG to boostrapIp)
class TopicManager(bootstrapServers: String) {
private val props = hashMapOf<String, Any>(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG to bootstrapServers)
lateinit var kafkaAdmin: AdminClient
init {
......@@ -20,22 +20,22 @@ class TopicManager(boostrapIp: String) {
}
}
fun createTopics(topics: Map<String, Int>, replicationfactor: Short) {
fun createTopics(topics: Map<String, Int>, replicationFactor: Short) {
val newTopics = mutableSetOf<NewTopic>()
for (i in topics) {
val tops = NewTopic(i.key, i.value, replicationfactor)
val tops = NewTopic(i.key, i.value, replicationFactor)
newTopics.add(tops)
}
kafkaAdmin.createTopics(newTopics)
logger.info {"Topics created"}
}
fun createTopics(topics: List<String>, numPartitions: Int, replicationfactor: Short) {
fun createTopics(topics: List<String>, numPartitions: Int, replicationFactor: Short) {
val newTopics = mutableSetOf<NewTopic>()
for (i in topics) {
val tops = NewTopic(i, numPartitions, replicationfactor)
val tops = NewTopic(i, numPartitions, replicationFactor)
newTopics.add(tops)
}
kafkaAdmin.createTopics(newTopics)
......
......@@ -51,10 +51,6 @@ class UC1Benchmark(config: UC1BenchmarkConfig) : Benchmark(config) {
}
override fun initializeClusterEnvironment() {
// this.workloadGeneratorStateCleaner.deleteAll()
// since the workloadGenerators are not started they cant be deleted
this.topicManager.deleteTopics(this.config.kafkaTopics)
this.topicManager.createTopics(
this.config.kafkaTopics,
this.config.kafkaPartition,
......
......@@ -63,7 +63,7 @@ class YamlLoader(private val client: NamespacedKubernetesClient) {
}
if (resource == null) {
throw NullPointerException("The Ressource at path: $path could not be loaded")
throw IllegalArgumentException("The Resource at path: $path could not be loaded")
}
return resource
......
......@@ -5,7 +5,8 @@ import theodolite.util.LoadDimension
import theodolite.util.Resource
/**
* The Lower Bound Restriction
* The Lower Bound Restriction sets the lower bound of the resources to be examined to the value
* needed to successfully execute the next smaller load.
*
* @param results Result object used as a basis to restrict the resources.
*/
......
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