From f6932d264db5b2e185ec7ea7aaec84dfb83f8fe9 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sun, 31 Jul 2022 21:27:02 +0200 Subject: feat(web/runner): Automatically compute experiment parallelism This change updates the runner configuration to support specifying the parallelism as zero to let the runtime decide the appropriate number of threads based on the available CPU cores on the machine. --- .../org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'opendc-web/opendc-web-runner-quarkus/src') diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java index b243dbc3..c1f356bc 100644 --- a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java +++ b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java @@ -44,11 +44,19 @@ public class OpenDCRunnerRecorder { */ public RuntimeValue createRunner(OpenDCRunnerRuntimeConfig config) { URI apiUrl = URI.create(config.apiUrl); + + int parallelism = config.parallelism; + if (parallelism < 0) { + throw new IllegalArgumentException("Parallelism must be non-negative"); + } else if (parallelism == 0) { + parallelism = Math.min(1, Runtime.getRuntime().availableProcessors() - 1); + } + OpenDCRunnerClient client = new OpenDCRunnerClient(apiUrl, null); OpenDCRunner runner = new OpenDCRunner( client, new File(config.tracePath), - config.parallelism, + parallelism, config.jobTimeout, config.pollInterval, config.heartbeatInterval -- cgit v1.2.3 From a424aa5e81c31f8cc6ba8846f0a6af29623588d4 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 3 Aug 2022 11:11:58 +0200 Subject: refactor(web/runner): Support pluggable job manager This change introduces a new interface `JobManager` that is responsible for communicating with the backend about the available jobs and updating their status when the runner is simulating a job. This manager can be injected into the `OpenDCRunner` class and allows users to provide different sources for the jobs, not only the current REST API. --- .../java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'opendc-web/opendc-web-runner-quarkus/src') diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java index c1f356bc..eccc8dcf 100644 --- a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java +++ b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java @@ -27,6 +27,7 @@ import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; import org.jboss.logging.Logger; import org.opendc.web.client.runner.OpenDCRunnerClient; +import org.opendc.web.runner.JobManager; import org.opendc.web.runner.OpenDCRunner; import java.io.File; @@ -54,7 +55,7 @@ public class OpenDCRunnerRecorder { OpenDCRunnerClient client = new OpenDCRunnerClient(apiUrl, null); OpenDCRunner runner = new OpenDCRunner( - client, + JobManager.create(client), new File(config.tracePath), parallelism, config.jobTimeout, @@ -77,7 +78,7 @@ public class OpenDCRunnerRecorder { Thread thread = new Thread(() -> { try { // Wait for some time to allow Vert.x to bind to the local port - Thread.sleep(1000); + Thread.sleep(4000); } catch (InterruptedException e) { throw new RuntimeException(e); } -- 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. --- .../web/runner/runtime/OpenDCRunnerRecorder.java | 23 ++++++---------------- .../runner/runtime/OpenDCRunnerRuntimeConfig.java | 6 ------ 2 files changed, 6 insertions(+), 23 deletions(-) (limited to 'opendc-web/opendc-web-runner-quarkus/src') diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java index eccc8dcf..f5c056ef 100644 --- a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java +++ b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java @@ -26,12 +26,11 @@ import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; import org.jboss.logging.Logger; -import org.opendc.web.client.runner.OpenDCRunnerClient; import org.opendc.web.runner.JobManager; import org.opendc.web.runner.OpenDCRunner; +import javax.enterprise.inject.spi.CDI; import java.io.File; -import java.net.URI; /** * Helper class for starting the OpenDC web runner. @@ -44,8 +43,6 @@ public class OpenDCRunnerRecorder { * Helper method to create an {@link OpenDCRunner} instance. */ public RuntimeValue createRunner(OpenDCRunnerRuntimeConfig config) { - URI apiUrl = URI.create(config.apiUrl); - int parallelism = config.parallelism; if (parallelism < 0) { throw new IllegalArgumentException("Parallelism must be non-negative"); @@ -53,9 +50,9 @@ public class OpenDCRunnerRecorder { parallelism = Math.min(1, Runtime.getRuntime().availableProcessors() - 1); } - OpenDCRunnerClient client = new OpenDCRunnerClient(apiUrl, null); + JobManager manager = CDI.current().select(JobManager.class).get(); OpenDCRunner runner = new OpenDCRunner( - JobManager.create(client), + manager, new File(config.tracePath), parallelism, config.jobTimeout, @@ -73,18 +70,10 @@ public class OpenDCRunnerRecorder { OpenDCRunnerRuntimeConfig config, ShutdownContext shutdownContext) { if (config.enable) { - LOGGER.info("Starting OpenDC Runner in background (polling " + config.apiUrl + ")"); - - Thread thread = new Thread(() -> { - try { - // Wait for some time to allow Vert.x to bind to the local port - Thread.sleep(4000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + LOGGER.info("Starting OpenDC Runner in background (polling every " + config.pollInterval + ")"); - runner.getValue().run(); - }); + Thread thread = new Thread(runner.getValue()); + thread.setName("opendc-runner"); thread.start(); shutdownContext.addShutdownTask(thread::interrupt); diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRuntimeConfig.java b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRuntimeConfig.java index e1dbf0a8..e9258f06 100644 --- a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRuntimeConfig.java +++ b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRuntimeConfig.java @@ -39,12 +39,6 @@ public class OpenDCRunnerRuntimeConfig { @ConfigItem(defaultValue = "true") public boolean enable; - /** - * The URI to the (local) API to communicate with. - */ - @ConfigItem(defaultValue = "http://${quarkus.http.host}:${quarkus.http.port}${quarkus.resteasy.path:}") - public String apiUrl; - /** * The path where the workload traces are located. */ -- cgit v1.2.3