From 6c6281716ac5ee644b6abacf5164dc3e27687503 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 29 Jul 2022 17:04:06 +0200 Subject: fix(web/runner): Register all available trace formats This change updates the Quarkus extension to register all the available trace formats that are on the class path during processing time. Without this change, the OpenDC web runner is unable to load any of the available trace formats via Quarkus. --- .../build.gradle.kts | 1 + .../web/runner/deployment/OpenDCRunnerProcessor.java | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'opendc-web/opendc-web-runner-quarkus-deployment') diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts b/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts index 24f667cf..d31c4839 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts +++ b/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts @@ -29,6 +29,7 @@ plugins { dependencies { implementation(projects.opendcWeb.opendcWebRunnerQuarkus) + implementation(projects.opendcTrace.opendcTraceApi) implementation(platform(libs.quarkus.bom)) implementation(libs.quarkus.core.deployment) diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java index b9a334ac..1d01aabc 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java +++ b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java @@ -26,11 +26,17 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.*; +import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; +import io.quarkus.deployment.util.ServiceUtil; import io.quarkus.runtime.RuntimeValue; +import org.opendc.trace.spi.TraceFormat; import org.opendc.web.runner.OpenDCRunner; import org.opendc.web.runner.runtime.OpenDCRunnerRecorder; import org.opendc.web.runner.runtime.OpenDCRunnerRuntimeConfig; +import java.io.IOException; +import java.util.Collections; +import java.util.Set; import java.util.function.BooleanSupplier; import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; @@ -51,12 +57,18 @@ public class OpenDCRunnerProcessor { } /** - * Build step to index the necessary dependencies for the OpenDC runner. + * Build step to register the trace formats used by OpenDC. */ @BuildStep - void addDependencies(BuildProducer indexDependency) { - indexDependency.produce(new IndexDependencyBuildItem("org.opendc.trace", "opendc-trace-opendc")); - indexDependency.produce(new IndexDependencyBuildItem("org.opendc.trace", "opendc-trace-bitbrains")); + void registerTraceFormats(BuildProducer services) throws IOException { + String service = "META-INF/services/" + TraceFormat.class.getName(); + + Set implementations = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), + service); + + services.produce( + new ServiceProviderBuildItem(TraceFormat.class.getName(), + implementations.toArray(new String[0]))); } /** -- cgit v1.2.3 From 16439ea8db70fe7d531fde30914291a9707f32f0 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sat, 30 Jul 2022 12:37:13 +0200 Subject: feat(web/runner): Avoid REST layer if possible This change updates the Quarkus extension for the OpenDC runner to avoid the REST layer if possible, by providing an implementation of `JobManager` that directly communicates with the `JobService`. This means the runner does not have to traverse the authentication layer. --- .../opendc-web-runner-quarkus-deployment/build.gradle.kts | 1 + .../opendc/web/runner/deployment/OpenDCRunnerProcessor.java | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'opendc-web/opendc-web-runner-quarkus-deployment') diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts b/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts index d31c4839..b3f1ec3b 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts +++ b/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts @@ -33,4 +33,5 @@ dependencies { implementation(platform(libs.quarkus.bom)) implementation(libs.quarkus.core.deployment) + implementation(libs.quarkus.arc.deployment) } diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java index 1d01aabc..94921454 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java +++ b/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java @@ -22,6 +22,7 @@ package org.opendc.web.runner.deployment; +import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.Record; @@ -30,6 +31,7 @@ import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.util.ServiceUtil; import io.quarkus.runtime.RuntimeValue; import org.opendc.trace.spi.TraceFormat; +import org.opendc.web.runner.JobManager; import org.opendc.web.runner.OpenDCRunner; import org.opendc.web.runner.runtime.OpenDCRunnerRecorder; import org.opendc.web.runner.runtime.OpenDCRunnerRuntimeConfig; @@ -71,6 +73,14 @@ public class OpenDCRunnerProcessor { implementations.toArray(new String[0]))); } + /** + * Mark {@link JobManager} as unremoveable, since we look up this service dynamically in {@link OpenDCRunnerRecorder}. + */ + @BuildStep + UnremovableBeanBuildItem unremovableBeans() { + return UnremovableBeanBuildItem.beanTypes(JobManager.class); + } + /** * Build step to create the runner service. */ -- cgit v1.2.3