diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-08-03 14:42:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-03 14:42:49 +0200 |
| commit | 2692a032b8ecbe2ddccfb88628cf37af56c3ea36 (patch) | |
| tree | 5dde4331c0a10dd8e843c75cf68d2c7d3cd45906 /opendc-web/opendc-web-runner-quarkus | |
| parent | b023b085425c0d0f7952c2c331576b8d0fc8c857 (diff) | |
| parent | 87df18bb691260ee69d2e48cf1598e6a4acc329b (diff) | |
merge: Simplify OpenDC deployment process
This pull request attempts to simplify the deployment process necessary for
deploying OpenDC locally or using Docker. There was currently not a clear
and simple way to deploy OpenDC locally, yet the Docker-based deployment
was also out-of-sync.
## Implementation Notes :hammer_and_pick:
* Address several bugs in the OpenDC web runner
* Fix dependency related issues
* Rename `opendc-web-api` to `opendc-web-server`
* Create a local distribution of `opendc-web-server`.
* Fix Docker deployment
* Update deployment guide
## External Dependencies :four_leaf_clover:
* Quarkus 2.11.1
* `jandex-gradle-plugin` 0.13.2
## Breaking API Changes :warning:
* `TraceFormat.installedProviders` has been changed to `TraceFormat.getInstalledProviders`.
The list of installed providers is now not cached at first access, but queried every time the
method is invoked and its results depend on the caller context (e.g., context class loader).
* `OpenDCRunner` now requires a `JobManager` as constructor argument, which can be
constructed as follows: `JobManager.create(client)`
* `opendc-web-api` is now renamed to `opendc-web-server`.
Diffstat (limited to 'opendc-web/opendc-web-runner-quarkus')
2 files changed, 15 insertions, 23 deletions
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..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,11 +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. @@ -43,12 +43,18 @@ public class OpenDCRunnerRecorder { * Helper method to create an {@link OpenDCRunner} instance. */ public RuntimeValue<OpenDCRunner> createRunner(OpenDCRunnerRuntimeConfig config) { - URI apiUrl = URI.create(config.apiUrl); - OpenDCRunnerClient client = new OpenDCRunnerClient(apiUrl, null); + 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); + } + + JobManager manager = CDI.current().select(JobManager.class).get(); OpenDCRunner runner = new OpenDCRunner( - client, + manager, new File(config.tracePath), - config.parallelism, + parallelism, config.jobTimeout, config.pollInterval, config.heartbeatInterval @@ -64,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(1000); - } 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 @@ -40,12 +40,6 @@ public class OpenDCRunnerRuntimeConfig { 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. */ @ConfigItem(defaultValue = "traces") |
