From 00a28ee84606754d186c39e9aa39d2ad2c277c91 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 11:11:32 +0200 Subject: build: Update next version to 3.0 This change updates the build script in preparation for the OpenDC v3.0 release changing the version numbers to the appropriate values. --- opendc-web/opendc-web-ui/package-lock.json | 4 ++-- opendc-web/opendc-web-ui/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'opendc-web') diff --git a/opendc-web/opendc-web-ui/package-lock.json b/opendc-web/opendc-web-ui/package-lock.json index a38802de..4790dcb9 100644 --- a/opendc-web/opendc-web-ui/package-lock.json +++ b/opendc-web/opendc-web-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "opendc-frontend", - "version": "2.1.0", + "version": "3.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "opendc-frontend", - "version": "2.1.0", + "version": "3.0.0", "license": "MIT", "dependencies": { "@auth0/auth0-react": "^1.11.0", diff --git a/opendc-web/opendc-web-ui/package.json b/opendc-web/opendc-web-ui/package.json index a4cac1be..f2175e35 100644 --- a/opendc-web/opendc-web-ui/package.json +++ b/opendc-web/opendc-web-ui/package.json @@ -1,6 +1,6 @@ { "name": "opendc-frontend", - "version": "2.1.0", + "version": "3.0.0", "description": "The user-facing component of the OpenDC stack, allowing users to build and interact with their own (virtual) datacenters.", "keywords": [ "opendc", -- cgit v1.2.3 From 402a8f55342c4565431c2a2e7287a70592f3fe33 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 12:51:27 +0200 Subject: style: Eliminate use of wildcard imports This change updates the repository to remove the use of wildcard imports everywhere. Wildcard imports are not allowed by default by Ktlint as well as Google's Java style guide. --- .../kotlin/org/opendc/web/client/ProjectResource.kt | 4 +++- .../kotlin/org/opendc/web/client/TraceResource.kt | 2 +- .../org/opendc/web/client/runner/JobResource.kt | 3 ++- .../opendc/web/client/runner/OpenDCRunnerClient.kt | 3 ++- .../kotlin/org/opendc/web/proto/runner/Scenario.kt | 3 ++- .../kotlin/org/opendc/web/proto/runner/Topology.kt | 2 +- .../src/cli/kotlin/org/opendc/web/runner/Main.kt | 6 +++++- .../kotlin/org/opendc/web/runner/OpenDCRunner.kt | 21 ++++++++++++++++++--- .../main/kotlin/org/opendc/web/server/model/Job.kt | 12 +++++++++++- .../kotlin/org/opendc/web/server/model/Portfolio.kt | 16 +++++++++++++++- .../kotlin/org/opendc/web/server/model/Project.kt | 12 +++++++++++- .../opendc/web/server/model/ProjectAuthorization.kt | 8 +++++++- .../kotlin/org/opendc/web/server/model/Scenario.kt | 16 +++++++++++++++- .../kotlin/org/opendc/web/server/model/Topology.kt | 13 ++++++++++++- .../kotlin/org/opendc/web/server/model/Trace.kt | 7 ++++++- .../org/opendc/web/server/rest/TraceResource.kt | 5 ++++- .../opendc/web/server/rest/runner/JobResource.kt | 6 +++++- .../web/server/rest/user/PortfolioResource.kt | 7 ++++++- .../server/rest/user/PortfolioScenarioResource.kt | 6 +++++- .../opendc/web/server/rest/user/ProjectResource.kt | 7 ++++++- .../opendc/web/server/rest/user/ScenarioResource.kt | 6 +++++- .../opendc/web/server/rest/user/TopologyResource.kt | 8 +++++++- .../opendc/web/server/service/PortfolioService.kt | 1 - .../org/opendc/web/server/service/ProjectService.kt | 14 ++++++++------ .../opendc/web/server/service/ScenarioService.kt | 20 +++++++++++++------- .../opendc/web/server/service/UserConversions.kt | 8 +++++++- .../hibernate/json/JsonBytesSqlTypeDescriptor.kt | 5 ++++- .../util/hibernate/json/JsonSqlTypeDescriptor.kt | 5 ++++- .../hibernate/json/JsonStringSqlTypeDescriptor.kt | 5 ++++- .../web/server/util/hibernate/json/JsonType.kt | 2 +- .../util/hibernate/json/JsonTypeDescriptor.kt | 3 ++- .../web/server/rest/runner/JobResourceTest.kt | 5 ++++- .../rest/user/PortfolioScenarioResourceTest.kt | 13 +++++++++++-- .../web/server/rest/user/ScenarioResourceTest.kt | 13 +++++++++++-- 34 files changed, 218 insertions(+), 49 deletions(-) (limited to 'opendc-web') diff --git a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/ProjectResource.kt b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/ProjectResource.kt index 12635b89..579d0d66 100644 --- a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/ProjectResource.kt +++ b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/ProjectResource.kt @@ -22,7 +22,9 @@ package org.opendc.web.client -import org.opendc.web.client.internal.* +import org.opendc.web.client.internal.delete +import org.opendc.web.client.internal.get +import org.opendc.web.client.internal.post import org.opendc.web.client.transport.TransportClient import org.opendc.web.proto.user.Project diff --git a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/TraceResource.kt b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/TraceResource.kt index 8201c432..b4a8c089 100644 --- a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/TraceResource.kt +++ b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/TraceResource.kt @@ -22,7 +22,7 @@ package org.opendc.web.client -import org.opendc.web.client.internal.* +import org.opendc.web.client.internal.get import org.opendc.web.client.transport.TransportClient import org.opendc.web.proto.Trace diff --git a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/JobResource.kt b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/JobResource.kt index 372a92d7..ad3f1c9b 100644 --- a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/JobResource.kt +++ b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/JobResource.kt @@ -22,7 +22,8 @@ package org.opendc.web.client.runner -import org.opendc.web.client.internal.* +import org.opendc.web.client.internal.get +import org.opendc.web.client.internal.post import org.opendc.web.client.transport.TransportClient import org.opendc.web.proto.runner.Job diff --git a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/OpenDCRunnerClient.kt b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/OpenDCRunnerClient.kt index e2112b8c..98785a55 100644 --- a/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/OpenDCRunnerClient.kt +++ b/opendc-web/opendc-web-client/src/main/kotlin/org/opendc/web/client/runner/OpenDCRunnerClient.kt @@ -22,7 +22,8 @@ package org.opendc.web.client.runner -import org.opendc.web.client.* +import org.opendc.web.client.SchedulerResource +import org.opendc.web.client.TraceResource import org.opendc.web.client.auth.AuthController import org.opendc.web.client.transport.HttpTransportClient import org.opendc.web.client.transport.TransportClient diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt index c5e609ec..aeffc4d7 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt @@ -23,7 +23,8 @@ package org.opendc.web.proto.runner import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.* +import org.opendc.web.proto.OperationalPhenomena +import org.opendc.web.proto.Workload /** * A [Scenario] that is exposed to an OpenDC runner. diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt index ea576e71..4bffdee9 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt @@ -23,7 +23,7 @@ package org.opendc.web.proto.runner import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.* +import org.opendc.web.proto.Room import java.time.Instant /** diff --git a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt index 4cfbdd7c..56fecf78 100644 --- a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt +++ b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt @@ -23,7 +23,11 @@ package org.opendc.web.runner import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.* +import com.github.ajalt.clikt.parameters.options.convert +import com.github.ajalt.clikt.parameters.options.default +import com.github.ajalt.clikt.parameters.options.defaultLazy +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.options.required import com.github.ajalt.clikt.parameters.types.file import com.github.ajalt.clikt.parameters.types.int import mu.KotlinLogging diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt index d340d31c..b0f99084 100644 --- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt +++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt @@ -24,8 +24,16 @@ package org.opendc.web.runner import mu.KotlinLogging import org.opendc.compute.service.ComputeService -import org.opendc.experiments.compute.* +import org.opendc.experiments.compute.ComputeWorkloadLoader +import org.opendc.experiments.compute.createComputeScheduler +import org.opendc.experiments.compute.grid5000 +import org.opendc.experiments.compute.registerComputeMonitor +import org.opendc.experiments.compute.replay +import org.opendc.experiments.compute.sampleByLoad +import org.opendc.experiments.compute.setupComputeService +import org.opendc.experiments.compute.setupHosts import org.opendc.experiments.compute.topology.HostSpec +import org.opendc.experiments.compute.trace import org.opendc.experiments.provisioner.Provisioner import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.model.MemoryUnit @@ -40,9 +48,16 @@ import org.opendc.web.proto.runner.Topology import org.opendc.web.runner.internal.WebComputeMonitor import java.io.File import java.time.Duration -import java.util.* -import java.util.concurrent.* +import java.util.Random +import java.util.UUID +import java.util.concurrent.Executors +import java.util.concurrent.ForkJoinPool import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory +import java.util.concurrent.ForkJoinWorkerThread +import java.util.concurrent.RecursiveAction +import java.util.concurrent.RecursiveTask +import java.util.concurrent.ScheduledExecutorService +import java.util.concurrent.TimeUnit /** * Class to execute the pending jobs via the OpenDC web API. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Job.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Job.kt index 024e7b89..c07e07f0 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Job.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Job.kt @@ -27,7 +27,17 @@ import org.hibernate.annotations.TypeDef import org.opendc.web.proto.JobState import org.opendc.web.server.util.hibernate.json.JsonType import java.time.Instant -import javax.persistence.* +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.FetchType +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.JoinColumn +import javax.persistence.NamedQueries +import javax.persistence.NamedQuery +import javax.persistence.OneToOne +import javax.persistence.Table /** * A simulation job to be run by the simulator. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt index 3e3f76a0..5b686d5f 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt @@ -26,7 +26,21 @@ import org.hibernate.annotations.Type import org.hibernate.annotations.TypeDef import org.opendc.web.proto.Targets import org.opendc.web.server.util.hibernate.json.JsonType -import javax.persistence.* +import javax.persistence.CascadeType +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.Index +import javax.persistence.JoinColumn +import javax.persistence.ManyToOne +import javax.persistence.NamedQueries +import javax.persistence.NamedQuery +import javax.persistence.OneToMany +import javax.persistence.OrderBy +import javax.persistence.Table +import javax.persistence.UniqueConstraint /** * A portfolio is the composition of multiple scenarios. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt index aa98b677..5eb925ea 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt @@ -23,7 +23,17 @@ package org.opendc.web.server.model import java.time.Instant -import javax.persistence.* +import javax.persistence.CascadeType +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.NamedQueries +import javax.persistence.NamedQuery +import javax.persistence.OneToMany +import javax.persistence.OrderBy +import javax.persistence.Table /** * A project in OpenDC encapsulates all the datacenter designs and simulation runs for a set of users. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/ProjectAuthorization.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/ProjectAuthorization.kt index a353186e..791725cd 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/ProjectAuthorization.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/ProjectAuthorization.kt @@ -23,7 +23,13 @@ package org.opendc.web.server.model import org.opendc.web.proto.user.ProjectRole -import javax.persistence.* +import javax.persistence.Column +import javax.persistence.EmbeddedId +import javax.persistence.Entity +import javax.persistence.JoinColumn +import javax.persistence.ManyToOne +import javax.persistence.MapsId +import javax.persistence.Table /** * An authorization for some user to participate in a project. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt index e40cff47..a7258e7b 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt @@ -26,7 +26,21 @@ import org.hibernate.annotations.Type import org.hibernate.annotations.TypeDef import org.opendc.web.proto.OperationalPhenomena import org.opendc.web.server.util.hibernate.json.JsonType -import javax.persistence.* +import javax.persistence.CascadeType +import javax.persistence.Column +import javax.persistence.Embedded +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.Index +import javax.persistence.JoinColumn +import javax.persistence.ManyToOne +import javax.persistence.NamedQueries +import javax.persistence.NamedQuery +import javax.persistence.OneToOne +import javax.persistence.Table +import javax.persistence.UniqueConstraint /** * A single scenario to be explored by the simulator. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Topology.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Topology.kt index a190b1ee..26368455 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Topology.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Topology.kt @@ -27,7 +27,18 @@ import org.hibernate.annotations.TypeDef import org.opendc.web.proto.Room import org.opendc.web.server.util.hibernate.json.JsonType import java.time.Instant -import javax.persistence.* +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.Index +import javax.persistence.JoinColumn +import javax.persistence.ManyToOne +import javax.persistence.NamedQueries +import javax.persistence.NamedQuery +import javax.persistence.Table +import javax.persistence.UniqueConstraint /** * A datacenter design in OpenDC. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt index 8aaac613..0fc79ca8 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt @@ -22,7 +22,12 @@ package org.opendc.web.server.model -import javax.persistence.* +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.Id +import javax.persistence.NamedQueries +import javax.persistence.NamedQuery +import javax.persistence.Table /** * A workload trace available for simulation. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/TraceResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/TraceResource.kt index f46f7f91..a33bd8f1 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/TraceResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/TraceResource.kt @@ -25,7 +25,10 @@ package org.opendc.web.server.rest import org.opendc.web.proto.Trace import org.opendc.web.server.service.TraceService import javax.inject.Inject -import javax.ws.rs.* +import javax.ws.rs.GET +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.WebApplicationException /** * A resource representing the workload traces available in the OpenDC instance. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/runner/JobResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/runner/JobResource.kt index 351a2237..4aa2f6a1 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/runner/JobResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/runner/JobResource.kt @@ -28,7 +28,11 @@ import javax.annotation.security.RolesAllowed import javax.inject.Inject import javax.transaction.Transactional import javax.validation.Valid -import javax.ws.rs.* +import javax.ws.rs.GET +import javax.ws.rs.POST +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.WebApplicationException /** * A resource representing the available simulation jobs. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt index 2a9d6f1b..da565fe4 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt @@ -29,7 +29,12 @@ import javax.annotation.security.RolesAllowed import javax.inject.Inject import javax.transaction.Transactional import javax.validation.Valid -import javax.ws.rs.* +import javax.ws.rs.DELETE +import javax.ws.rs.GET +import javax.ws.rs.POST +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.WebApplicationException /** * A resource representing the portfolios of a project. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt index f2372bde..515f6be6 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt @@ -29,7 +29,11 @@ import javax.annotation.security.RolesAllowed import javax.inject.Inject import javax.transaction.Transactional import javax.validation.Valid -import javax.ws.rs.* +import javax.ws.rs.GET +import javax.ws.rs.POST +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.WebApplicationException /** * A resource representing the scenarios of a portfolio. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ProjectResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ProjectResource.kt index f3d96f55..817f53a5 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ProjectResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ProjectResource.kt @@ -29,7 +29,12 @@ import javax.annotation.security.RolesAllowed import javax.inject.Inject import javax.transaction.Transactional import javax.validation.Valid -import javax.ws.rs.* +import javax.ws.rs.DELETE +import javax.ws.rs.GET +import javax.ws.rs.POST +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.WebApplicationException /** * A resource representing the created projects. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ScenarioResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ScenarioResource.kt index 24cdcb6a..56bb4290 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ScenarioResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/ScenarioResource.kt @@ -28,7 +28,11 @@ import org.opendc.web.server.service.ScenarioService import javax.annotation.security.RolesAllowed import javax.inject.Inject import javax.transaction.Transactional -import javax.ws.rs.* +import javax.ws.rs.DELETE +import javax.ws.rs.GET +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.WebApplicationException /** * A resource representing the scenarios of a portfolio. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/TopologyResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/TopologyResource.kt index 40b3741c..8eef66c8 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/TopologyResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/TopologyResource.kt @@ -29,7 +29,13 @@ import javax.annotation.security.RolesAllowed import javax.inject.Inject import javax.transaction.Transactional import javax.validation.Valid -import javax.ws.rs.* +import javax.ws.rs.DELETE +import javax.ws.rs.GET +import javax.ws.rs.POST +import javax.ws.rs.PUT +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.WebApplicationException /** * A resource representing the constructed datacenter topologies. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/PortfolioService.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/PortfolioService.kt index 0d380190..c83b7a54 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/PortfolioService.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/PortfolioService.kt @@ -23,7 +23,6 @@ package org.opendc.web.server.service import org.opendc.web.proto.user.Portfolio -import org.opendc.web.server.model.* import org.opendc.web.server.repository.PortfolioRepository import org.opendc.web.server.repository.ProjectRepository import java.time.Instant diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ProjectService.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ProjectService.kt index 44348195..2fc5a054 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ProjectService.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ProjectService.kt @@ -22,13 +22,15 @@ package org.opendc.web.server.service -import org.opendc.web.proto.user.Project import org.opendc.web.proto.user.ProjectRole -import org.opendc.web.server.model.* +import org.opendc.web.server.model.Project +import org.opendc.web.server.model.ProjectAuthorization +import org.opendc.web.server.model.ProjectAuthorizationKey import org.opendc.web.server.repository.ProjectRepository import java.time.Instant import javax.enterprise.context.ApplicationScoped import javax.inject.Inject +import org.opendc.web.proto.user.Project as ProjectDto /** * Service for managing [Project]s. @@ -38,21 +40,21 @@ class ProjectService @Inject constructor(private val repository: ProjectReposito /** * List all projects for the user with the specified [userId]. */ - fun findWithUser(userId: String): List { + fun findWithUser(userId: String): List { return repository.findAll(userId).map { it.toUserDto() } } /** * Obtain the project with the specified [id] for the user with the specified [userId]. */ - fun findWithUser(userId: String, id: Long): Project? { + fun findWithUser(userId: String, id: Long): ProjectDto? { return repository.findOne(userId, id)?.toUserDto() } /** * Create a new [Project] for the user with the specified [userId]. */ - fun createForUser(userId: String, name: String): Project { + fun createForUser(userId: String, name: String): ProjectDto { val now = Instant.now() val entity = Project(0, name, now) repository.save(entity) @@ -71,7 +73,7 @@ class ProjectService @Inject constructor(private val repository: ProjectReposito * @param userId The user that invokes the action. * @param id The identifier of the project. */ - fun deleteWithUser(userId: String, id: Long): Project? { + fun deleteWithUser(userId: String, id: Long): ProjectDto? { val auth = repository.findOne(userId, id) ?: return null if (!auth.role.canDelete) { diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt index 5b56068d..1929f44b 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt @@ -22,12 +22,18 @@ package org.opendc.web.server.service -import org.opendc.web.proto.user.Scenario -import org.opendc.web.server.model.* -import org.opendc.web.server.repository.* +import org.opendc.web.server.model.Job +import org.opendc.web.server.model.Scenario +import org.opendc.web.server.model.Workload +import org.opendc.web.server.repository.PortfolioRepository +import org.opendc.web.server.repository.ProjectRepository +import org.opendc.web.server.repository.ScenarioRepository +import org.opendc.web.server.repository.TopologyRepository +import org.opendc.web.server.repository.TraceRepository import java.time.Instant import javax.enterprise.context.ApplicationScoped import javax.inject.Inject +import org.opendc.web.proto.user.Scenario as ScenarioDto /** * Service for managing [Scenario]s. @@ -43,7 +49,7 @@ class ScenarioService @Inject constructor( /** * List all [Scenario]s that belong a certain portfolio. */ - fun findAll(userId: String, projectId: Long, number: Int): List { + fun findAll(userId: String, projectId: Long, number: Int): List { // User must have access to project val auth = projectRepository.findOne(userId, projectId) ?: return emptyList() val project = auth.toUserDto() @@ -53,7 +59,7 @@ class ScenarioService @Inject constructor( /** * Obtain a [Scenario] by identifier. */ - fun findOne(userId: String, projectId: Long, number: Int): Scenario? { + fun findOne(userId: String, projectId: Long, number: Int): ScenarioDto? { // User must have access to project val auth = projectRepository.findOne(userId, projectId) ?: return null val project = auth.toUserDto() @@ -63,7 +69,7 @@ class ScenarioService @Inject constructor( /** * Delete the specified scenario. */ - fun delete(userId: String, projectId: Long, number: Int): Scenario? { + fun delete(userId: String, projectId: Long, number: Int): ScenarioDto? { // User must have access to project val auth = projectRepository.findOne(userId, projectId) @@ -82,7 +88,7 @@ class ScenarioService @Inject constructor( /** * Construct a new [Scenario] with the specified data. */ - fun create(userId: String, projectId: Long, portfolioNumber: Int, request: Scenario.Create): Scenario? { + fun create(userId: String, projectId: Long, portfolioNumber: Int, request: ScenarioDto.Create): ScenarioDto? { // User must have access to project val auth = projectRepository.findOne(userId, projectId) diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/UserConversions.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/UserConversions.kt index ee78d103..e28d9c0f 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/UserConversions.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/UserConversions.kt @@ -23,7 +23,13 @@ package org.opendc.web.server.service import org.opendc.web.proto.user.Project -import org.opendc.web.server.model.* +import org.opendc.web.server.model.Job +import org.opendc.web.server.model.Portfolio +import org.opendc.web.server.model.ProjectAuthorization +import org.opendc.web.server.model.Scenario +import org.opendc.web.server.model.Topology +import org.opendc.web.server.model.Trace +import org.opendc.web.server.model.Workload /** * Conversions into DTOs provided to users. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt index 216c465f..cc8dad48 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt @@ -27,7 +27,10 @@ import org.hibernate.type.descriptor.WrapperOptions import org.hibernate.type.descriptor.java.JavaTypeDescriptor import org.hibernate.type.descriptor.sql.BasicBinder import java.io.UnsupportedEncodingException -import java.sql.* +import java.sql.CallableStatement +import java.sql.PreparedStatement +import java.sql.ResultSet +import java.sql.Types /** * A [AbstractJsonSqlTypeDescriptor] that stores the JSON as UTF-8 encoded bytes. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonSqlTypeDescriptor.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonSqlTypeDescriptor.kt index f5069c4c..bd22ffbe 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonSqlTypeDescriptor.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonSqlTypeDescriptor.kt @@ -32,7 +32,10 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor import org.hibernate.type.descriptor.sql.BasicBinder import org.hibernate.type.descriptor.sql.BasicExtractor import org.hibernate.type.descriptor.sql.SqlTypeDescriptor -import java.sql.* +import java.sql.CallableStatement +import java.sql.PreparedStatement +import java.sql.ResultSet +import java.sql.Types /** * A [SqlTypeDescriptor] that automatically selects the correct implementation for the database dialect. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt index 3d10cb0e..63f32849 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt @@ -4,7 +4,10 @@ import org.hibernate.type.descriptor.ValueBinder import org.hibernate.type.descriptor.WrapperOptions import org.hibernate.type.descriptor.java.JavaTypeDescriptor import org.hibernate.type.descriptor.sql.BasicBinder -import java.sql.* +import java.sql.CallableStatement +import java.sql.PreparedStatement +import java.sql.ResultSet +import java.sql.Types /** * A [AbstractJsonSqlTypeDescriptor] that stores the JSON as string (VARCHAR). diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonType.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonType.kt index 98663640..9ee21a4c 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonType.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonType.kt @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.hibernate.type.AbstractSingleColumnStandardBasicType import org.hibernate.type.BasicType import org.hibernate.usertype.DynamicParameterizedType -import java.util.* +import java.util.Properties import javax.enterprise.inject.spi.CDI /** diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonTypeDescriptor.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonTypeDescriptor.kt index 6c6078dd..9407f940 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonTypeDescriptor.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonTypeDescriptor.kt @@ -40,7 +40,8 @@ import java.io.InputStream import java.lang.reflect.Type import java.sql.Blob import java.sql.SQLException -import java.util.* +import java.util.Objects +import java.util.Properties /** * An [AbstractTypeDescriptor] implementation for Hibernate JSON type. diff --git a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt index c96788b0..71aaa8a4 100644 --- a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt +++ b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt @@ -35,8 +35,11 @@ import io.restassured.module.kotlin.extensions.When import org.hamcrest.Matchers.equalTo import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.opendc.web.proto.* +import org.opendc.web.proto.JobState +import org.opendc.web.proto.OperationalPhenomena import org.opendc.web.proto.Targets +import org.opendc.web.proto.Trace +import org.opendc.web.proto.Workload import org.opendc.web.proto.runner.Job import org.opendc.web.proto.runner.Portfolio import org.opendc.web.proto.runner.Scenario diff --git a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResourceTest.kt b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResourceTest.kt index 13c47d19..676a43dc 100644 --- a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResourceTest.kt +++ b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResourceTest.kt @@ -35,8 +35,17 @@ import io.restassured.module.kotlin.extensions.When import org.hamcrest.Matchers import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.opendc.web.proto.* -import org.opendc.web.proto.user.* +import org.opendc.web.proto.JobState +import org.opendc.web.proto.OperationalPhenomena +import org.opendc.web.proto.Targets +import org.opendc.web.proto.Trace +import org.opendc.web.proto.Workload +import org.opendc.web.proto.user.Job +import org.opendc.web.proto.user.Portfolio +import org.opendc.web.proto.user.Project +import org.opendc.web.proto.user.ProjectRole +import org.opendc.web.proto.user.Scenario +import org.opendc.web.proto.user.Topology import org.opendc.web.server.service.ScenarioService import java.time.Instant diff --git a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/ScenarioResourceTest.kt b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/ScenarioResourceTest.kt index 1d63679e..2e080971 100644 --- a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/ScenarioResourceTest.kt +++ b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/user/ScenarioResourceTest.kt @@ -35,8 +35,17 @@ import io.restassured.module.kotlin.extensions.When import org.hamcrest.Matchers import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import org.opendc.web.proto.* -import org.opendc.web.proto.user.* +import org.opendc.web.proto.JobState +import org.opendc.web.proto.OperationalPhenomena +import org.opendc.web.proto.Targets +import org.opendc.web.proto.Trace +import org.opendc.web.proto.Workload +import org.opendc.web.proto.user.Job +import org.opendc.web.proto.user.Portfolio +import org.opendc.web.proto.user.Project +import org.opendc.web.proto.user.ProjectRole +import org.opendc.web.proto.user.Scenario +import org.opendc.web.proto.user.Topology import org.opendc.web.server.service.ScenarioService import java.time.Instant -- cgit v1.2.3 From 47357afd16f928260db34d4dd3e686fb9ee7c5ff Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 6 Oct 2022 13:13:10 +0200 Subject: build: Switch to Spotless for formatting This change updates the build configuration to use Spotless for code formating of both Kotlin and Java. --- .../src/main/kotlin/org/opendc/web/proto/Room.kt | 2 +- .../main/kotlin/org/opendc/web/proto/RoomTile.kt | 2 +- .../src/main/kotlin/org/opendc/web/proto/Trace.kt | 2 +- .../org/opendc/web/proto/runner/Portfolio.kt | 2 +- .../kotlin/org/opendc/web/proto/runner/Topology.kt | 2 +- .../kotlin/org/opendc/web/proto/user/Portfolio.kt | 2 +- .../org/opendc/web/proto/user/ProjectRole.kt | 2 +- .../kotlin/org/opendc/web/proto/user/Scenario.kt | 2 +- .../kotlin/org/opendc/web/proto/user/Topology.kt | 4 +- .../runner/deployment/OpenDCRunnerProcessor.java | 39 ++++--- .../web/runner/runtime/OpenDCRunnerRecorder.java | 23 ++--- .../runner/runtime/OpenDCRunnerRuntimeConfig.java | 1 - .../src/cli/kotlin/org/opendc/web/runner/Main.kt | 2 +- .../kotlin/org/opendc/web/runner/OpenDCRunner.kt | 7 +- .../web/runner/internal/WebComputeMonitor.kt | 6 +- .../org/opendc/web/server/model/Portfolio.kt | 2 +- .../kotlin/org/opendc/web/server/model/Project.kt | 2 +- .../kotlin/org/opendc/web/server/model/Scenario.kt | 2 +- .../kotlin/org/opendc/web/server/model/Trace.kt | 4 +- .../web/server/rest/user/PortfolioResource.kt | 2 +- .../server/rest/user/PortfolioScenarioResource.kt | 2 +- .../opendc/web/server/service/ScenarioService.kt | 2 +- .../hibernate/json/JsonBinarySqlTypeDescriptor.kt | 22 ++++ .../hibernate/json/JsonBytesSqlTypeDescriptor.kt | 10 +- .../hibernate/json/JsonStringSqlTypeDescriptor.kt | 22 ++++ .../web/server/rest/runner/JobResourceTest.kt | 2 +- .../web/ui/deployment/AuthConfiguration.java | 1 - .../opendc/web/ui/deployment/OpenDCUiConfig.java | 1 - .../web/ui/deployment/OpenDCUiProcessor.java | 115 +++++++++++---------- .../ui/deployment/OpenDCUiRoutingBuildItem.java | 3 +- .../opendc/web/ui/runtime/OpenDCUiRecorder.java | 43 +++----- opendc-web/opendc-web-ui/build.gradle.kts | 4 +- 32 files changed, 184 insertions(+), 153 deletions(-) (limited to 'opendc-web') diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt index 5b305168..c5499150 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt @@ -29,5 +29,5 @@ public data class Room( val id: String, val name: String, val tiles: Set, - val topologyId: String? = null, + val topologyId: String? = null ) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt index 666d66ee..53cb53cd 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt @@ -30,5 +30,5 @@ public data class RoomTile( val positionX: Double, val positionY: Double, val rack: Rack? = null, - val roomId: String? = null, + val roomId: String? = null ) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt index 2952a273..1c086cd8 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt @@ -32,5 +32,5 @@ package org.opendc.web.proto public data class Trace( val id: String, val name: String, - val type: String, + val type: String ) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt index 916d8cf0..5faad5b3 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt @@ -39,5 +39,5 @@ public data class Portfolio( val id: Long, val number: Int, val name: String, - val targets: Targets, + val targets: Targets ) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt index 4bffdee9..bc185aea 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt @@ -36,5 +36,5 @@ public data class Topology( val name: String, val rooms: List, val createdAt: Instant, - val updatedAt: Instant, + val updatedAt: Instant ) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt index 6f468e79..99d0f65e 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt @@ -67,6 +67,6 @@ public data class Portfolio( val id: Long, val number: Int, val name: String, - val targets: Targets, + val targets: Targets ) } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt index 0f6de1fc..ea6a30ab 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt @@ -39,5 +39,5 @@ public enum class ProjectRole { /** * The user owns the project (so he can delete it). */ - OWNER, + OWNER } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt index 552a4912..ed77ef08 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt @@ -58,7 +58,7 @@ public data class Scenario( val workload: Workload.Spec, val topology: Long, val phenomena: OperationalPhenomena, - val schedulerName: String, + val schedulerName: String ) /** diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt index a144a2e6..73748bb9 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt +++ b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt @@ -37,7 +37,7 @@ public data class Topology( val name: String, val rooms: List, val createdAt: Instant, - val updatedAt: Instant, + val updatedAt: Instant ) { /** * Create a new topology for a project. @@ -70,6 +70,6 @@ public data class Topology( val number: Int, val name: String, val createdAt: Instant, - val updatedAt: Instant, + val updatedAt: Instant ) } 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 94921454..85a973e7 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,8 @@ package org.opendc.web.runner.deployment; +import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; + import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -30,19 +32,15 @@ import io.quarkus.deployment.builditem.*; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.util.ServiceUtil; import io.quarkus.runtime.RuntimeValue; +import java.io.IOException; +import java.util.Set; +import java.util.function.BooleanSupplier; 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; -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; - /** * Build processor for the OpenDC web runner Quarkus extension. */ @@ -65,12 +63,11 @@ public class OpenDCRunnerProcessor { void registerTraceFormats(BuildProducer services) throws IOException { String service = "META-INF/services/" + TraceFormat.class.getName(); - Set implementations = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), - service); + Set implementations = + ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), service); services.produce( - new ServiceProviderBuildItem(TraceFormat.class.getName(), - implementations.toArray(new String[0]))); + new ServiceProviderBuildItem(TraceFormat.class.getName(), implementations.toArray(new String[0]))); } /** @@ -86,9 +83,10 @@ public class OpenDCRunnerProcessor { */ @BuildStep(onlyIf = IsIncluded.class) @Record(RUNTIME_INIT) - ServiceStartBuildItem createRunnerService(OpenDCRunnerRecorder recorder, - OpenDCRunnerRuntimeConfig config, - BuildProducer runnerBuildItem) { + ServiceStartBuildItem createRunnerService( + OpenDCRunnerRecorder recorder, + OpenDCRunnerRuntimeConfig config, + BuildProducer runnerBuildItem) { RuntimeValue runner = recorder.createRunner(config); runnerBuildItem.produce(new OpenDCRunnerBuildItem(runner)); return new ServiceStartBuildItem("OpenDCRunnerService"); @@ -99,12 +97,13 @@ public class OpenDCRunnerProcessor { */ @BuildStep(onlyIf = IsIncluded.class) @Record(RUNTIME_INIT) - void startRunnerService(ApplicationStartBuildItem start, - OpenDCRunnerBuildItem runnerBuildItem, - OpenDCRunnerRecorder recorder, - OpenDCRunnerRuntimeConfig config, - ShutdownContextBuildItem shutdownContextBuildItem) { - recorder.startRunner(runnerBuildItem.getRunner(), config,shutdownContextBuildItem); + void startRunnerService( + ApplicationStartBuildItem start, + OpenDCRunnerBuildItem runnerBuildItem, + OpenDCRunnerRecorder recorder, + OpenDCRunnerRuntimeConfig config, + ShutdownContextBuildItem shutdownContextBuildItem) { + recorder.startRunner(runnerBuildItem.getRunner(), config, shutdownContextBuildItem); } /** 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 f5c056ef..76f2368f 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 @@ -25,13 +25,12 @@ package org.opendc.web.runner.runtime; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; +import java.io.File; +import javax.enterprise.inject.spi.CDI; import org.jboss.logging.Logger; import org.opendc.web.runner.JobManager; import org.opendc.web.runner.OpenDCRunner; -import javax.enterprise.inject.spi.CDI; -import java.io.File; - /** * Helper class for starting the OpenDC web runner. */ @@ -52,13 +51,12 @@ public class OpenDCRunnerRecorder { JobManager manager = CDI.current().select(JobManager.class).get(); OpenDCRunner runner = new OpenDCRunner( - manager, - new File(config.tracePath), - parallelism, - config.jobTimeout, - config.pollInterval, - config.heartbeatInterval - ); + manager, + new File(config.tracePath), + parallelism, + config.jobTimeout, + config.pollInterval, + config.heartbeatInterval); return new RuntimeValue<>(runner); } @@ -66,9 +64,8 @@ public class OpenDCRunnerRecorder { /** * Helper method to start the OpenDC runner service. */ - public void startRunner(RuntimeValue runner, - OpenDCRunnerRuntimeConfig config, - ShutdownContext shutdownContext) { + public void startRunner( + RuntimeValue runner, OpenDCRunnerRuntimeConfig config, ShutdownContext shutdownContext) { if (config.enable) { LOGGER.info("Starting OpenDC Runner in background (polling every " + config.pollInterval + ")"); 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 e9258f06..61c07e48 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 @@ -25,7 +25,6 @@ package org.opendc.web.runner.runtime; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; - import java.time.Duration; /** diff --git a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt index 56fecf78..299c4d09 100644 --- a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt +++ b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt @@ -109,7 +109,7 @@ class RunnerCli : CliktCommand(name = "opendc-runner") { */ private val parallelism by option( "--parallelism", - help = "maximum number of threads for simulations", + help = "maximum number of threads for simulations" ) .int() .default(Runtime.getRuntime().availableProcessors() - 1) diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt index b0f99084..226bad47 100644 --- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt +++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt @@ -215,7 +215,7 @@ public class OpenDCRunner( private inner class SimulationTask( private val scenario: Scenario, private val repeat: Int, - private val topology: List, + private val topology: List ) : RecursiveTask() { override fun compute(): WebComputeMonitor.Results { val monitor = WebComputeMonitor() @@ -261,10 +261,11 @@ public class OpenDCRunner( val phenomena = scenario.phenomena val failureModel = - if (phenomena.failures) + if (phenomena.failures) { grid5000(Duration.ofDays(7)) - else + } else { null + } // Run workload trace service.replay(clock, vms, seed, failureModel = failureModel, interference = phenomena.interference) diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/WebComputeMonitor.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/WebComputeMonitor.kt index 76377c08..4db70d3d 100644 --- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/WebComputeMonitor.kt +++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/WebComputeMonitor.kt @@ -66,7 +66,7 @@ internal class WebComputeMonitor : ComputeMonitor { val totalLostTime: Long = 0L, val totalPowerDraw: Double = 0.0, val totalFailureSlices: Double = 0.0, - val totalFailureVmSlices: Double = 0.0, + val totalFailureVmSlices: Double = 0.0 ) private data class HostMetrics( @@ -84,7 +84,7 @@ internal class WebComputeMonitor : ComputeMonitor { max(reader.serversPending, serviceMetrics.vmWaitingCount), max(reader.serversActive, serviceMetrics.vmActiveCount), max(0, serviceMetrics.vmInactiveCount), - max(reader.attemptsFailure, serviceMetrics.vmFailedCount), + max(reader.attemptsFailure, serviceMetrics.vmFailedCount) ) } @@ -115,7 +115,7 @@ internal class WebComputeMonitor : ComputeMonitor { serviceMetrics.vmTotalCount, serviceMetrics.vmWaitingCount, serviceMetrics.vmInactiveCount, - serviceMetrics.vmFailedCount, + serviceMetrics.vmFailedCount ) } diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt index 5b686d5f..09437712 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Portfolio.kt @@ -87,7 +87,7 @@ class Portfolio( */ @Type(type = "json") @Column(columnDefinition = "jsonb", nullable = false, updatable = false) - val targets: Targets, + val targets: Targets ) { /** * The scenarios in this portfolio. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt index 5eb925ea..41d1a786 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Project.kt @@ -85,7 +85,7 @@ class Project( var name: String, @Column(name = "created_at", nullable = false, updatable = false) - val createdAt: Instant, + val createdAt: Instant ) { /** * The instant at which the project was updated. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt index a7258e7b..62adc9e2 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Scenario.kt @@ -106,7 +106,7 @@ class Scenario( val phenomena: OperationalPhenomena, @Column(name = "scheduler_name", nullable = false, updatable = false) - val schedulerName: String, + val schedulerName: String ) { /** * The [Job] associated with the scenario. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt index 0fc79ca8..14a88c5a 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/model/Trace.kt @@ -43,7 +43,7 @@ import javax.persistence.Table NamedQuery( name = "Trace.findAll", query = "SELECT t FROM Trace t" - ), + ) ] ) class Trace( @@ -54,7 +54,7 @@ class Trace( val name: String, @Column(nullable = false, updatable = false) - val type: String, + val type: String ) { /** * Return a string representation of this trace. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt index da565fe4..ebe57ae2 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioResource.kt @@ -43,7 +43,7 @@ import javax.ws.rs.WebApplicationException @RolesAllowed("openid") class PortfolioResource @Inject constructor( private val portfolioService: PortfolioService, - private val identity: SecurityIdentity, + private val identity: SecurityIdentity ) { /** * Get all portfolios that belong to the specified project. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt index 515f6be6..82f35127 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/rest/user/PortfolioScenarioResource.kt @@ -42,7 +42,7 @@ import javax.ws.rs.WebApplicationException @RolesAllowed("openid") class PortfolioScenarioResource @Inject constructor( private val scenarioService: ScenarioService, - private val identity: SecurityIdentity, + private val identity: SecurityIdentity ) { /** * Get all scenarios that belong to the specified portfolio. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt index 1929f44b..fad4e56f 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/service/ScenarioService.kt @@ -44,7 +44,7 @@ class ScenarioService @Inject constructor( private val portfolioRepository: PortfolioRepository, private val topologyRepository: TopologyRepository, private val traceRepository: TraceRepository, - private val scenarioRepository: ScenarioRepository, + private val scenarioRepository: ScenarioRepository ) { /** * List all [Scenario]s that belong a certain portfolio. diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBinarySqlTypeDescriptor.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBinarySqlTypeDescriptor.kt index 45752d4e..df6a3013 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBinarySqlTypeDescriptor.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBinarySqlTypeDescriptor.kt @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2022 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package org.opendc.web.server.util.hibernate.json import com.fasterxml.jackson.databind.JsonNode diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt index cc8dad48..4924f586 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonBytesSqlTypeDescriptor.kt @@ -77,10 +77,12 @@ internal object JsonBytesSqlTypeDescriptor : AbstractJsonSqlTypeDescriptor() { private fun fromJsonBytes(jsonBytes: ByteArray?): String? { return if (jsonBytes == null) { null - } else try { - String(jsonBytes, CHARSET) - } catch (e: UnsupportedEncodingException) { - throw IllegalStateException(e) + } else { + try { + String(jsonBytes, CHARSET) + } catch (e: UnsupportedEncodingException) { + throw IllegalStateException(e) + } } } } diff --git a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt index 63f32849..6e015762 100644 --- a/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt +++ b/opendc-web/opendc-web-server/src/main/kotlin/org/opendc/web/server/util/hibernate/json/JsonStringSqlTypeDescriptor.kt @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2022 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package org.opendc.web.server.util.hibernate.json import org.hibernate.type.descriptor.ValueBinder diff --git a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt index 71aaa8a4..9aca58e9 100644 --- a/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt +++ b/opendc-web/opendc-web-server/src/test/kotlin/org/opendc/web/server/rest/runner/JobResourceTest.kt @@ -62,7 +62,7 @@ class JobResourceTest { private val dummyPortfolio = Portfolio(1, 1, "test", Targets(emptySet())) private val dummyTopology = Topology(1, 1, "test", emptyList(), Instant.now(), Instant.now()) private val dummyTrace = Trace("bitbrains", "Bitbrains", "vm") - private val dummyScenario = Scenario(1, 1, dummyPortfolio, "test", Workload(dummyTrace, 1.0), dummyTopology, OperationalPhenomena(false, false), "test",) + private val dummyScenario = Scenario(1, 1, dummyPortfolio, "test", Workload(dummyTrace, 1.0), dummyTopology, OperationalPhenomena(false, false), "test") private val dummyJob = Job(1, dummyScenario, JobState.PENDING, Instant.now(), Instant.now()) @BeforeEach diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java index 2e4d9198..82e02549 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java @@ -24,7 +24,6 @@ package org.opendc.web.ui.deployment; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; - import java.util.Optional; /** diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java index 50c1fbe3..d630dbac 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java @@ -24,7 +24,6 @@ package org.opendc.web.ui.deployment; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigRoot; - import java.util.Optional; /** diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java index 54782ace..093a9bfa 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java @@ -41,9 +41,6 @@ import io.quarkus.vertx.http.deployment.webjar.WebJarResourcesFilter; import io.quarkus.vertx.http.deployment.webjar.WebJarResultsBuildItem; import io.vertx.core.Handler; import io.vertx.ext.web.RoutingContext; -import org.opendc.web.ui.runtime.OpenDCUiRecorder; -import org.opendc.web.ui.runtime.OpenDCUiRuntimeConfig; - import java.io.*; import java.util.ArrayList; import java.util.Iterator; @@ -51,6 +48,8 @@ import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.opendc.web.ui.runtime.OpenDCUiRecorder; +import org.opendc.web.ui.runtime.OpenDCUiRuntimeConfig; /** * Build processor for the OpenDC web UI Quarkus extension. @@ -76,25 +75,25 @@ public class OpenDCUiProcessor { * Build the WebJar that is used to serve the Next.js resources. */ @BuildStep(onlyIf = IsIncluded.class) - public WebJarBuildItem buildWebJar(OpenDCUiConfig config, - HttpRootPathBuildItem httpRootPathBuildItem) { + public WebJarBuildItem buildWebJar(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) { return WebJarBuildItem.builder() - .artifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY) - .root(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH) - .onlyCopyNonArtifactFiles(false) - .useDefaultQuarkusBranding(false) - .filter(new InsertVariablesResourcesFilter(config, httpRootPathBuildItem)) - .build(); + .artifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY) + .root(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH) + .onlyCopyNonArtifactFiles(false) + .useDefaultQuarkusBranding(false) + .filter(new InsertVariablesResourcesFilter(config, httpRootPathBuildItem)) + .build(); } - /** * Build the Next.js routes based on the route manifest generated by it. */ @BuildStep(onlyIf = IsIncluded.class) - public OpenDCUiRoutingBuildItem buildRoutes(CurateOutcomeBuildItem curateOutcomeBuildItem) throws IOException { + public OpenDCUiRoutingBuildItem buildRoutes(CurateOutcomeBuildItem curateOutcomeBuildItem) throws IOException { ResolvedDependency dependency = getAppArtifact(curateOutcomeBuildItem, OPENDC_UI_WEBJAR_ARTIFACT_KEY); - PathVisit visit = dependency.getContentTree().apply(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH + "/routes-manifest.json", v -> v); + PathVisit visit = dependency + .getContentTree() + .apply(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH + "/routes-manifest.json", v -> v); if (visit == null) { throw new FileNotFoundException("Cannot find routes-manifest.json"); @@ -103,7 +102,7 @@ public class OpenDCUiProcessor { JsonNode routeManifest = objectMapper.readTree(visit.getUrl()); var pages = new ArrayList(); - for (Iterator it = routeManifest.get("staticRoutes").elements(); it.hasNext();) { + for (Iterator it = routeManifest.get("staticRoutes").elements(); it.hasNext(); ) { JsonNode route = it.next(); String page = route.get("page").asText(); @@ -112,7 +111,7 @@ public class OpenDCUiProcessor { pages.add(new OpenDCUiRoutingBuildItem.Page(page, page)); } - for (Iterator it = routeManifest.get("dynamicRoutes").elements(); it.hasNext();) { + for (Iterator it = routeManifest.get("dynamicRoutes").elements(); it.hasNext(); ) { JsonNode route = it.next(); String page = route.get("page").asText(); @@ -122,7 +121,7 @@ public class OpenDCUiProcessor { } var redirects = new ArrayList(); - for (Iterator it = routeManifest.get("redirects").elements(); it.hasNext();) { + for (Iterator it = routeManifest.get("redirects").elements(); it.hasNext(); ) { JsonNode redirect = it.next(); if (redirect.has("internal")) { continue; @@ -148,16 +147,18 @@ public class OpenDCUiProcessor { */ @BuildStep(onlyIf = IsIncluded.class) @Record(ExecutionTime.RUNTIME_INIT) - public void registerOpenDCUiHandler(OpenDCUiRecorder recorder, - BuildProducer routes, - HttpRootPathBuildItem httpRootPathBuildItem, - WebJarResultsBuildItem webJarResultsBuildItem, - OpenDCUiRoutingBuildItem openDCUiBuildItem, - OpenDCUiRuntimeConfig runtimeConfig, - OpenDCUiConfig buildConfig, - ShutdownContextBuildItem shutdownContext) { - - WebJarResultsBuildItem.WebJarResult result = webJarResultsBuildItem.byArtifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY); + public void registerOpenDCUiHandler( + OpenDCUiRecorder recorder, + BuildProducer routes, + HttpRootPathBuildItem httpRootPathBuildItem, + WebJarResultsBuildItem webJarResultsBuildItem, + OpenDCUiRoutingBuildItem openDCUiBuildItem, + OpenDCUiRuntimeConfig runtimeConfig, + OpenDCUiConfig buildConfig, + ShutdownContextBuildItem shutdownContext) { + + WebJarResultsBuildItem.WebJarResult result = + webJarResultsBuildItem.byArtifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY); if (result == null) { return; } @@ -167,41 +168,41 @@ public class OpenDCUiProcessor { /* Construct dynamic routes */ for (var redirect : openDCUiBuildItem.getRedirects()) { - String destination = basePath.equals("/") ? redirect.getDestination() : basePath + redirect.getDestination(); - - routes.produce(httpRootPathBuildItem.routeBuilder() - .route(basePath + redirect.getPath()) - .handler(recorder.redirectHandler(destination, redirect.getStatusCode(), runtimeConfig)) - .build()); + String destination = + basePath.equals("/") ? redirect.getDestination() : basePath + redirect.getDestination(); + + routes.produce(httpRootPathBuildItem + .routeBuilder() + .route(basePath + redirect.getPath()) + .handler(recorder.redirectHandler(destination, redirect.getStatusCode(), runtimeConfig)) + .build()); } for (var page : openDCUiBuildItem.getPages()) { - routes.produce(httpRootPathBuildItem.routeBuilder() - .route(basePath + page.getPath()) - .handler(recorder.pageHandler(finalDestination, page.getName(), runtimeConfig)) - .build()); + routes.produce(httpRootPathBuildItem + .routeBuilder() + .route(basePath + page.getPath()) + .handler(recorder.pageHandler(finalDestination, page.getName(), runtimeConfig)) + .build()); } /* Construct static routes */ Handler staticHandler = recorder.staticHandler( - finalDestination, - basePath, - result.getWebRootConfigurations(), - runtimeConfig, - shutdownContext - ); - - routes.produce(httpRootPathBuildItem.routeBuilder() - .route(buildConfig.path) - .displayOnNotFoundPage("OpenDC UI") - .routeConfigKey("quarkus.opendc-ui.path") - .handler(staticHandler) - .build()); - - routes.produce(httpRootPathBuildItem.routeBuilder() - .route(buildConfig.path + "*") - .handler(staticHandler) - .build()); + finalDestination, basePath, result.getWebRootConfigurations(), runtimeConfig, shutdownContext); + + routes.produce(httpRootPathBuildItem + .routeBuilder() + .route(buildConfig.path) + .displayOnNotFoundPage("OpenDC UI") + .routeConfigKey("quarkus.opendc-ui.path") + .handler(staticHandler) + .build()); + + routes.produce(httpRootPathBuildItem + .routeBuilder() + .route(buildConfig.path + "*") + .handler(staticHandler) + .build()); } /** @@ -216,7 +217,6 @@ public class OpenDCUiProcessor { private final OpenDCUiConfig config; private final HttpRootPathBuildItem httpRootPathBuildItem; - public InsertVariablesResourcesFilter(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) { this.config = config; this.httpRootPathBuildItem = httpRootPathBuildItem; @@ -304,7 +304,8 @@ public class OpenDCUiProcessor { } private static ResolvedDependency getAppArtifact(CurateOutcomeBuildItem curateOutcomeBuildItem, GACT artifactKey) { - for (ResolvedDependency dep : curateOutcomeBuildItem.getApplicationModel().getDependencies()) { + for (ResolvedDependency dep : + curateOutcomeBuildItem.getApplicationModel().getDependencies()) { if (dep.getKey().equals(artifactKey)) { return dep; } diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java index 7e0f9408..6cf44893 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java @@ -23,7 +23,6 @@ package org.opendc.web.ui.deployment; import io.quarkus.builder.item.SimpleBuildItem; - import java.util.List; /** @@ -57,7 +56,7 @@ public final class OpenDCUiRoutingBuildItem extends SimpleBuildItem { } public boolean hasCustom404() { - return this.custom404; + return this.custom404; } /** diff --git a/opendc-web/opendc-web-ui-quarkus/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRecorder.java b/opendc-web/opendc-web-ui-quarkus/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRecorder.java index 026a9039..03fedd4f 100644 --- a/opendc-web/opendc-web-ui-quarkus/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRecorder.java +++ b/opendc-web/opendc-web-ui-quarkus/src/main/java/org/opendc/web/ui/runtime/OpenDCUiRecorder.java @@ -29,7 +29,6 @@ import io.quarkus.vertx.http.runtime.webjar.WebJarNotFoundHandler; import io.quarkus.vertx.http.runtime.webjar.WebJarStaticHandler; import io.vertx.core.Handler; import io.vertx.ext.web.RoutingContext; - import java.util.List; import java.util.stream.Collectors; @@ -42,16 +41,11 @@ public class OpenDCUiRecorder { * Construct a {@link Handler} for serving a page of the OpenDC web interface. */ public Handler pageHandler( - String finalDestination, - String page, - OpenDCUiRuntimeConfig runtimeConfig - ) { + String finalDestination, String page, OpenDCUiRuntimeConfig runtimeConfig) { if (runtimeConfig.enable) { String pageDirectory = finalDestination + "/pages"; return (event) -> { - event.response() - .setStatusCode(200) - .sendFile(pageDirectory + page + ".html"); + event.response().setStatusCode(200).sendFile(pageDirectory + page + ".html"); }; } @@ -62,19 +56,16 @@ public class OpenDCUiRecorder { * Construct a {@link Handler} for handling redirects in the OpenDC web interface. */ public Handler redirectHandler( - String destination, - int statusCode, - OpenDCUiRuntimeConfig runtimeConfig - ) { + String destination, int statusCode, OpenDCUiRuntimeConfig runtimeConfig) { if (runtimeConfig.enable) { return (event) -> { String query = event.request().query(); String fullDestination = query != null ? destination + "?" + query : destination; event.response() - .setStatusCode(statusCode) - .putHeader("Location", fullDestination) - .end(); + .setStatusCode(statusCode) + .putHeader("Location", fullDestination) + .end(); }; } @@ -85,19 +76,19 @@ public class OpenDCUiRecorder { * Construct a {@link Handler} for serving the static files of the OpenDC web interface. */ public Handler staticHandler( - String finalDestination, - String path, - List webRootConfigurations, - OpenDCUiRuntimeConfig runtimeConfig, - ShutdownContext shutdownContext - ) { + String finalDestination, + String path, + List webRootConfigurations, + OpenDCUiRuntimeConfig runtimeConfig, + ShutdownContext shutdownContext) { if (runtimeConfig.enable) { - var augmentedWebRootConfigurations = webRootConfigurations - .stream() - .map(c -> new FileSystemStaticHandler.StaticWebRootConfiguration(c.getFileSystem(), c.getWebRoot().isEmpty() ? "static" : c.getWebRoot() + "/static")) - .collect(Collectors.toList()); + var augmentedWebRootConfigurations = webRootConfigurations.stream() + .map(c -> new FileSystemStaticHandler.StaticWebRootConfiguration( + c.getFileSystem(), c.getWebRoot().isEmpty() ? "static" : c.getWebRoot() + "/static")) + .collect(Collectors.toList()); - WebJarStaticHandler handler = new WebJarStaticHandler(finalDestination + "/static", path, augmentedWebRootConfigurations); + WebJarStaticHandler handler = + new WebJarStaticHandler(finalDestination + "/static", path, augmentedWebRootConfigurations); shutdownContext.addShutdownTask(new ShutdownContext.CloseRunnable(handler)); return handler; } diff --git a/opendc-web/opendc-web-ui/build.gradle.kts b/opendc-web/opendc-web-ui/build.gradle.kts index f8c0a45b..5e999359 100644 --- a/opendc-web/opendc-web-ui/build.gradle.kts +++ b/opendc-web/opendc-web-ui/build.gradle.kts @@ -76,10 +76,10 @@ val buildTask = tasks.register("buildNext") { "NEXT_PUBLIC_SENTRY_DSN", "NEXT_PUBLIC_AUTH0_DOMAIN", "NEXT_PUBLIC_AUTH0_CLIENT_ID", - "NEXT_PUBLIC_AUTH0_AUDIENCE", + "NEXT_PUBLIC_AUTH0_AUDIENCE" ) for (envvar in env) { - environment.put(envvar, "%%${envvar}%%") + environment.put(envvar, "%%$envvar%%") } dependsOn(tasks.npmInstall) -- cgit v1.2.3