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

Added review suggestions

parent 9e672e40
No related branches found
No related tags found
1 merge request!215Redesign Strategy, Load, and Resources data types
......@@ -20,7 +20,7 @@ spec:
properties:
spec:
type: object
required: ["benchmark", "load", "resources", "slos", "execution", "configOverrides"]
required: ["benchmark", "loads", "resources", "slos", "execution", "configOverrides"]
properties:
name:
description: This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.
......
package theodolite.evaluation
import theodolite.benchmark.BenchmarkExecution
import theodolite.strategies.Metric
import theodolite.util.EvaluationFailedException
import theodolite.util.IOHandler
import java.text.Normalizer
......@@ -31,7 +32,7 @@ class AnalysisExecutor(
* @param executionIntervals list of start and end points of experiments
* @return true if the experiment succeeded.
*/
fun analyze(load: Int, resource: Int, executionIntervals: List<Pair<Instant, Instant>>): Boolean {
fun analyze(load: Int, resource: Int, executionIntervals: List<Pair<Instant, Instant>>, metric: Metric): Boolean {
var repetitionCounter = 1
try {
......@@ -56,11 +57,12 @@ class AnalysisExecutor(
)
}
//TODO: CHECK WHETHER WE NEED TO DIFFERENTIATE BETWEEN METRICS AND HAVE SOME NEW KIND OF SLOCHECKER WHICH GETS RESOURCE AS PARAMETER
val sloChecker = SloCheckerFactory().create(
sloType = slo.sloType,
properties = slo.properties,
load = load
load = load,
resource = resource,
metric = metric
)
return sloChecker.evaluate(prometheusData)
......
package theodolite.evaluation
import theodolite.strategies.Metric
/**
* Factory used to potentially create different [SloChecker]s.
......@@ -40,7 +42,9 @@ class SloCheckerFactory {
fun create(
sloType: String,
properties: MutableMap<String, String>,
load: Int
load: Int,
resource: Int,
metric: Metric
): SloChecker {
return when (SloTypes.from(sloType)) {
SloTypes.GENERIC -> ExternalSloChecker(
......
......@@ -65,7 +65,8 @@ class BenchmarkExecutorImpl(
.analyze(
load = load,
resource = resource,
executionIntervals = executionIntervals
executionIntervals = executionIntervals,
metric = this.results.metric
)
}
......
......@@ -14,21 +14,14 @@ private val logger = KotlinLogging.logger {}
* @param guessStrategy Strategy that provides us with a guess for the first resource amount.
* @param results current results of all previously performed benchmarks.
*/
class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStrategy: GuessStrategy, results: Results) :
SearchStrategy(benchmarkExecutor, guessStrategy, results) {
class InitialGuessSearchStrategy(
benchmarkExecutor: BenchmarkExecutor,
private val guessStrategy: GuessStrategy,
private var results: Results
) : SearchStrategy(benchmarkExecutor) {
override fun findSuitableResource(load: Int, resources: List<Int>): Int? {
if(this.guessStrategy == null){
logger.info { "Your InitialGuessSearchStrategy doesn't have a GuessStrategy. This is not supported." }
return null
}
if(results == null){
logger.info { "The results need to be initialized." }
return null
}
var lastLowestResource : Int? = null
// Getting the lastLowestResource from results and calling firstGuess() with it
......@@ -83,16 +76,6 @@ class InitialGuessSearchStrategy(benchmarkExecutor: BenchmarkExecutor, guessStra
override fun findSuitableLoad(resource: Int, loads: List<Int>): Int?{
if(this.guessStrategy == null){
logger.info { "Your InitialGuessSearchStrategy doesn't have a GuessStrategy. This is not supported." }
return null
}
if(results == null){
logger.info { "The results need to be initialized." }
return null
}
var lastMaxLoad : Int? = null
// Getting the lastLowestLoad from results and calling firstGuess() with it
......
......@@ -14,8 +14,7 @@ import theodolite.util.Results
* @param results the [Results] object.
*/
@RegisterForReflection
abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor, val guessStrategy: GuessStrategy? = null,
val results: Results? = null) {
abstract class SearchStrategy(val benchmarkExecutor: BenchmarkExecutor) {
/**
......
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