Skip to content
Snippets Groups Projects
Commit f580e1ae authored by Sören Henning's avatar Sören Henning
Browse files

Merge branch 'feature/158-handle-shutdown' into 'theodolite-kotlin'

Handle shutdown

See merge request !96
parents 22913c8a b73c1936
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!96Handle shutdown,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Pipeline #2457 passed
package theodolite.execution
import mu.KotlinLogging
import theodolite.benchmark.BenchmarkExecution
import theodolite.benchmark.KubernetesBenchmark
import theodolite.util.LoadDimension
import theodolite.util.Resource
private val logger = KotlinLogging.logger {}
class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val benchmark: KubernetesBenchmark) :
Thread() {
override fun run() {
// Build Configuration to teardown
logger.info { "Received shutdown signal -> Shutting down" }
val deployment =
benchmark.buildDeployment(
load = LoadDimension(0, emptyList()),
res = Resource(0, emptyList()),
configurationOverrides = benchmarkExecution.configOverrides
)
logger.info { "Teardown the everything deployed" }
deployment.teardown()
logger.info { "Teardown completed" }
}
}
...@@ -21,8 +21,13 @@ class TheodoliteExecutor( ...@@ -21,8 +21,13 @@ class TheodoliteExecutor(
val strategyFactory = StrategyFactory() val strategyFactory = StrategyFactory()
val executionDuration = Duration.ofSeconds(config.execution.duration) val executionDuration = Duration.ofSeconds(config.execution.duration)
val resourcePatcherDefinition = PatcherDefinitionFactory().createPatcherDefinition(config.resources.resourceType, this.kubernetesBenchmark.resourceTypes)
val loadDimensionPatcherDefinition = PatcherDefinitionFactory().createPatcherDefinition(config.load.loadType, this.kubernetesBenchmark.loadTypes) val resourcePatcherDefinition = PatcherDefinitionFactory().createPatcherDefinition(
config.resources.resourceType,
this.kubernetesBenchmark.resourceTypes
)
val loadDimensionPatcherDefinition =
PatcherDefinitionFactory().createPatcherDefinition(config.load.loadType, this.kubernetesBenchmark.loadTypes)
val executor = val executor =
BenchmarkExecutorImpl( BenchmarkExecutorImpl(
...@@ -35,7 +40,12 @@ class TheodoliteExecutor( ...@@ -35,7 +40,12 @@ class TheodoliteExecutor(
return Config( return Config(
loads = config.load.loadValues.map { load -> LoadDimension(load, loadDimensionPatcherDefinition) }, loads = config.load.loadValues.map { load -> LoadDimension(load, loadDimensionPatcherDefinition) },
resources = config.resources.resourceValues.map { resource -> Resource(resource, resourcePatcherDefinition) }, resources = config.resources.resourceValues.map { resource ->
Resource(
resource,
resourcePatcherDefinition
)
},
compositeStrategy = CompositeStrategy( compositeStrategy = CompositeStrategy(
benchmarkExecutor = executor, benchmarkExecutor = executor,
searchStrategy = strategyFactory.createSearchStrategy(executor, config.execution.strategy), searchStrategy = strategyFactory.createSearchStrategy(executor, config.execution.strategy),
......
...@@ -22,6 +22,8 @@ object TheodoliteYamlExecutor { ...@@ -22,6 +22,8 @@ object TheodoliteYamlExecutor {
val benchmark = val benchmark =
parser.parse("./../../../resources/main/yaml/BenchmarkType.yaml", KubernetesBenchmark::class.java)!! parser.parse("./../../../resources/main/yaml/BenchmarkType.yaml", KubernetesBenchmark::class.java)!!
Runtime.getRuntime().addShutdownHook(Shutdown(benchmarkExecution, benchmark))
val executor = TheodoliteExecutor(benchmarkExecution, benchmark) val executor = TheodoliteExecutor(benchmarkExecution, benchmark)
executor.run() executor.run()
logger.info { "Theodolite finished" } logger.info { "Theodolite finished" }
......
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