From f0c12a130b7b1feeec2b0c67d7caa137ff0fe64d Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sat, 28 Oct 2023 21:39:15 +0100 Subject: [PATCH] refactor(web): Migrate web proto to Java This commit migrates the web protocol to Java and removes the dependency on Jandex Gradle. --- buildSrc/build.gradle.kts | 1 - .../kotlin/quarkus-conventions.gradle.kts | 5 -- gradle/libs.versions.toml | 6 +- opendc-web/opendc-web-proto/build.gradle.kts | 9 +-- .../org/opendc/web/proto/JobState.java} | 8 +-- .../web/proto/OperationalPhenomena.java} | 9 +-- .../org/opendc/web/proto/ProtocolError.java} | 6 +- .../org/opendc/web/proto/Targets.java} | 13 ++-- .../org/opendc/web/proto/Trace.java} | 10 +-- .../org/opendc/web/proto/Workload.java} | 21 +++--- .../org/opendc/web/proto/runner/Job.java} | 36 +++++----- .../opendc/web/proto/runner/JobService.java | 60 ++++++++++++++++ .../opendc/web/proto/runner/Portfolio.java} | 18 ++--- .../opendc/web/proto/runner/Scenario.java} | 31 ++++---- .../opendc/web/proto/runner/Topology.java} | 20 ++---- .../opendc/web/proto/topology/Machine.java | 38 ++++++++++ .../web/proto/topology/MemoryUnit.java} | 12 +--- .../web/proto/topology/ProcessingUnit.java} | 13 ++-- .../org/opendc/web/proto/topology/Rack.java} | 14 ++-- .../org/opendc/web/proto/topology/Room.java} | 13 ++-- .../opendc/web/proto/topology/RoomTile.java | 28 ++++++++ .../java/org/opendc/web/proto/user/Job.java | 34 +++++++++ .../org/opendc/web/proto/user/Portfolio.java} | 34 +++------ .../org/opendc/web/proto/user/Project.java} | 20 ++---- .../opendc/web/proto/user/ProjectRole.java} | 6 +- .../org/opendc/web/proto/user/Scenario.java} | 71 +++++++++---------- .../org/opendc/web/proto/user/Topology.java} | 40 ++++------- .../org/opendc/web/proto/user/User.java} | 9 +-- .../web/proto/user/UserAccounting.java} | 12 ++-- .../kotlin/org/opendc/web/proto/Machine.kt | 40 ----------- .../kotlin/org/opendc/web/proto/RoomTile.kt | 34 --------- .../kotlin/org/opendc/web/proto/user/Job.kt | 40 ----------- .../src/main/resources/META-INF/beans.xml | 0 .../runtime/runner/OpenDCRunnerRecorder.java | 2 +- .../web/runner/internal/JobManagerImpl.kt | 8 +-- .../org/opendc/web/server/model/Topology.java | 2 +- ...MissingKotlinParameterExceptionMapper.java | 46 ------------ .../web/server/rest/runner/JobResource.java | 2 +- .../server/rest/user/PortfolioResource.java | 2 +- .../rest/user/PortfolioScenarioResource.java | 14 ++-- .../web/server/rest/user/ProjectResource.java | 2 +- .../server/rest/user/TopologyResource.java | 4 +- .../service/UserAccountingServiceTest.java | 10 +-- 43 files changed, 354 insertions(+), 449 deletions(-) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/JobState.kt => java/org/opendc/web/proto/JobState.java} (93%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/OperationalPhenomena.kt => java/org/opendc/web/proto/OperationalPhenomena.java} (87%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/ProtocolError.kt => java/org/opendc/web/proto/ProtocolError.java} (89%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/Targets.kt => java/org/opendc/web/proto/Targets.java} (85%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/Trace.kt => java/org/opendc/web/proto/Trace.java} (88%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/Workload.kt => java/org/opendc/web/proto/Workload.java} (72%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/runner/Job.kt => java/org/opendc/web/proto/runner/Job.java} (68%) create mode 100644 opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/runner/Portfolio.kt => java/org/opendc/web/proto/runner/Portfolio.java} (81%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/runner/Scenario.kt => java/org/opendc/web/proto/runner/Scenario.java} (72%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/runner/Topology.kt => java/org/opendc/web/proto/runner/Topology.java} (80%) create mode 100644 opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/MemoryUnit.kt => java/org/opendc/web/proto/topology/MemoryUnit.java} (82%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/ProcessingUnit.kt => java/org/opendc/web/proto/topology/ProcessingUnit.java} (82%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/Rack.kt => java/org/opendc/web/proto/topology/Rack.java} (83%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/Room.kt => java/org/opendc/web/proto/topology/Room.java} (84%) create mode 100644 opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java create mode 100644 opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/user/Portfolio.kt => java/org/opendc/web/proto/user/Portfolio.java} (75%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/user/Project.kt => java/org/opendc/web/proto/user/Project.java} (77%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/user/ProjectRole.kt => java/org/opendc/web/proto/user/ProjectRole.java} (92%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/user/Scenario.kt => java/org/opendc/web/proto/user/Scenario.java} (64%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/user/Topology.kt => java/org/opendc/web/proto/user/Topology.java} (70%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/user/User.kt => java/org/opendc/web/proto/user/User.java} (87%) rename opendc-web/opendc-web-proto/src/main/{kotlin/org/opendc/web/proto/user/UserAccounting.kt => java/org/opendc/web/proto/user/UserAccounting.java} (83%) delete mode 100644 opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Machine.kt delete mode 100644 opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt delete mode 100644 opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Job.kt create mode 100644 opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml delete mode 100644 opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/MissingKotlinParameterExceptionMapper.java diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c86f85ede..ce5f79c50 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -38,7 +38,6 @@ dependencies { implementation(libs.jmh.gradle) implementation(libs.dokka.gradle) - implementation(libs.jandex.gradle) implementation(libs.quarkus.gradle.application) implementation(libs.quarkus.gradle.extension) } diff --git a/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts b/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts index 3bd3d85ae..e811519ef 100644 --- a/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts @@ -23,10 +23,7 @@ import org.gradle.api.artifacts.type.ArtifactTypeDefinition import org.gradle.api.attributes.Category import org.gradle.api.attributes.VerificationType -import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.kotlin -import org.gradle.kotlin.dsl.withType plugins { id("java-conventions") @@ -48,7 +45,6 @@ configurations.create("coverageDataElementsForQuarkus") { extendsFrom(configurations["implementation"], configurations["runtimeOnly"]) - @Suppress("UnstableApiUsage") attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class.java, Category.VERIFICATION)) attribute(VerificationType.VERIFICATION_TYPE_ATTRIBUTE, objects.named(VerificationType::class.java, VerificationType.JACOCO_RESULTS)) @@ -56,7 +52,6 @@ configurations.create("coverageDataElementsForQuarkus") { artifacts { add("coverageDataElementsForQuarkus", layout.buildDirectory.file("jacoco-quarkus.exec")) { - @Suppress("UnstableApiUsage") type = ArtifactTypeDefinition.BINARY_DATA_TYPE builtBy(tasks.test) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f399200bf..245fc6199 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,16 +6,17 @@ dokka = "1.9.10" hadoop = "3.3.6" hypersistence-utils = "3.6.0" jackson = "2.15.3" -jandex-gradle = "1.1.0" java = "17" jline = "3.23.0" jmh-gradle = "0.7.1" jakarta-validation = "3.0.2" +jakarta-ws-rs = "3.1.0" junit-jupiter = "5.10.0" kotlin = "1.9.10" kotlin-logging = "3.0.5" kotlinx-coroutines = "1.7.3" log4j = "2.21.0" +microprofile-rest-client = "3.0.1" microprofile-openapi = "3.1.1" microprofile-config = "3.1" mockk = "1.13.8" @@ -100,14 +101,15 @@ jline = { module = "org.jline:jline", version.ref = "jline" } # Other jakarta-validation = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation" } +jakarta-ws-rs-api = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version.ref = "jakarta-ws-rs" } hadoop-common = { module = "org.apache.hadoop:hadoop-common", version.ref = "hadoop" } hadoop-mapreduce-client-core = { module = "org.apache.hadoop:hadoop-mapreduce-client-core", version.ref = "hadoop" } commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" } +microprofile-rest-client-api = { module = "org.eclipse.microprofile.rest.client:microprofile-rest-client-api", version.ref = "microprofile-rest-client" } microprofile-openapi-api = { module = "org.eclipse.microprofile.openapi:microprofile-openapi-api", version.ref = "microprofile-openapi" } microprofile-config = { module = "org.eclipse.microprofile.config:microprofile-config-api", version.ref = "microprofile-config" } # Other (Build) dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } -jandex-gradle = { module = "org.kordamp.gradle:jandex-gradle-plugin", version.ref = "jandex-gradle" } jmh-gradle = { module = "me.champeau.jmh:jmh-gradle-plugin", version.ref = "jmh-gradle" } spotless-gradle = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } diff --git a/opendc-web/opendc-web-proto/build.gradle.kts b/opendc-web/opendc-web-proto/build.gradle.kts index 4a566346a..04e9f3093 100644 --- a/opendc-web/opendc-web-proto/build.gradle.kts +++ b/opendc-web/opendc-web-proto/build.gradle.kts @@ -24,16 +24,13 @@ description = "Web communication protocol for OpenDC" /* Build configuration */ plugins { - `kotlin-library-conventions` - id("org.kordamp.gradle.jandex") // Necessary for Quarkus to process annotations + `java-library-conventions` } dependencies { implementation(libs.jackson.annotations) implementation(libs.jakarta.validation) + implementation(libs.jakarta.ws.rs.api) + implementation(libs.microprofile.rest.client.api) implementation(libs.microprofile.openapi.api) } - -tasks.withType { - kotlinOptions.javaParameters = true -} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java similarity index 93% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java index 38b8ca427..14a0faba4 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,12 +20,12 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * State of a scenario for the simulator runner. */ -public enum class JobState { +public enum JobState { /** * The job is pending to be claimed by a runner. */ @@ -49,5 +49,5 @@ public enum class JobState { /** * The job has failed. */ - FAILED; + FAILED } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java similarity index 87% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java index f3164f647..cf492e382 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * 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 @@ -20,12 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * Object describing the enabled operational phenomena for a scenario. */ -public data class OperationalPhenomena( - val failures: Boolean, - val interference: Boolean -) +public record OperationalPhenomena(boolean failures, boolean interference) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java similarity index 89% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java index e7fe2702f..cb9324ea7 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,9 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * Container for reporting errors. */ -public data class ProtocolError(val code: Int, val message: String) +public record ProtocolError(int code, String message) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java similarity index 85% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java index 32c006e67..4823bb665 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,9 +20,10 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; -import jakarta.validation.constraints.Min +import jakarta.validation.constraints.Min; +import java.util.Set; /** * The targets of a portfolio. @@ -30,8 +31,4 @@ * @param metrics The selected metrics to track during simulation. * @param repeats The number of repetitions per scenario. */ -public data class Targets( - val metrics: Set, - @field:Min(1) - val repeats: Int = 1 -) +public record Targets(Set metrics, @Min(1) int repeats) {} 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/java/org/opendc/web/proto/Trace.java similarity index 88% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java index 1c086cd83..adf916d3a 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * A workload trace available for simulation. @@ -29,8 +29,4 @@ * @param name The name of the trace. * @param type The type of trace. */ -public data class Trace( - val id: String, - val name: String, - val type: String -) +public record Trace(String id, String name, String type) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java similarity index 72% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java index 185226b28..e8f552d6a 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * 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 @@ -20,25 +20,24 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; -import jakarta.validation.constraints.DecimalMax -import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.DecimalMax; +import jakarta.validation.constraints.DecimalMin; /** * The workload to simulate for a scenario. */ -public data class Workload(val trace: Trace, val samplingFraction: Double) { +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 data class Spec( - val trace: String, - @DecimalMin(value = "0.001", message = "Sampling fraction must be non-zero") - @DecimalMax(value = "1", message = "Sampling fraction cannot exceed one") - val samplingFraction: Double - ) + 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/kotlin/org/opendc/web/proto/runner/Job.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java similarity index 68% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Job.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java index 4f21f0bbe..587fe4518 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Job.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,32 +20,32 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +package org.opendc.web.proto.runner; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.JobState -import java.time.Instant +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 data class Job( - val id: Long, - val scenario: Scenario, - val state: JobState, - val createdAt: Instant, - val updatedAt: Instant, - val runtime: Int, - val results: Map? = null -) { +public record Job( + long id, + Scenario scenario, + JobState state, + Instant createdAt, + Instant updatedAt, + int runtime, + Map results) { /** * A request to update the state of a job. * - * @property state The next state of the job. - * @property runtime The runtime of the job (in seconds). - * @property results The results of the 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 data class Update(val state: JobState, val runtime: Int, val results: Map? = null) + public record Update(JobState state, int runtime, Map 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 000000000..33b520a0d --- /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 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/kotlin/org/opendc/web/proto/runner/Portfolio.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java similarity index 81% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java index 5faad5b3f..44f0b500f 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/java/org/opendc/web/proto/runner/Portfolio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,14 +20,13 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +package org.opendc.web.proto.runner; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Targets -import org.opendc.web.proto.user.Portfolio +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.Targets; /** - * A [Portfolio] as seen from the runner's perspective. + * 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. @@ -35,9 +34,4 @@ * @param targets The targets of the portfolio. */ @Schema(name = "Runner.Portfolio") -public data class Portfolio( - val id: Long, - val number: Int, - val name: String, - val targets: Targets -) +public record Portfolio(long id, int number, String name, Targets targets) {} 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/java/org/opendc/web/proto/runner/Scenario.java similarity index 72% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java index aeffc4d7b..8005ac3bd 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/java/org/opendc/web/proto/runner/Scenario.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,23 +20,22 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +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 +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.OperationalPhenomena; +import org.opendc.web.proto.Workload; /** - * A [Scenario] that is exposed to an OpenDC runner. + * A {@link Scenario} that is exposed to an OpenDC runner. */ @Schema(name = "Runner.Scenario") -public data class Scenario( - val id: Long, - val number: Int, - val portfolio: Portfolio, - val name: String, - val workload: Workload, - val topology: Topology, - val phenomena: OperationalPhenomena, - val schedulerName: String -) +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/kotlin/org/opendc/web/proto/runner/Topology.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java similarity index 80% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java index bc185aead..fdabd12df 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/java/org/opendc/web/proto/runner/Topology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,21 +20,15 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +package org.opendc.web.proto.runner; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Room -import java.time.Instant +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 data class Topology( - val id: Long, - val number: Int, - val name: String, - val rooms: List, - val createdAt: Instant, - val updatedAt: Instant -) +public record Topology(long id, int number, String name, List 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 000000000..ec78f2490 --- /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 cpus, + List gpus, + @JsonProperty("memories") List memory, + @JsonProperty("storages") List storage, + String rackId) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/MemoryUnit.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java similarity index 82% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/MemoryUnit.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java index 1fc604fad..a53b584a8 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/MemoryUnit.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * 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 @@ -20,15 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; /** * A memory unit in a system. */ -public data class MemoryUnit( - val id: String, - val name: String, - val speedMbPerS: Double, - val sizeMb: Double, - val energyConsumptionW: Double -) +public record MemoryUnit(String id, String name, double speedMbPerS, double sizeMb, double energyConsumptionW) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProcessingUnit.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java similarity index 82% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProcessingUnit.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java index 5f79d1bd6..baa61aace 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProcessingUnit.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * 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 @@ -20,15 +20,10 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; /** * A CPU model. */ -public data class ProcessingUnit( - val id: String, - val name: String, - val clockRateMhz: Double, - val numberOfCores: Int, - val energyConsumptionW: Double -) +public record ProcessingUnit( + String id, String name, double clockRateMhz, int numberOfCores, double energyConsumptionW) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Rack.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java similarity index 83% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Rack.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java index 131aa1846..b68fddd3d 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Rack.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,15 +20,11 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; + +import java.util.List; /** * A rack in a datacenter. */ -public data class Rack( - val id: String, - val name: String, - val capacity: Int, - val powerCapacityW: Double, - val machines: List -) +public record Rack(String id, String name, int capacity, double powerCapacityW, List machines) {} 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/java/org/opendc/web/proto/topology/Room.java similarity index 84% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java index c54991501..530d21f5c 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,14 +20,11 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; + +import java.util.Set; /** * A room in a datacenter. */ -public data class Room( - val id: String, - val name: String, - val tiles: Set, - val topologyId: String? = null -) +public record Room(String id, String name, Set 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 000000000..a72405413 --- /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 000000000..480efdad9 --- /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}. + *

+ * This entity is exposed in the runner-facing API via {@link Job}. + */ +public record Job(long id, JobState state, Instant createdAt, Instant updatedAt, Map results) {} 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/java/org/opendc/web/proto/user/Portfolio.java similarity index 75% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java index ceca79cc5..ff8d9e82c 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/java/org/opendc/web/proto/user/Portfolio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,11 +20,12 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Targets -import jakarta.validation.constraints.NotBlank +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. @@ -36,23 +37,13 @@ * @param targets The targets of the portfolio. * @param scenarios The scenarios in the portfolio. */ -public data class Portfolio( - val id: Long, - val number: Int, - val project: Project, - val name: String, - val targets: Targets, - val scenarios: List -) { +public record Portfolio( + long id, int number, Project project, String name, Targets targets, List scenarios) { /** * A request to create a new portfolio. */ @Schema(name = "Portfolio.Update") - public data class Create( - @field:NotBlank(message = "Name must not be empty") - val name: String, - val targets: Targets - ) + public record Create(@NotBlank(message = "Name must not be empty") String name, Targets targets) {} /** * A summary view of a [Portfolio] provided for nested relations. @@ -63,10 +54,5 @@ public data class Create( * @param targets The targets of the portfolio. */ @Schema(name = "Portfolio.Summary") - public data class Summary( - val id: Long, - val number: Int, - val name: String, - val targets: Targets - ) + public record Summary(long id, int number, String name, Targets targets) {} } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Project.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java similarity index 77% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Project.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java index c2a551bef..534fdb266 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Project.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,25 +20,19 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import java.time.Instant -import jakarta.validation.constraints.NotBlank +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 data class Project( - val id: Long, - val name: String, - val createdAt: Instant, - val updatedAt: Instant, - val role: ProjectRole -) { +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 data class Create(@field:NotBlank(message = "Name must not be empty") val name: String) + public record Create(@NotBlank(message = "Name must not be empty") String name) {} } 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/java/org/opendc/web/proto/user/ProjectRole.java similarity index 92% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java index ea6a30abc..3d3ba5068 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/java/org/opendc/web/proto/user/ProjectRole.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,12 +20,12 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; /** * The role of a user in a project. */ -public enum class ProjectRole { +public enum ProjectRole { /** * The user is allowed to view the project. */ 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/java/org/opendc/web/proto/user/Scenario.java similarity index 64% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java index bf59bbbb8..7add5656d 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/java/org/opendc/web/proto/user/Scenario.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,28 +20,28 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.OperationalPhenomena -import org.opendc.web.proto.Workload -import jakarta.validation.constraints.NotBlank +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 data class Scenario( - val id: Long, - val number: Int, - val project: Project, - val portfolio: Portfolio.Summary, - val name: String, - val workload: Workload, - val topology: Topology.Summary, - val phenomena: OperationalPhenomena, - val schedulerName: String, - val jobs: List -) { +public record Scenario( + long id, + int number, + Project project, + Portfolio.Summary portfolio, + String name, + Workload workload, + Topology.Summary topology, + OperationalPhenomena phenomena, + String schedulerName, + List jobs) { /** * Create a new scenario. * @@ -52,14 +52,12 @@ public data class Scenario( * @param schedulerName The name of the scheduler. */ @Schema(name = "Scenario.Create") - public data class Create( - @field:NotBlank(message = "Name must not be empty") - val name: String, - val workload: Workload.Spec, - val topology: Long, - val phenomena: OperationalPhenomena, - val schedulerName: String - ) + 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. @@ -70,17 +68,16 @@ public data class Create( * @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 job The simulation job associated with the scenario. + * @param jobs The simulation jobs associated with the scenario. */ @Schema(name = "Scenario.Summary") - public data class Summary( - val id: Long, - val number: Int, - val name: String, - val workload: Workload, - val topology: Topology.Summary, - val phenomena: OperationalPhenomena, - val schedulerName: String, - val jobs: List - ) + public record Summary( + long id, + int number, + String name, + Workload workload, + Topology.Summary topology, + OperationalPhenomena phenomena, + String schedulerName, + List jobs) {} } 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/java/org/opendc/web/proto/user/Topology.java similarity index 70% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java index 958e2a440..7291c77bc 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/java/org/opendc/web/proto/user/Topology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,40 +20,30 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Room -import java.time.Instant -import jakarta.validation.constraints.NotBlank +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 data class Topology( - val id: Long, - val number: Int, - val project: Project, - val name: String, - val rooms: List, - val createdAt: Instant, - val updatedAt: Instant -) { +public record Topology( + long id, int number, Project project, String name, List rooms, Instant createdAt, Instant updatedAt) { /** * Create a new topology for a project. */ @Schema(name = "Topology.Create") - public data class Create( - @field:NotBlank(message = "Name must not be empty") - val name: String, - val rooms: List - ) + public record Create(@NotBlank(message = "Name must not be empty") String name, List rooms) {} /** * Update an existing topology. */ @Schema(name = "Topology.Update") - public data class Update(val rooms: List) + public record Update(List rooms) {} /** * A summary view of a [Topology] provided for nested relations. @@ -65,11 +55,5 @@ public data class Update(val rooms: List) * @param updatedAt The instant at which the topology was updated. */ @Schema(name = "Topology.Summary") - public data class Summary( - val id: Long, - val number: Int, - val name: String, - val createdAt: Instant, - val updatedAt: Instant - ) + public record Summary(long id, int number, String name, Instant createdAt, Instant updatedAt) {} } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/User.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java similarity index 87% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/User.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java index f18cda617..030d92074 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/User.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,12 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; /** * A user of OpenDC. */ -public data class User( - val userId: String, - val accounting: UserAccounting -) +public record User(String userId, UserAccounting accounting) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/UserAccounting.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java similarity index 83% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/UserAccounting.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java index 2441983a5..3831381f5 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/UserAccounting.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * 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 @@ -20,15 +20,11 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import java.time.LocalDate +import java.time.LocalDate; /** * Accounting data for a user. */ -public data class UserAccounting( - val periodEnd: LocalDate, - val simulationTime: Int, - val simulationTimeBudget: Int -) +public record UserAccounting(LocalDate periodEnd, int simulationTime, int simulationTimeBudget) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Machine.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Machine.kt deleted file mode 100644 index f5c50cc3c..000000000 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Machine.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.proto - -import com.fasterxml.jackson.annotation.JsonProperty - -/** - * A machine in a rack. - */ -public data class Machine( - val id: String, - val position: Int, - val cpus: List = emptyList(), - val gpus: List = emptyList(), - @JsonProperty("memories") - val memory: List = emptyList(), - @JsonProperty("storages") - val storage: List = emptyList(), - val rackId: 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 deleted file mode 100644 index 53cb53cde..000000000 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.proto - -/** - * A room tile. - */ -public data class RoomTile( - val id: String, - val positionX: Double, - val positionY: Double, - val rack: Rack? = null, - val roomId: String? = null -) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Job.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Job.kt deleted file mode 100644 index de5f8de3b..000000000 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Job.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.proto.user - -import org.opendc.web.proto.JobState -import org.opendc.web.proto.runner.Job -import java.time.Instant - -/** - * A simulation job that is associated with a [Scenario]. - * - * This entity is exposed in the runner-facing API via [Job]. - */ -public data class Job( - val id: Long, - val state: JobState, - val createdAt: Instant, - val updatedAt: Instant, - val results: Map? = null -) diff --git a/opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml b/opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml new file mode 100644 index 000000000..e69de29bb diff --git a/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRecorder.java b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRecorder.java index 10bed219d..814ddf15e 100644 --- a/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRecorder.java +++ b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRecorder.java @@ -25,8 +25,8 @@ import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; -import java.io.File; import jakarta.enterprise.inject.spi.CDI; +import java.io.File; import org.jboss.logging.Logger; import org.opendc.web.runner.JobManager; import org.opendc.web.runner.OpenDCRunner; diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt index 5b1b71325..6b58cc001 100644 --- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt +++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt @@ -37,7 +37,7 @@ internal class JobManagerImpl(private val client: OpenDCRunnerClient) : JobManag override fun claim(id: Long): Boolean { return try { - client.jobs.update(id, Job.Update(JobState.CLAIMED, 0)) + client.jobs.update(id, Job.Update(JobState.CLAIMED, 0, null)) true } catch (e: IllegalStateException) { false @@ -45,15 +45,15 @@ internal class JobManagerImpl(private val client: OpenDCRunnerClient) : JobManag } override fun heartbeat(id: Long, runtime: Int): Boolean { - val res = client.jobs.update(id, Job.Update(JobState.RUNNING, runtime)) + val res = client.jobs.update(id, Job.Update(JobState.RUNNING, runtime, null)) return res?.state != JobState.FAILED } override fun fail(id: Long, runtime: Int) { - client.jobs.update(id, Job.Update(JobState.FAILED, runtime)) + client.jobs.update(id, Job.Update(JobState.FAILED, runtime, null)) } override fun finish(id: Long, runtime: Int, results: Map) { - client.jobs.update(id, Job.Update(JobState.FINISHED, runtime)) + client.jobs.update(id, Job.Update(JobState.FINISHED, runtime, results)) } } diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java index b41d1aeb0..ca5664488 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java @@ -38,7 +38,7 @@ import java.time.Instant; import java.util.List; import org.hibernate.annotations.Type; -import org.opendc.web.proto.Room; +import org.opendc.web.proto.topology.Room; /** * A datacenter design in OpenDC. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/MissingKotlinParameterExceptionMapper.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/MissingKotlinParameterExceptionMapper.java deleted file mode 100644 index 345acdfe7..000000000 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/MissingKotlinParameterExceptionMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.server.rest.error; - -import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.ext.ExceptionMapper; -import jakarta.ws.rs.ext.Provider; -import org.opendc.web.proto.ProtocolError; - -/** - * An [ExceptionMapper] for [MissingKotlinParameterException] thrown by Jackson. - */ -@Provider -public final class MissingKotlinParameterExceptionMapper implements ExceptionMapper { - @Override - public Response toResponse(MissingKotlinParameterException exception) { - return Response.status(Response.Status.BAD_REQUEST) - .entity(new ProtocolError( - Response.Status.BAD_REQUEST.getStatusCode(), - "Field " + exception.getParameter().getName() + " is missing from body.")) - .type(MediaType.APPLICATION_JSON) - .build(); - } -} diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java index 4dde8654e..2b7740820 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java @@ -98,7 +98,7 @@ public org.opendc.web.proto.runner.Job update( } try { - jobService.updateJob(job, update.getState(), update.getRuntime(), update.getResults()); + jobService.updateJob(job, update.state(), update.runtime(), update.results()); } catch (IllegalArgumentException e) { throw new WebApplicationException(e, 400); } catch (IllegalStateException e) { diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java index 2a3a40f47..e4d5362c9 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java @@ -100,7 +100,7 @@ public org.opendc.web.proto.user.Portfolio create( var project = auth.project; int number = project.allocatePortfolio(now); - Portfolio portfolio = new Portfolio(project, number, request.getName(), request.getTargets()); + Portfolio portfolio = new Portfolio(project, number, request.name(), request.targets()); project.portfolios.add(portfolio); portfolio.persist(); diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java index 789808c80..ea87a7ad4 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java @@ -118,12 +118,12 @@ public org.opendc.web.proto.user.Scenario create( throw new WebApplicationException("Portfolio not found", 404); } - Topology topology = Topology.findByProject(projectId, (int) request.getTopology()); + Topology topology = Topology.findByProject(projectId, (int) request.topology()); if (topology == null) { throw new WebApplicationException("Referred topology does not exist", 400); } - Trace trace = Trace.findById(request.getWorkload().getTrace()); + Trace trace = Trace.findById(request.workload().trace()); if (trace == null) { throw new WebApplicationException("Referred trace does not exist", 400); } @@ -136,14 +136,14 @@ public org.opendc.web.proto.user.Scenario create( project, portfolio, number, - request.getName(), - new Workload(trace, request.getWorkload().getSamplingFraction()), + request.name(), + new Workload(trace, request.workload().samplingFraction()), topology, - request.getPhenomena(), - request.getSchedulerName()); + request.phenomena(), + request.schedulerName()); scenario.persist(); - Job job = new Job(scenario, userId, now, portfolio.targets.getRepeats()); + Job job = new Job(scenario, userId, now, portfolio.targets.repeats()); job.persist(); // Fail the job if there is not enough budget for the simulation diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java index fe892985e..39903e4d2 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java @@ -79,7 +79,7 @@ public List getAll() { @Consumes("application/json") public org.opendc.web.proto.user.Project create(@Valid org.opendc.web.proto.user.Project.Create request) { Instant now = Instant.now(); - Project entity = new Project(request.getName(), now); + Project entity = new Project(request.name(), now); entity.persist(); ProjectAuthorization authorization = diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java index b8c542d3d..25819e325 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java @@ -104,7 +104,7 @@ public org.opendc.web.proto.user.Topology create( Project project = auth.project; int number = project.allocateTopology(now); - Topology topology = new Topology(project, number, request.getName(), now, request.getRooms()); + Topology topology = new Topology(project, number, request.name(), now, request.rooms()); project.topologies.add(topology); topology.persist(); @@ -164,7 +164,7 @@ public org.opendc.web.proto.user.Topology update( } entity.updatedAt = Instant.now(); - entity.rooms = request.getRooms(); + entity.rooms = request.rooms(); return UserProtocol.toDto(entity, auth); } diff --git a/opendc-web/opendc-web-server/src/test/java/org/opendc/web/server/service/UserAccountingServiceTest.java b/opendc-web/opendc-web-server/src/test/java/org/opendc/web/server/service/UserAccountingServiceTest.java index 91e3eb661..f4a8c9d69 100644 --- a/opendc-web/opendc-web-server/src/test/java/org/opendc/web/server/service/UserAccountingServiceTest.java +++ b/opendc-web/opendc-web-server/src/test/java/org/opendc/web/server/service/UserAccountingServiceTest.java @@ -68,8 +68,8 @@ public void testGetUserDoesNotExist() { var accounting = service.getAccounting(userId); - assertTrue(accounting.getPeriodEnd().isAfter(LocalDate.now())); - assertEquals(0, accounting.getSimulationTime()); + assertTrue(accounting.periodEnd().isAfter(LocalDate.now())); + assertEquals(0, accounting.simulationTime()); } @Test @@ -85,9 +85,9 @@ public void testGetUserDoesExist() { var accounting = service.getAccounting(userId); assertAll( - () -> assertEquals(periodEnd, accounting.getPeriodEnd()), - () -> assertEquals(32, accounting.getSimulationTime()), - () -> assertEquals(3600, accounting.getSimulationTimeBudget())); + () -> assertEquals(periodEnd, accounting.periodEnd()), + () -> assertEquals(32, accounting.simulationTime()), + () -> assertEquals(3600, accounting.simulationTimeBudget())); } @Test