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

clean up and restructure

move old and unused classes to the new a package called depcrecated and update all types to the new ones.
parent 0cdba1d1
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
Showing
with 157 additions and 132 deletions
......@@ -2,7 +2,7 @@ package theodolite
import io.quarkus.runtime.annotations.QuarkusMain
import mu.KotlinLogging
import theodolite.benchmark.TheodoliteYamlExecutor
import theodolite.execution.TheodoliteYamlExecutor
private val logger = KotlinLogging.logger {}
......
......@@ -3,7 +3,7 @@ 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.YamlLoader
import theodolite.k8s.K8sResourceLoader
import theodolite.patcher.PatcherManager
import theodolite.util.*
import java.util.*
......@@ -21,8 +21,8 @@ class KubernetesBenchmark(): Benchmark {
private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> {
val basePath = "./../../../resources/main/yaml/"
var parser = theodolite.benchmark.BenchmarkYamlParser()
val loader = YamlLoader(DefaultKubernetesClient().inNamespace("default"))
var parser = YamlParser()
val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace("default"))
return resources
.map { resource ->
val resourcePath = "$basePath/$resource"
......@@ -32,9 +32,6 @@ class KubernetesBenchmark(): Benchmark {
}
}
override fun buildDeployment(load: LoadDimension, res: Resource, overrides: List<OverridePatcherDefinition>): BenchmarkDeployment {
// TODO("set node selector")
val resources = loadKubernetesResources(this.appResource + this.loadGenResource)
......
......@@ -9,7 +9,7 @@ import theodolite.k8s.WorkloadGeneratorStateCleaner
import java.util.*
class KubernetesBenchmarkDeployment(
val resources: List<KubernetesResource>, // List of already patched resources
val resources: List<KubernetesResource>,
private val kafkaConfig: HashMap<String, Any>,
private val zookeeperConfig: String,
private val topics: Collection<NewTopic>
......
package theodolite.benchmark
import theodolite.util.LoadDimension
import theodolite.util.OverridePatcherDefinition
import theodolite.util.Resource
class TestBenchmark : Benchmark {
override fun buildDeployment(
load: LoadDimension,
res: Resource,
override: List<OverridePatcherDefinition>
): BenchmarkDeployment {
return TestBenchmarkDeployment()
}
}
package theodolite.benchmark
class TestBenchmarkDeployment: BenchmarkDeployment {
override fun setup() {
}
override fun teardown() {
}
}
\ No newline at end of file
package theodolite.benchmark
import theodolite.execution.BenchmarkExecutor
import theodolite.execution.BenchmarkExecutorImpl
import theodolite.strategies.StrategiesManager
import theodolite.strategies.searchstrategy.CompositeStrategy
import theodolite.util.Config
import theodolite.util.LoadDimension
import theodolite.util.Resource
import theodolite.util.Results
import java.time.Duration
class TheodoliteBenchmarkExecutor(
private val benchmarkContext: BenchmarkContext,
private val kubernetesBenchmark: KubernetesBenchmark)
{
private fun buildConfig(): Config{
val results = Results()
val strategyManager = StrategiesManager()
val executionDuration = Duration.ofSeconds(this.benchmarkContext.execution.duration)
val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, this.benchmarkContext.configOverrides)
return Config(
loads = benchmarkContext.loads.map { number -> LoadDimension(number) },
resources = benchmarkContext.resources.map { number -> Resource(number) },
compositeStrategy = CompositeStrategy(
benchmarkExecutor = executor,
searchStrategy = strategyManager.createSearchStrategy(executor, this.benchmarkContext.execution.strategy),
restrictionStrategies = strategyManager.createRestrictionStrategy(results, this.benchmarkContext.execution.restrictions)),
executionDuration = executionDuration)
}
fun run() {
val config = buildConfig()
// execute benchmarks for each load
for (load in config.loads) {
config.compositeStrategy.findSuitableResource(load, config.resources)
}
}
}
package theodolite.util
package theodolite.deprecated
import theodolite.util.LoadDimension
import theodolite.util.Resource
abstract class AbstractBenchmark(val config: Config): Benchmark {
override fun start(load: LoadDimension, resources: Resource) {
......@@ -24,4 +27,4 @@ abstract class AbstractBenchmark(val config: Config): Benchmark {
val ucImageURL: String,
val wgImageURL: String
) {}
}
}
\ No newline at end of file
package theodolite.util
package theodolite.deprecated
import theodolite.util.LoadDimension
import theodolite.util.Resource
interface Benchmark {
fun start(load: LoadDimension, resources: Resource) {
......@@ -9,4 +12,4 @@ interface Benchmark {
fun startSUT(resources: Resource);
fun startWorkloadGenerator(load: LoadDimension)
}
\ No newline at end of file
}
package theodolite.k8s
package theodolite.deprecated
import io.fabric8.kubernetes.api.model.ConfigMap
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
......
package theodolite.k8s
package theodolite.deprecated
import io.fabric8.kubernetes.api.model.Service
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
......
package theodolite.deprecated
/*
import mu.KotlinLogging
import theodolite.deprecated.AbstractBenchmark
import theodolite.k8s.UC1Benchmark
import theodolite.strategies.restriction.LowerBoundRestriction
import theodolite.strategies.searchstrategy.CompositeStrategy
import theodolite.strategies.searchstrategy.LinearSearch
import theodolite.util.*
import java.nio.file.Paths
import java.time.Duration
private val logger = KotlinLogging.logger {}
class TheodoliteExecutor() {
val projectDirAbsolutePath = Paths.get("").toAbsolutePath().toString()
val resourcesPath = Paths.get(projectDirAbsolutePath, "./../../../resources/main/yaml/")
private fun loadConfig(): Config {
logger.info { resourcesPath }
val benchmark: UC1Benchmark = UC1Benchmark(
AbstractBenchmark.Config(
clusterZookeeperConnectionString = "my-confluent-cp-zookeeper:2181",
clusterKafkaConnectionString = "my-confluent-cp-kafka:9092",
externalZookeeperConnectionString = "localhost:2181",
externalKafkaConnectionString = "localhost:9092",
schemaRegistryConnectionString = "http://my-confluent-cp-schema-registry:8081",
kafkaPartition = 40,
kafkaReplication = 1,
kafkaTopics = listOf("input", "output"),
// TODO("handle path in a more nice way (not absolut)")
ucDeploymentPath = "$resourcesPath/aggregation-deployment.yaml",
ucServicePath = "$resourcesPath/aggregation-service.yaml",
wgDeploymentPath = "$resourcesPath/workloadGenerator.yaml",
configMapPath = "$resourcesPath/jmx-configmap.yaml",
ucImageURL = "ghcr.io/cau-se/theodolite-uc1-kstreams-app:latest",
wgImageURL = "ghcr.io/cau-se/theodolite-uc1-workload-generator:theodolite-kotlin-latest"
)
)
val results: Results = Results()
val executionDuration = Duration.ofSeconds(60 * 5)
val executor: BenchmarkExecutor = BenchmarkExecutorImpl(benchmark, results, executionDuration)
val restrictionStrategy = LowerBoundRestriction(results)
val searchStrategy = LinearSearch(executor)
return Config(
loads = listOf(5000, 10000).map { number -> LoadDimension(number) },
resources = (1..6).map { number -> Resource(number) },
compositeStrategy = CompositeStrategy(
executor,
searchStrategy,
restrictionStrategies = setOf(restrictionStrategy)
),
executionDuration = executionDuration
)
}
fun run() {
// read or get benchmark config
val config = this.loadConfig()
// execute benchmarks for each load
for (load in config.loads) {
config.compositeStrategy.findSuitableResource(load, config.resources)
}
}
}
*/
\ No newline at end of file
package theodolite.k8s
package theodolite.deprecated
/*
import io.fabric8.kubernetes.api.model.ConfigMap
import io.fabric8.kubernetes.api.model.Service
import io.fabric8.kubernetes.api.model.apps.Deployment
import io.fabric8.kubernetes.client.DefaultKubernetesClient
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import mu.KotlinLogging
import theodolite.util.AbstractBenchmark
import theodolite.deprecated.AbstractBenchmark
import theodolite.util.LoadDimension
import theodolite.util.Resource
......@@ -93,5 +93,5 @@ class UC1Benchmark(config: Config) : AbstractBenchmark(config) {
this.deploymentManager.setWorkloadEnv(this.wgDeployment, "workload-generator", environmentVariables)
this.deploymentManager.deploy(this.wgDeployment)
}
}
*/
\ No newline at end of file
......@@ -2,7 +2,6 @@ package theodolite.execution
import mu.KotlinLogging
import theodolite.benchmark.Benchmark
import theodolite.benchmark.KubernetesBenchmark
import theodolite.util.*
import java.time.Duration
......
......@@ -4,7 +4,7 @@ import theodolite.benchmark.Benchmark
import theodolite.util.*
import java.time.Duration
class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, private val overrides: List<OverridePatcherDefinition>) : BenchmarkExecutor(benchmark, results, executionDuration, overrides) {
class BenchmarkExecutorImpl(benchmark: Benchmark, results: Results, executionDuration: Duration, val overrides: List<OverridePatcherDefinition>) : BenchmarkExecutor(benchmark, results, executionDuration, overrides) {
override fun runExperiment(load: LoadDimension, res: Resource): Boolean {
val benchmarkDeployment = benchmark.buildDeployment(load, res, this.overrides)
benchmarkDeployment.setup()
......
package theodolite.execution
import theodolite.benchmark.Benchmark
import theodolite.benchmark.KubernetesBenchmark
import theodolite.util.AbstractBenchmark
import theodolite.util.LoadDimension
import theodolite.util.Resource
import theodolite.util.Results
......
package theodolite.execution
/*
import mu.KotlinLogging
import theodolite.k8s.UC1Benchmark
import theodolite.strategies.restriction.LowerBoundRestriction
import theodolite.benchmark.BenchmarkContext
import theodolite.benchmark.KubernetesBenchmark
import theodolite.strategies.StrategiesManager
import theodolite.strategies.searchstrategy.CompositeStrategy
import theodolite.strategies.searchstrategy.LinearSearch
import theodolite.util.*
import java.nio.file.Paths
import theodolite.util.Config
import theodolite.util.LoadDimension
import theodolite.util.Resource
import theodolite.util.Results
import java.time.Duration
private val logger = KotlinLogging.logger {}
class TheodoliteExecutor() {
val projectDirAbsolutePath = Paths.get("").toAbsolutePath().toString()
val resourcesPath = Paths.get(projectDirAbsolutePath, "./../../../resources/main/yaml/")
private fun loadConfig(): Config {
logger.info { resourcesPath }
val benchmark: UC1Benchmark = UC1Benchmark(
AbstractBenchmark.Config(
clusterZookeeperConnectionString = "my-confluent-cp-zookeeper:2181",
clusterKafkaConnectionString = "my-confluent-cp-kafka:9092",
externalZookeeperConnectionString = "localhost:2181",
externalKafkaConnectionString = "localhost:9092",
schemaRegistryConnectionString = "http://my-confluent-cp-schema-registry:8081",
kafkaPartition = 40,
kafkaReplication = 1,
kafkaTopics = listOf("input", "output"),
// TODO("handle path in a more nice way (not absolut)")
ucDeploymentPath = "$resourcesPath/aggregation-deployment.yaml",
ucServicePath = "$resourcesPath/aggregation-service.yaml",
wgDeploymentPath = "$resourcesPath/workloadGenerator.yaml",
configMapPath = "$resourcesPath/jmx-configmap.yaml",
ucImageURL = "ghcr.io/cau-se/theodolite-uc1-kstreams-app:latest",
wgImageURL = "ghcr.io/cau-se/theodolite-uc1-workload-generator:theodolite-kotlin-latest"
)
)
val results: Results = Results()
val executionDuration = Duration.ofSeconds(60 * 5)
class TheodoliteExecutor(
private val benchmarkContext: BenchmarkContext,
private val kubernetesBenchmark: KubernetesBenchmark
)
{
val executor: BenchmarkExecutor = BenchmarkExecutorImpl(benchmark, results, executionDuration)
private fun buildConfig(): Config{
val results = Results()
val strategyManager = StrategiesManager()
val restrictionStrategy = LowerBoundRestriction(results)
val searchStrategy = LinearSearch(executor)
val executionDuration = Duration.ofSeconds(this.benchmarkContext.execution.duration)
val executor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, this.benchmarkContext.configOverrides)
return Config(
loads = listOf(5000, 10000).map { number -> LoadDimension(number) },
resources = (1..6).map { number -> Resource(number) },
compositeStrategy = CompositeStrategy(
executor,
searchStrategy,
restrictionStrategies = setOf(restrictionStrategy)
),
executionDuration = executionDuration
)
loads = benchmarkContext.loads.map { number -> LoadDimension(number) },
resources = benchmarkContext.resources.map { number -> Resource(number) },
compositeStrategy = CompositeStrategy(
benchmarkExecutor = executor,
searchStrategy = strategyManager.createSearchStrategy(executor, this.benchmarkContext.execution.strategy),
restrictionStrategies = strategyManager.createRestrictionStrategy(results, this.benchmarkContext.execution.restrictions)),
executionDuration = executionDuration)
}
fun run() {
// read or get benchmark config
val config = this.loadConfig()
val config = buildConfig()
// execute benchmarks for each load
for (load in config.loads) {
config.compositeStrategy.findSuitableResource(load, config.resources)
}
}
}
*/
package theodolite.benchmark
package theodolite.execution
import theodolite.benchmark.BenchmarkContext
import theodolite.util.YamlParser
import theodolite.benchmark.KubernetesBenchmark
class TheodoliteYamlExecutor {
fun run() {
// load the Benchmark context and the benchmark type
var parser = theodolite.benchmark.BenchmarkYamlParser()
var parser = YamlParser()
val benchmarkContext = parser.parse("./../../../resources/main/yaml/testContext.yaml", BenchmarkContext::class.java) !!
val benchmark = parser.parse("./../../../resources/main/yaml/testBenchmarkType.yaml", KubernetesBenchmark::class.java) !!
// TheodoliteExecutor benchmarkContext, benchmark
val executor = TheodoliteBenchmarkExecutor(benchmarkContext, benchmark)
val executor = TheodoliteExecutor(benchmarkContext, benchmark)
executor.run()
System.out.println(benchmark.name)
System.out.println(benchmarkContext.name)
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
this.client.configMaps().createOrReplace(resource)
is StatefulSet ->
this.client.apps().statefulSets().createOrReplace(resource)
else -> throw IllegalArgumentException("Unknown kubernetes resource.")
else -> throw IllegalArgumentException("Unknown Kubernetes resource.")
}
}
......@@ -35,7 +35,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
this.client.configMaps().delete(resource)
is StatefulSet ->
this.client.apps().statefulSets().delete(resource)
else -> throw IllegalArgumentException("Unknown kubernetes resource.")
else -> throw IllegalArgumentException("Unknown Kubernetes resource.")
}
}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ import mu.KotlinLogging
private val logger = KotlinLogging.logger {}
class YamlLoader(private val client: NamespacedKubernetesClient) {
class K8sResourceLoader(private val client: NamespacedKubernetesClient) {
/**
* Parses a Service from a servive yaml
......
package theodolite.util
interface Parser {
fun <T> parse(path: String, E:Class<T>): T? //Yaml
fun <T> parse(path: String, E:Class<T>): T?
}
\ No newline at end of file
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