Skip to content
Snippets Groups Projects
Commit 83de527c authored by Marcel Samir Becker's avatar Marcel Samir Becker
Browse files

Execution yaml restructuring, strategy.name indicates strategy type

parent cbf2f3d2
No related branches found
No related tags found
1 merge request!215Redesign Strategy, Load, and Resources data types
...@@ -93,11 +93,12 @@ spec: ...@@ -93,11 +93,12 @@ spec:
name: string name: string
properties: properties:
restrictions: restrictions:
description: List of restriction strategys used to delimit the search space. description: List of restriction strategies used to delimit the search space.
type: array type: array
items: items:
type: string type: string
guessStrategy: string guessStrategy: string
searchStrategy: object
properties: properties:
duration: duration:
description: Defines the duration of each experiment in seconds. description: Defines the duration of each experiment in seconds.
......
...@@ -59,6 +59,7 @@ class BenchmarkExecution : KubernetesResource { ...@@ -59,6 +59,7 @@ class BenchmarkExecution : KubernetesResource {
lateinit var name: String lateinit var name: String
lateinit var restrictions: List<String> lateinit var restrictions: List<String>
lateinit var guessStrategy: String lateinit var guessStrategy: String
lateinit var searchStrategy: String
} }
/** /**
......
...@@ -92,7 +92,8 @@ class TheodoliteExecutor( ...@@ -92,7 +92,8 @@ class TheodoliteExecutor(
resourcePatcherDefinition resourcePatcherDefinition
) )
}, },
searchStrategy = strategyFactory.createSearchStrategy(executor, config.execution.strategy, results) searchStrategy = strategyFactory.createSearchStrategy(executor, config.execution.strategy, results),
metric = config.execution.metric
) )
} }
...@@ -119,6 +120,10 @@ class TheodoliteExecutor( ...@@ -119,6 +120,10 @@ class TheodoliteExecutor(
val config = buildConfig() val config = buildConfig()
//TODO: Differentiate metrics here //TODO: Differentiate metrics here
// when (config.metric) {
// "demand" -> // execute benchmarks for each load
// "capacity" -> // execute benchmarks for each resource amount
// }
// execute benchmarks for each load // execute benchmarks for each load
try { try {
for (load in config.loads) { for (load in config.loads) {
......
...@@ -27,15 +27,21 @@ class StrategyFactory { ...@@ -27,15 +27,21 @@ class StrategyFactory {
"FullSearch" -> FullSearch(executor) "FullSearch" -> FullSearch(executor)
"LinearSearch" -> LinearSearch(executor) "LinearSearch" -> LinearSearch(executor)
"BinarySearch" -> BinarySearch(executor) "BinarySearch" -> BinarySearch(executor)
"RestrictionSearch" -> when (searchStrategyObject.searchStrategy){
//TODO: Do we only need LinearSearch here as valid searchstrat? Or actually just allow all?
// If we dont have restriction Strat specified but still RestrictionSearch just do normal Search
"FullSearch" -> composeSearchRestrictionStrategy(executor, FullSearch(executor), results, searchStrategyObject.restrictions)
"LinearSearch" -> composeSearchRestrictionStrategy(executor, LinearSearch(executor), results, searchStrategyObject.restrictions)
"BinarySearch" -> composeSearchRestrictionStrategy(executor, BinarySearch(executor), results, searchStrategyObject.restrictions)
else -> throw IllegalArgumentException("Search Strategy ${searchStrategyObject.searchStrategy} for RestrictionSearch not found")
}
"InitialGuessSearch" -> when (searchStrategyObject.guessStrategy){ "InitialGuessSearch" -> when (searchStrategyObject.guessStrategy){
"PrevResourceMinGuess" -> InitialGuessSearchStrategy(executor,PrevResourceMinGuess(), results) "PrevResourceMinGuess" -> InitialGuessSearchStrategy(executor,PrevResourceMinGuess(), results)
else -> throw IllegalArgumentException("Guess Strategy ${searchStrategyObject.guessStrategy} not found") else -> throw IllegalArgumentException("Guess Strategy ${searchStrategyObject.guessStrategy} not found")
} }
else -> throw IllegalArgumentException("Search Strategy $searchStrategyObject not found") else -> throw IllegalArgumentException("Search Strategy $searchStrategyObject not found")
} }
if(searchStrategyObject.restrictions.isNotEmpty()){
strategy = RestrictionSearch(executor,strategy,createRestrictionStrategy(results, searchStrategyObject.restrictions))
}
return strategy return strategy
} }
...@@ -58,4 +64,21 @@ class StrategyFactory { ...@@ -58,4 +64,21 @@ class StrategyFactory {
} }
}.toSet() }.toSet()
} }
/**
* Create a RestrictionSearch, if the provided restriction list is not empty. Otherwise just return the given
* searchStrategy.
*
* @param executor The [theodolite.execution.BenchmarkExecutor] that executes individual experiments.
* @param searchStrategy The [SearchStrategy] to use
* @param results The [Results] saves the state of the Theodolite benchmark run.
* @param restrictions The [RestrictionStrategy]'s to use
*/
private fun composeSearchRestrictionStrategy(executor: BenchmarkExecutor, searchStrategy: SearchStrategy,
results: Results, restrictions: List<String>): SearchStrategy {
if(restrictions.isNotEmpty()){
return RestrictionSearch(executor,searchStrategy,createRestrictionStrategy(results, restrictions))
}
return searchStrategy
}
} }
...@@ -10,10 +10,12 @@ import theodolite.strategies.searchstrategy.SearchStrategy ...@@ -10,10 +10,12 @@ import theodolite.strategies.searchstrategy.SearchStrategy
* @param loads the [LoadDimension] of the execution * @param loads the [LoadDimension] of the execution
* @param resources the [Resource] of the execution * @param resources the [Resource] of the execution
* @param searchStrategy the [SearchStrategy] of the execution * @param searchStrategy the [SearchStrategy] of the execution
* @param metric the Metric of the execution
*/ */
@RegisterForReflection @RegisterForReflection
data class Config( data class Config(
val loads: List<LoadDimension>, val loads: List<LoadDimension>,
val resources: List<Resource>, val resources: List<Resource>,
val searchStrategy: SearchStrategy val searchStrategy: SearchStrategy,
val metric: String
) )
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