diff --git a/theodolite-quarkus/src/main/docker/Dockerfile.jvm b/theodolite-quarkus/src/main/docker/Dockerfile.jvm index 232ab03978c949e3d3b144813dd2c465d0d44a96..6733d5d441e8292e02547cf59131c706575e9d86 100644 --- a/theodolite-quarkus/src/main/docker/Dockerfile.jvm +++ b/theodolite-quarkus/src/main/docker/Dockerfile.jvm @@ -41,7 +41,7 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. -ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus.package.main-class=TheodoliteOperator" +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" COPY build/lib/* /deployments/lib/ COPY build/*-runner.jar /deployments/app.jar COPY config/ /deployments/config/ diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecutionList.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecutionList.kt index 74ba733d703b2242e16b22aab7d4537a6f5bd88e..50e8967f20aebad880ebd218136749af8e3ea6ee 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecutionList.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecutionList.kt @@ -2,5 +2,4 @@ package theodolite.benchmark import io.fabric8.kubernetes.client.CustomResourceList -class BenchmarkExecutionList : CustomResourceList<BenchmarkExecution>() { -} \ No newline at end of file +class BenchmarkExecutionList : CustomResourceList<BenchmarkExecution>() \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KafkaLagExporterRemover.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KafkaLagExporterRemover.kt index 9e241cabfa208a0632635a30c658590faec2c1a8..2b86c51ae87c7b26609683b68bf6cfc12003efc8 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KafkaLagExporterRemover.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KafkaLagExporterRemover.kt @@ -1,14 +1,14 @@ -package theodolite.benchmark; +package theodolite.benchmark import io.fabric8.kubernetes.client.NamespacedKubernetesClient import mu.KotlinLogging private val logger = KotlinLogging.logger {} -class KafkaLagExporterRemover(private val client : NamespacedKubernetesClient) { +class KafkaLagExporterRemover(private val client: NamespacedKubernetesClient) { - fun remove(label: String){ + fun remove(label: String) { this.client.pods().withLabel(label).delete() - logger.info{"Pod with label: $label deleted"} + logger.info { "Pod with label: $label deleted" } } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkList.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkList.kt index 06d0d268a832a85e71e440534a8e8204ebfb324a..0930875e96146fda58301478bda68b00c229e99f 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkList.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkList.kt @@ -2,5 +2,4 @@ package theodolite.benchmark import io.fabric8.kubernetes.client.CustomResourceList -class KubernetesBenchmarkList : CustomResourceList<KubernetesBenchmark>() { -} \ No newline at end of file +class KubernetesBenchmarkList : CustomResourceList<KubernetesBenchmark>() \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt index 2910d84991c2c37051b4b053c0c024344c0b3ff0..ce63f23a31840b8e47cb15b71a026d35e438e953 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt @@ -16,7 +16,7 @@ class AnalysisExecutor(private val slo: BenchmarkExecution.Slo) { offset = Duration.ofHours(slo.offset.toLong()) ) - fun analyse(load: LoadDimension, res: Resource, executionDuration: Duration): Boolean { + fun analyze(load: LoadDimension, res: Resource, executionDuration: Duration): Boolean { var result = false try { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index 32124ab355d9103143c15294b29d78a2e51d9f4c..9332af89810d24f87016fd02ce56d35a5ab07ca5 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -8,6 +8,7 @@ import theodolite.util.LoadDimension import theodolite.util.Resource import theodolite.util.Results import java.time.Duration +import java.util.concurrent.atomic.AtomicBoolean private val logger = KotlinLogging.logger {} @@ -27,7 +28,7 @@ abstract class BenchmarkExecutor( val slo: BenchmarkExecution.Slo ) { - var run = true + var run: AtomicBoolean = AtomicBoolean(true) /** * Run a experiment for the given parametrization, evaluate the experiment and save the result. @@ -37,11 +38,7 @@ abstract class BenchmarkExecutor( * @return True, if the number of resources are suitable for the given load, false otherwise. */ abstract fun runExperiment(load: LoadDimension, res: Resource): Boolean - - fun stop() { - run = false - } - + /** * Wait while the benchmark is running and log the number of minutes executed every 1 minute. * @@ -51,16 +48,16 @@ abstract class BenchmarkExecutor( var secondsRunning = 0L - while (run && secondsRunning < executionDuration.toSeconds()) { + while (run.get() && secondsRunning < executionDuration.toSeconds()) { secondsRunning++ Thread.sleep(Duration.ofSeconds(1).toMillis()) if ((secondsRunning % 60) == 0L) { - logger.info { "Executed: ${secondsRunning / 60} minutes" } + logger.info { "Executed: ${secondsRunning / 60} minutes." } } } - logger.debug { "Executor shutdown gracefully" } + logger.debug { "Executor 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 26836c46b27c547479a2984d6a9109b87f2481ec..11485285e851fb6a59232bdff3119781b1de378c 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -24,9 +24,9 @@ class BenchmarkExecutorImpl( benchmarkDeployment.setup() this.waitAndLog() - if (this.run) { + if (this.run.get()) { result = - AnalysisExecutor(slo = slo).analyse(load = load, res = res, executionDuration = executionDuration) + AnalysisExecutor(slo = slo).analyze(load = load, res = res, executionDuration = executionDuration) this.results.setResult(Pair(load, res), result) } benchmarkDeployment.teardown() diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteController.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteController.kt index ef1b19e62cc90850b6abdd6cf25ea5da86175ded..e4bd60b7645766d1fda8ecb208bc8b619b1f782e 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteController.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteController.kt @@ -47,7 +47,7 @@ class TheodoliteController( if (::executor.isInitialized && executor.getExecution().name == newExecution.metadata.name) { isUpdated = true - executor.executor.run = false + executor.executor.run.compareAndSet(true, false) } } @@ -56,7 +56,7 @@ class TheodoliteController( executionsQueue.removeIf { e -> e.name == execution.metadata.name } if (::executor.isInitialized && executor.getExecution().name == execution.metadata.name) { isUpdated = true - executor.executor.run = false + executor.executor.run.compareAndSet(true, false) logger.info { "Current benchmark stopped" } } } @@ -74,7 +74,7 @@ class TheodoliteController( newBenchmark.name = newBenchmark.metadata.name if (::executor.isInitialized && executor.getBenchmark().name == oldBenchmark.metadata.name) { isUpdated = true - executor.executor.run = false + executor.executor.run.compareAndSet(true, false) } else { onAdd(newBenchmark) } @@ -85,7 +85,7 @@ class TheodoliteController( benchmarks.remove(benchmark.metadata.name) if (::executor.isInitialized && executor.getBenchmark().name == benchmark.metadata.name) { isUpdated = true - executor.executor.run = false + executor.executor.run.compareAndSet(true, false) logger.info { "Current benchmark stopped" } } } @@ -96,7 +96,15 @@ class TheodoliteController( while (true) { try { reconcile() - logger.info { "Theodolite is waiting for new jobs" } + logger.info { "Theodolite is waiting for new matching benchmark and execution" } + logger.info { "Currently available executions: " } + executionsQueue.forEach { + logger.info { "${it.name} : waiting for : ${it.benchmark}" } + } + logger.info { "Currently available benchmarks: " } + benchmarks.forEach { + logger.info { it.key } + } sleep(2000) } catch (e: InterruptedException) { logger.error { "Execution interrupted with error: $e" } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index fd78a18a889d833447f4e459336171c7d45b2436..3d7718214e15488ad8c0d7c1cea7441474653571 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -12,8 +12,8 @@ import theodolite.util.Results import java.time.Duration class TheodoliteExecutor( - private var config: BenchmarkExecution, - private var kubernetesBenchmark: KubernetesBenchmark + private val config: BenchmarkExecution, + private val kubernetesBenchmark: KubernetesBenchmark ) { lateinit var executor: BenchmarkExecutor @@ -75,7 +75,7 @@ class TheodoliteExecutor( val config = buildConfig() // execute benchmarks for each load for (load in config.loads) { - if (executor.run) { + if (executor.run.get()) { config.compositeStrategy.findSuitableResource(load, config.resources) } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt index 88d9a978f23c8c5612d2ad46df795b7e3ba8cd19..6d6505192daac3331e5c99b9706ca7413e98ea7d 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/SchedulerNamePatcher.kt @@ -3,10 +3,10 @@ package theodolite.patcher import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.api.model.apps.Deployment -class SchedulerNamePatcher(private val k8sResource: KubernetesResource): Patcher { +class SchedulerNamePatcher(private val k8sResource: KubernetesResource) : Patcher { override fun <String> patch(value: String) { if (k8sResource is Deployment) { - k8sResource.spec.template.spec.schedulerName = value as kotlin.String; + k8sResource.spec.template.spec.schedulerName = value as kotlin.String } } } \ No newline at end of file