Skip to content
Snippets Groups Projects
Commit 0ccce97d authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

Start theodolite without dedicated thread

parent 93cd7ab3
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!106Introduce a Theodolite operator,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
This commit is part of merge request !106. Comments created here will be created in the context of that merge request.
......@@ -5,7 +5,10 @@ import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.api.model.Namespaced
import io.fabric8.kubernetes.client.CustomResource
import theodolite.util.ConfigurationOverride
import java.lang.System.exit
import kotlin.concurrent.thread
import kotlin.properties.Delegates
import kotlin.system.exitProcess
@JsonDeserialize
class BenchmarkExecution : CustomResource(), Namespaced {
......@@ -17,6 +20,10 @@ class BenchmarkExecution : CustomResource(), Namespaced {
lateinit var execution: Execution
lateinit var configOverrides: List<ConfigurationOverride?>
fun stop() {
throw InterruptedException()
}
@JsonDeserialize
class Execution : KubernetesResource {
lateinit var strategy: String
......
package theodolite.execution
import io.smallrye.mutiny.helpers.Subscriptions.cancel
import mu.KotlinLogging
import theodolite.benchmark.Benchmark
import theodolite.benchmark.BenchmarkExecution
......@@ -36,6 +37,10 @@ abstract class BenchmarkExecutor(
*/
abstract fun runExperiment(load: LoadDimension, res: Resource): Boolean
fun stop() {
throw InterruptedException()
}
/**
* Wait while the benchmark is running and log the number of minutes executed every 1 minute.
*
......
......@@ -21,7 +21,6 @@ class TheodoliteController(
val executionContext: CustomResourceDefinitionContext
) {
lateinit var executor: TheodoliteExecutor
val self = this
val executionsQueue: Queue<BenchmarkExecution> = LinkedList<BenchmarkExecution>()
val benchmarks: MutableMap<String, KubernetesBenchmark> = HashMap()
......@@ -94,6 +93,8 @@ class TheodoliteController(
while (true) {
try {
reconcile()
logger.info { "Theodolite is waiting for new jobs" }
sleep(1000)
} catch (e: InterruptedException) {
logger.error { "Execution interrupted with error: $e" }
}
......@@ -113,10 +114,16 @@ class TheodoliteController(
executor = TheodoliteExecutor(config = execution, kubernetesBenchmark = benchmark)
executor.run()
// wait until executions is deleted
client.customResource(executionContext).delete(client.namespace, execution.metadata.name)
while (executionsQueue.contains(execution)) {
sleep(1000)
try {
client.customResource(executionContext).delete(client.namespace, execution.metadata.name)
while (executionsQueue.contains(execution)) {
logger.info { "sleep" }
sleep(1000)
}
} catch (e: Exception) {
logger.error { "Error while delete current execution" }
}
logger.info { "Execution is finally stopped for execution ${execution.name}" }
}
}
}
......
......@@ -32,6 +32,7 @@ class TheodoliteExecutor(
}
var isRunning = false
lateinit var executor: BenchmarkExecutor
private fun buildConfig(): Config {
val results = Results()
......@@ -51,7 +52,7 @@ class TheodoliteExecutor(
this.kubernetesBenchmark.loadTypes
)
val executor =
executor =
BenchmarkExecutorImpl(
kubernetesBenchmark,
results,
......@@ -90,13 +91,26 @@ class TheodoliteExecutor(
fun run() {
isRunning = true
logger.info { "Start thread" }
executionThread.start()
logger.info { "Stop Thread" }
// executionThread.start()
if (config == null || kubernetesBenchmark == null) {
logger.error { "Execution or Benchmark not found" }
} else {
val config = buildConfig()
// execute benchmarks for each load
for (load in config.loads) {
config.compositeStrategy.findSuitableResource(load, config.resources)
}
logger.info { "Stop Thread" }
}
}
fun stop() {
// TODO call shutdown hook
isRunning = false
executionThread.interrupt()
try {
executor.stop()
} catch (e: InterruptedException) {
logger.warn { "Execution stopped" }
}
}
}
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