diff options
Diffstat (limited to 'opendc-web/opendc-web-proto/src/main')
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt) | 8 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt) | 9 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt) | 6 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt) | 13 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt) | 10 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt) | 21 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Job.kt) | 36 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java | 60 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt) | 18 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt) | 31 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt) | 20 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java | 38 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/MemoryUnit.kt) | 12 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProcessingUnit.kt) | 13 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Rack.kt) | 14 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt) | 13 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java | 28 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java | 34 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt) | 34 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Project.kt) | 22 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt) | 6 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt) | 71 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt) | 40 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/User.kt) | 9 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java (renamed from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/UserAccounting.kt) | 12 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt | 34 | ||||
| -rw-r--r-- | opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml | 0 |
27 files changed, 324 insertions, 288 deletions
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 index a8e67ec5..14a0faba 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 index 28006d27..cf492e38 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 index e7fe2702..cb9324ea 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 index 25516ff0..4823bb66 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 @@ import jakarta.validation.constraints.Min * @param metrics The selected metrics to track during simulation. * @param repeats The number of repetitions per scenario. */ -public data class Targets( - val metrics: Set<String>, - @field:Min(1) - val repeats: Int = 1, -) +public record Targets(Set<String> 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 index 2952a273..adf916d3 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 @@ package org.opendc.web.proto * @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 index 58daf817..e8f552d6 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 index 34642436..587fe451 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<String, Any>? = null, -) { +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. * - * @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<String, Any>? = null) + 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/kotlin/org/opendc/web/proto/runner/Portfolio.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java index 916d8cf0..44f0b500 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 @@ import org.opendc.web.proto.user.Portfolio * @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 index ebc10bb0..8005ac3b 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 index 4bffdee9..fdabd12d 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<Room>, - val createdAt: Instant, - val updatedAt: Instant, -) +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/kotlin/org/opendc/web/proto/MemoryUnit.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java index 00560ad6..a53b584a 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 index 86f40516..baa61aac 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 index c997e814..b68fddd3 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<Machine>, -) +public record Rack(String id, String name, int capacity, double powerCapacityW, List<Machine> 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 index 5b305168..530d21f5 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<RoomTile>, - val topologyId: String? = null, -) +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/kotlin/org/opendc/web/proto/user/Portfolio.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java index 6f433a04..ff8d9e82 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 jakarta.validation.constraints.NotBlank -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Targets +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 @@ import org.opendc.web.proto.Targets * @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<Scenario.Summary>, -) { +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 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 Portfolio( * @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 index 635552a9..534fdb26 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,27 +20,19 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import jakarta.validation.constraints.NotBlank -import org.eclipse.microprofile.openapi.annotations.media.Schema -import java.time.Instant +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 index 0f6de1fc..434ab472 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 index e0c790f5..7add5656 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 jakarta.validation.constraints.NotBlank -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 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<Job>, -) { +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. * @@ -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 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 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<Job>, - ) + 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/kotlin/org/opendc/web/proto/user/Topology.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java index 0943eaf8..7291c77b 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 jakarta.validation.constraints.NotBlank -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Room -import java.time.Instant +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<Room>, - val createdAt: Instant, - val updatedAt: Instant, -) { +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 data class Create( - @field:NotBlank(message = "Name must not be empty") - val name: String, - val rooms: List<Room>, - ) + public record Create(@NotBlank(message = "Name must not be empty") String name, List<Room> rooms) {} /** * Update an existing topology. */ @Schema(name = "Topology.Update") - public data class Update(val rooms: List<Room>) + public record Update(List<Room> rooms) {} /** * A summary view of a [Topology] provided for nested relations. @@ -65,11 +55,5 @@ public data class Topology( * @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 index 33dad4ff..030d9207 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 index 970721eb..3831381f 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/RoomTile.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt deleted file mode 100644 index 666d66ee..00000000 --- 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/resources/META-INF/beans.xml b/opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml |
