From a1af54d892ef6c4c1b4c550e26c4b0678680ee11 Mon Sep 17 00:00:00 2001 From: lorenz <stu203404@mail.uni-kiel.de> Date: Thu, 25 Mar 2021 18:23:07 +0100 Subject: [PATCH] Add stop of a running experiment by flag + Reimplement waitAndLog() in BechmarkExecutor + skipp analysis in BenchmarkExecutorImpl + Skipp further experiments --- .../theodolite/execution/BenchmarkExecutor.kt | 19 ++++++++++++++----- .../execution/BenchmarkExecutorImpl.kt | 10 +++++++--- .../execution/TheodoliteExecutor.kt | 7 +++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index 6504abfa8..cbe59dd22 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -1,6 +1,5 @@ package theodolite.execution -import io.smallrye.mutiny.helpers.Subscriptions.cancel import mu.KotlinLogging import theodolite.benchmark.Benchmark import theodolite.benchmark.BenchmarkExecution @@ -28,6 +27,8 @@ abstract class BenchmarkExecutor( val slo: BenchmarkExecution.Slo ) { + var run = true + /** * Run a experiment for the given parametrization, evaluate the experiment and save the result. * @@ -38,7 +39,8 @@ abstract class BenchmarkExecutor( abstract fun runExperiment(load: LoadDimension, res: Resource): Boolean fun stop() { - throw InterruptedException() + run = false + //throw InterruptedException() } /** @@ -47,12 +49,19 @@ abstract class BenchmarkExecutor( */ fun waitAndLog() { logger.info { "Execution of a new benchmark started." } - for (i in 1.rangeTo(executionDuration.toSeconds())) { + var secondsRunning = 0L + + while (run && secondsRunning < executionDuration.toSeconds()) { + secondsRunning++ Thread.sleep(Duration.ofSeconds(1).toMillis()) - if ((i % 60) == 0L) { - logger.info { "Executed: ${i / 60} minutes" } + + if ((secondsRunning % 60) == 0L) { + logger.info { "Executed: ${secondsRunning / 60} minutes" } } } + + logger.info { "Exucutor shutdown gracefully" } + } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index e8b7a1a26..57dd1c77b 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -20,15 +20,19 @@ class BenchmarkExecutorImpl( slo: BenchmarkExecution.Slo ) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean { + var result = false val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) benchmarkDeployment.setup() this.waitAndLog() - val result = AnalysisExecutor(slo = slo).analyse(load = load, res = res, executionDuration = executionDuration) + if (this.run) { + result = + AnalysisExecutor(slo = slo).analyse(load = load, res = res, executionDuration = executionDuration) - benchmarkDeployment.teardown() + benchmarkDeployment.teardown() - this.results.setResult(Pair(load, res), result) + this.results.setResult(Pair(load, res), result) + } return result } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index d3d2357ae..e831bcc1d 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -19,7 +19,7 @@ class TheodoliteExecutor( private var kubernetesBenchmark: KubernetesBenchmark ) { private val executionThread = Thread() { - if(config == null || kubernetesBenchmark == null) { + if (config == null || kubernetesBenchmark == null) { logger.error { "Execution or Benchmark not found" } } else { val config = buildConfig() @@ -98,7 +98,9 @@ class TheodoliteExecutor( val config = buildConfig() // execute benchmarks for each load for (load in config.loads) { - config.compositeStrategy.findSuitableResource(load, config.resources) + if (isRunning) { + config.compositeStrategy.findSuitableResource(load, config.resources) + } } logger.info { "Stop Thread" } } @@ -109,6 +111,7 @@ class TheodoliteExecutor( isRunning = false try { executor.stop() + Shutdown(config, kubernetesBenchmark).run() } catch (e: InterruptedException) { logger.warn { "Execution stopped" } } -- GitLab