diff options
| author | vincent van beek <vincent@vlogic.nl> | 2026-03-26 14:02:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-26 13:02:54 +0000 |
| commit | 0ffde21b0337c606e2d0ece5bd5434a930a87dcd (patch) | |
| tree | 4fd071728a8da6dcf3e6fc9fe9dca5a492100d34 /opendc-web/opendc-web-proto/src/main/java/org/opendc | |
| parent | 8bb98c773bc982a0dab9cf9fb20d62f60a36a5d7 (diff) | |
Use Quarkus Quinoa for serving web UI (#391)
* refactor(web): Migrate to Quarkus 3
This commit updates the OpenDC web server to use Quarkus 3, which
changes annotations to use the Jakarta namespace for annotations.
* refactor(web): Configure runtime variables for web UI
This commit updates the web UI to propagate runtime variables via the
next-runtime-env package. Before, we would need to replace the variables
in the generated sources by Next.js, next-runtime-env works by loading a
JavaScript file when opening the OpenDC web UI which contains the
configuration of the web app.
* refactor(web): Migrate to Quarkus Quinoa
This commit updates the OpenDC web server to make use of Quarkus Quinoa
for serving the web UI. This allows us to deprecate the complex Quarkus
extension for serving the web UI.
* refactor(web): Move web UI into Quarkus web app
This commit moves the web UI into the Quarkus web server module to
ensure we follow Quarkus Quinoa's conventions.
* refactor(web): Merge Quarkus extension into single module
This commit merges the existing Quarkus extensions into a single module
to prevent build complexity.
* refactor(web): Migrate web proto to Java
This commit migrates the web protocol to Java and removes the dependency
on Jandex Gradle.
* refactor(web): Migrate to Quarkus 3
This commit updates the OpenDC web server to use Quarkus 3, which
changes annotations to use the Jakarta namespace for annotations.
* enable DB schema migration on DEV server
* webui is not needed anymore
* remove MAINTAINERS is depricated
* fix quarkus.quinoa properties
* revert properties change, install npm in docker image to allow building the frontend
* pin postgres version, this is a best practice. Fix some properties the old ones are depricated. Added properties for local testing
* fix build error
* :opendc-web:opendc-web-proto:spotlessApply
* fix database schema
---------
Co-authored-by: Fabian Mastenbroek <mail.fabianm@gmail.com>
Diffstat (limited to 'opendc-web/opendc-web-proto/src/main/java/org/opendc')
25 files changed, 997 insertions, 0 deletions
diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java new file mode 100644 index 00000000..14a0faba --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 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.proto; + +/** + * State of a scenario for the simulator runner. + */ +public enum JobState { + /** + * The job is pending to be claimed by a runner. + */ + PENDING, + + /** + * The job is claimed by a runner. + */ + CLAIMED, + + /** + * The job is currently running. + */ + RUNNING, + + /** + * The job has finished. + */ + FINISHED, + + /** + * The job has failed. + */ + FAILED +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java new file mode 100644 index 00000000..cf492e38 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 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.proto; + +/** + * Object describing the enabled operational phenomena for a scenario. + */ +public record OperationalPhenomena(boolean failures, boolean interference) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java new file mode 100644 index 00000000..cb9324ea --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 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.proto; + +/** + * Container for reporting errors. + */ +public record ProtocolError(int code, String message) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java new file mode 100644 index 00000000..4823bb66 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 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.proto; + +import jakarta.validation.constraints.Min; +import java.util.Set; + +/** + * The targets of a portfolio. + * + * @param metrics The selected metrics to track during simulation. + * @param repeats The number of repetitions per scenario. + */ +public record Targets(Set<String> metrics, @Min(1) int repeats) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java new file mode 100644 index 00000000..adf916d3 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 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.proto; + +/** + * A workload trace available for simulation. + * + * @param id The unique identifier of the trace. + * @param name The name of the trace. + * @param type The type of trace. + */ +public record Trace(String id, String name, String type) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java new file mode 100644 index 00000000..e8f552d6 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 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.proto; + +import jakarta.validation.constraints.DecimalMax; +import jakarta.validation.constraints.DecimalMin; + +/** + * The workload to simulate for a scenario. + */ +public record Workload(Trace trace, double samplingFraction) { + /** + * Specification for a workload. + * + * @param trace The unique identifier of the trace. + * @param samplingFraction The fraction of the workload to sample. + */ + public record Spec( + String trace, + @DecimalMin(value = "0.001", message = "Sampling fraction must be non-zero") + @DecimalMax(value = "1", message = "Sampling fraction cannot exceed one") + double samplingFraction) {} +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java new file mode 100644 index 00000000..587fe451 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023 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.proto.runner; + +import java.time.Instant; +import java.util.Map; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.JobState; + +/** + * A simulation job to be simulated by a runner. + */ +@Schema(name = "Runner.Job") +public record Job( + long id, + Scenario scenario, + JobState state, + Instant createdAt, + Instant updatedAt, + int runtime, + Map<String, ?> results) { + /** + * A request to update the state of a job. + * + * @param state The next state of the job. + * @param runtime The runtime of the job (in seconds). + * @param results The results of the job. + */ + @Schema(name = "Runner.Job.Update") + public record Update(JobState state, int runtime, Map<String, ?> results) {} +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java new file mode 100644 index 00000000..33b520a0 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 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.proto.runner; + +import jakarta.validation.Valid; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import java.util.List; +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +/** + * Service for interacting with the OpenDC job server. + */ +@Path("/jobs") +@RegisterRestClient +public interface JobService { + /** + * Obtain all pending simulation jobs. + */ + @GET + List<Job> queryPending(); + + /** + * Get a job by identifier. + */ + @GET + @Path("{job}") + Job get(@PathParam("job") long id); + + /** + * Atomically update the state of a job. + */ + @POST + @Path("{job}") + @Consumes("application/json") + Job update(@PathParam("job") long id, @Valid Job.Update update); +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java new file mode 100644 index 00000000..44f0b500 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 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.proto.runner; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.Targets; + +/** + * A {@link Portfolio} as seen from the runner's perspective. + * + * @param id The unique identifier of the portfolio. + * @param number The number of the portfolio for the project. + * @param name The name of the portfolio. + * @param targets The targets of the portfolio. + */ +@Schema(name = "Runner.Portfolio") +public record Portfolio(long id, int number, String name, Targets targets) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java new file mode 100644 index 00000000..8005ac3b --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 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.proto.runner; + +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.OperationalPhenomena; +import org.opendc.web.proto.Workload; + +/** + * A {@link Scenario} that is exposed to an OpenDC runner. + */ +@Schema(name = "Runner.Scenario") +public record Scenario( + long id, + int number, + Portfolio portfolio, + String name, + Workload workload, + Topology topology, + OperationalPhenomena phenomena, + String schedulerName) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java new file mode 100644 index 00000000..fdabd12d --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 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.proto.runner; + +import java.time.Instant; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.topology.Room; + +/** + * A [Topology] that is exposed to an OpenDC runner. + */ +@Schema(name = "Runner.Topology") +public record Topology(long id, int number, String name, List<Room> rooms, Instant createdAt, Instant updatedAt) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java new file mode 100644 index 00000000..ec78f249 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 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.proto.topology; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * A machine in a rack. + */ +public record Machine( + String id, + int position, + List<ProcessingUnit> cpus, + List<ProcessingUnit> gpus, + @JsonProperty("memories") List<MemoryUnit> memory, + @JsonProperty("storages") List<MemoryUnit> storage, + String rackId) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java new file mode 100644 index 00000000..a53b584a --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 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.proto.topology; + +/** + * A memory unit in a system. + */ +public record MemoryUnit(String id, String name, double speedMbPerS, double sizeMb, double energyConsumptionW) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java new file mode 100644 index 00000000..baa61aac --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 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.proto.topology; + +/** + * A CPU model. + */ +public record ProcessingUnit( + String id, String name, double clockRateMhz, int numberOfCores, double energyConsumptionW) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java new file mode 100644 index 00000000..b68fddd3 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 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.proto.topology; + +import java.util.List; + +/** + * A rack in a datacenter. + */ +public record Rack(String id, String name, int capacity, double powerCapacityW, List<Machine> machines) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java new file mode 100644 index 00000000..530d21f5 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 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.proto.topology; + +import java.util.Set; + +/** + * A room in a datacenter. + */ +public record Room(String id, String name, Set<RoomTile> tiles, String topologyId) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java new file mode 100644 index 00000000..a7240541 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 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.proto.topology; + +/** + * A location in a room. + */ +public record RoomTile(String id, double positionX, double positionY, Rack rack, String roomId) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java new file mode 100644 index 00000000..480efdad --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 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.proto.user; + +import java.time.Instant; +import java.util.Map; +import org.opendc.web.proto.JobState; + +/** + * A simulation job that is associated with a {@link Scenario}. + * <p> + * This entity is exposed in the runner-facing API via {@link Job}. + */ +public record Job(long id, JobState state, Instant createdAt, Instant updatedAt, Map<String, ?> results) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java new file mode 100644 index 00000000..ff8d9e82 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 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.proto.user; + +import jakarta.validation.constraints.NotBlank; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.Targets; + +/** + * A portfolio is the composition of multiple scenarios. + * + * @param id The unique identifier of the portfolio. + * @param number The number of the portfolio with respect to the project. + * @param project The project to which the portfolio belongs. + * @param name The name of the portfolio. + * @param targets The targets of the portfolio. + * @param scenarios The scenarios in the portfolio. + */ +public record Portfolio( + long id, int number, Project project, String name, Targets targets, List<Scenario.Summary> scenarios) { + /** + * A request to create a new portfolio. + */ + @Schema(name = "Portfolio.Update") + public record Create(@NotBlank(message = "Name must not be empty") String name, Targets targets) {} + + /** + * A summary view of a [Portfolio] provided for nested relations. + * + * @param id The unique identifier of the portfolio. + * @param number The number of the portfolio for the project. + * @param name The name of the portfolio. + * @param targets The targets of the portfolio. + */ + @Schema(name = "Portfolio.Summary") + public record Summary(long id, int number, String name, Targets targets) {} +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java new file mode 100644 index 00000000..534fdb26 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 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.proto.user; + +import jakarta.validation.constraints.NotBlank; +import java.time.Instant; +import org.eclipse.microprofile.openapi.annotations.media.Schema; + +/** + * A project in OpenDC encapsulates all the datacenter designs and simulation runs for a set of users. + */ +public record Project(long id, String name, Instant createdAt, Instant updatedAt, ProjectRole role) { + /** + * A request to create a new project. + */ + @Schema(name = "Project.Create") + public record Create(@NotBlank(message = "Name must not be empty") String name) {} +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java new file mode 100644 index 00000000..434ab472 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 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.proto.user; + +/** + * The role of a user in a project. + */ +public enum ProjectRole { + /** + * The user is allowed to view the project. + */ + VIEWER, + + /** + * The user is allowed to edit the project. + */ + EDITOR, + + /** + * The user owns the project (so he can delete it). + */ + OWNER, +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java new file mode 100644 index 00000000..7add5656 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2023 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.proto.user; + +import jakarta.validation.constraints.NotBlank; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.OperationalPhenomena; +import org.opendc.web.proto.Workload; + +/** + * A single scenario to be explored by the simulator. + */ +public record Scenario( + long id, + int number, + Project project, + Portfolio.Summary portfolio, + String name, + Workload workload, + Topology.Summary topology, + OperationalPhenomena phenomena, + String schedulerName, + List<Job> jobs) { + /** + * Create a new scenario. + * + * @param name The name of the scenario. + * @param workload The workload specification to use for the scenario. + * @param topology The number of the topology to use. + * @param phenomena The phenomena to model during simulation. + * @param schedulerName The name of the scheduler. + */ + @Schema(name = "Scenario.Create") + public record Create( + @NotBlank(message = "Name must not be empty") String name, + Workload.Spec workload, + long topology, + OperationalPhenomena phenomena, + String schedulerName) {} + + /** + * A summary view of a [Scenario] provided for nested relations. + * + * @param id The unique identifier of the scenario. + * @param number The number of the scenario for the project. + * @param name The name of the scenario. + * @param workload The workload to be modeled by the scenario. + * @param phenomena The phenomena simulated for this scenario. + * @param schedulerName The scheduler name to use for the experiment. + * @param jobs The simulation jobs associated with the scenario. + */ + @Schema(name = "Scenario.Summary") + public record Summary( + long id, + int number, + String name, + Workload workload, + Topology.Summary topology, + OperationalPhenomena phenomena, + String schedulerName, + List<Job> jobs) {} +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java new file mode 100644 index 00000000..7291c77b --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023 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.proto.user; + +import jakarta.validation.constraints.NotBlank; +import java.time.Instant; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.topology.Room; + +/** + * Model for an OpenDC topology. + */ +public record Topology( + long id, int number, Project project, String name, List<Room> rooms, Instant createdAt, Instant updatedAt) { + /** + * Create a new topology for a project. + */ + @Schema(name = "Topology.Create") + public record Create(@NotBlank(message = "Name must not be empty") String name, List<Room> rooms) {} + + /** + * Update an existing topology. + */ + @Schema(name = "Topology.Update") + public record Update(List<Room> rooms) {} + + /** + * A summary view of a [Topology] provided for nested relations. + * + * @param id The unique identifier of the topology. + * @param number The number of the topology for the project. + * @param name The name of the topology. + * @param createdAt The instant at which the topology was created. + * @param updatedAt The instant at which the topology was updated. + */ + @Schema(name = "Topology.Summary") + public record Summary(long id, int number, String name, Instant createdAt, Instant updatedAt) {} +} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java new file mode 100644 index 00000000..030d9207 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 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.proto.user; + +/** + * A user of OpenDC. + */ +public record User(String userId, UserAccounting accounting) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java new file mode 100644 index 00000000..3831381f --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 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.proto.user; + +import java.time.LocalDate; + +/** + * Accounting data for a user. + */ +public record UserAccounting(LocalDate periodEnd, int simulationTime, int simulationTimeBudget) {} |
