Skip to content
Snippets Groups Projects
Commit 153b2bfd authored by Benedikt Wetzel's avatar Benedikt Wetzel Committed by Sören Henning
Browse files

clean up

parent 97204abf
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,58 +2,34 @@ package theodolite.benchmark
import theodolite.execution.BenchmarkExecutor
import theodolite.execution.BenchmarkExecutorImpl
import theodolite.strategies.restriction.LowerBoundRestriction
import theodolite.strategies.restriction.RestrictionStrategy
import theodolite.strategies.searchstrategy.BinarySearch
import theodolite.strategies.StrategiesManager
import theodolite.strategies.searchstrategy.CompositeStrategy
import theodolite.strategies.searchstrategy.LinearSearch
import theodolite.strategies.searchstrategy.SearchStrategy
import theodolite.util.Config
import theodolite.util.LoadDimension
import theodolite.util.Resource
import theodolite.util.Results
import java.lang.IllegalArgumentException
import java.time.Duration
class TheodoliteBenchmarkExecutor(
private val benchmarkContext: BenchmarkContext,
private val kubernetesBenchmark: KubernetesBenchmark)
{
private fun createSearchStrategy(executor: BenchmarkExecutor): SearchStrategy {
return when (this.benchmarkContext.execution.strategy) {
"LinearSearch" -> LinearSearch(executor)
"BinarySearch" -> BinarySearch(executor)
else -> throw IllegalArgumentException("Search Strategy ${this.benchmarkContext.execution.strategy} not found")
}
}
private fun createRestrictionStrategy(results: Results): Set<RestrictionStrategy> {
var strategies = emptyList<RestrictionStrategy>()
strategies = this.benchmarkContext.execution.restrictions.map { restriction ->
when (restriction) {
"LowerBound" -> LowerBoundRestriction(results)
else -> throw IllegalArgumentException("Restriction Strategy ${this.benchmarkContext.execution.restrictions} not found")
}
}
return strategies.toSet()
}
private fun buildConfig(): Config{
val results = Results()
val strategyManager = StrategiesManager()
val executionDuration = Duration.ofSeconds(this.benchmarkContext.execution.duration)
val executor: BenchmarkExecutor = BenchmarkExecutorImpl(kubernetesBenchmark, results, executionDuration, this.benchmarkContext.configOverrides)
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 = createSearchStrategy(executor),
restrictionStrategies = createRestrictionStrategy(results)
),
executionDuration = executionDuration
)
searchStrategy = strategyManager.createSearchStrategy(executor, this.benchmarkContext.execution.strategy),
restrictionStrategies = strategyManager.createRestrictionStrategy(results, this.benchmarkContext.execution.restrictions)),
executionDuration = executionDuration)
}
......
......
......@@ -5,6 +5,7 @@ import org.apache.kafka.clients.admin.AdminClient
import org.apache.kafka.clients.admin.AdminClientConfig
import org.apache.kafka.clients.admin.ListTopicsResult
import org.apache.kafka.clients.admin.NewTopic
import java.util.*
private val logger = KotlinLogging.logger {}
......
......
package theodolite.strategies
import theodolite.execution.BenchmarkExecutor
import theodolite.strategies.restriction.LowerBoundRestriction
import theodolite.strategies.restriction.RestrictionStrategy
import theodolite.strategies.searchstrategy.BinarySearch
import theodolite.strategies.searchstrategy.LinearSearch
import theodolite.strategies.searchstrategy.SearchStrategy
import theodolite.util.Results
import java.lang.IllegalArgumentException
class StrategiesManager {
fun createSearchStrategy(executor: BenchmarkExecutor, searchStrategyString: String): SearchStrategy {
return when (searchStrategyString) {
"LinearSearch" -> LinearSearch(executor)
"BinarySearch" -> BinarySearch(executor)
else -> throw IllegalArgumentException("Search Strategy $searchStrategyString not found")
}
}
fun createRestrictionStrategy(results: Results, restrictionStrings: List<String>): Set<RestrictionStrategy> {
return restrictionStrings
.map { restriction ->
when (restriction) {
"LowerBound" -> LowerBoundRestriction(results)
else -> throw IllegalArgumentException("Restriction Strategy $restrictionStrings not found")
}
}.toSet()
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment