Skip to content

Commit 6bf3b04

Browse files
committed
refactor(web): Migrate web proto to Java
This commit migrates the web protocol to Java and removes the dependency on Jandex Gradle.
1 parent 6858fc9 commit 6bf3b04

File tree

43 files changed

+354
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+354
-449
lines changed

buildSrc/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ dependencies {
3838
implementation(libs.jmh.gradle)
3939
implementation(libs.dokka.gradle)
4040

41-
implementation(libs.jandex.gradle)
4241
implementation(libs.quarkus.gradle.application)
4342
implementation(libs.quarkus.gradle.extension)
4443
}

buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
import org.gradle.api.artifacts.type.ArtifactTypeDefinition
2424
import org.gradle.api.attributes.Category
2525
import org.gradle.api.attributes.VerificationType
26-
import org.gradle.kotlin.dsl.dependencies
2726
import org.gradle.kotlin.dsl.get
28-
import org.gradle.kotlin.dsl.kotlin
29-
import org.gradle.kotlin.dsl.withType
3027

3128
plugins {
3229
id("java-conventions")
@@ -48,15 +45,13 @@ configurations.create("coverageDataElementsForQuarkus") {
4845

4946
extendsFrom(configurations["implementation"], configurations["runtimeOnly"])
5047

51-
@Suppress("UnstableApiUsage")
5248
attributes {
5349
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class.java, Category.VERIFICATION))
5450
attribute(VerificationType.VERIFICATION_TYPE_ATTRIBUTE, objects.named(VerificationType::class.java, VerificationType.JACOCO_RESULTS))
5551
}
5652

5753
artifacts {
5854
add("coverageDataElementsForQuarkus", layout.buildDirectory.file("jacoco-quarkus.exec")) {
59-
@Suppress("UnstableApiUsage")
6055
type = ArtifactTypeDefinition.BINARY_DATA_TYPE
6156
builtBy(tasks.test)
6257
}

gradle/libs.versions.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ dokka = "1.9.10"
66
hadoop = "3.3.6"
77
hypersistence-utils = "3.6.0"
88
jackson = "2.15.3"
9-
jandex-gradle = "1.1.0"
109
java = "17"
1110
jline = "3.23.0"
1211
jmh-gradle = "0.7.1"
1312
jakarta-validation = "3.0.2"
13+
jakarta-ws-rs = "3.1.0"
1414
junit-jupiter = "5.10.0"
1515
kotlin = "1.9.10"
1616
kotlin-logging = "3.0.5"
1717
kotlinx-coroutines = "1.7.3"
1818
log4j = "2.21.0"
19+
microprofile-rest-client = "3.0.1"
1920
microprofile-openapi = "3.1.1"
2021
microprofile-config = "3.1"
2122
mockk = "1.13.8"
@@ -100,14 +101,15 @@ jline = { module = "org.jline:jline", version.ref = "jline" }
100101

101102
# Other
102103
jakarta-validation = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation" }
104+
jakarta-ws-rs-api = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version.ref = "jakarta-ws-rs" }
103105
hadoop-common = { module = "org.apache.hadoop:hadoop-common", version.ref = "hadoop" }
104106
hadoop-mapreduce-client-core = { module = "org.apache.hadoop:hadoop-mapreduce-client-core", version.ref = "hadoop" }
105107
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
108+
microprofile-rest-client-api = { module = "org.eclipse.microprofile.rest.client:microprofile-rest-client-api", version.ref = "microprofile-rest-client" }
106109
microprofile-openapi-api = { module = "org.eclipse.microprofile.openapi:microprofile-openapi-api", version.ref = "microprofile-openapi" }
107110
microprofile-config = { module = "org.eclipse.microprofile.config:microprofile-config-api", version.ref = "microprofile-config" }
108111

109112
# Other (Build)
110113
dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
111-
jandex-gradle = { module = "org.kordamp.gradle:jandex-gradle-plugin", version.ref = "jandex-gradle" }
112114
jmh-gradle = { module = "me.champeau.jmh:jmh-gradle-plugin", version.ref = "jmh-gradle" }
113115
spotless-gradle = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }

opendc-web/opendc-web-proto/build.gradle.kts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@ description = "Web communication protocol for OpenDC"
2424

2525
/* Build configuration */
2626
plugins {
27-
`kotlin-library-conventions`
28-
id("org.kordamp.gradle.jandex") // Necessary for Quarkus to process annotations
27+
`java-library-conventions`
2928
}
3029

3130
dependencies {
3231
implementation(libs.jackson.annotations)
3332
implementation(libs.jakarta.validation)
33+
implementation(libs.jakarta.ws.rs.api)
34+
implementation(libs.microprofile.rest.client.api)
3435
implementation(libs.microprofile.openapi.api)
3536
}
36-
37-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
38-
kotlinOptions.javaParameters = true
39-
}

opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt renamed to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 AtLarge Research
2+
* Copyright (c) 2023 AtLarge Research
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,12 +20,12 @@
2020
* SOFTWARE.
2121
*/
2222

23-
package org.opendc.web.proto
23+
package org.opendc.web.proto;
2424

2525
/**
2626
* State of a scenario for the simulator runner.
2727
*/
28-
public enum class JobState {
28+
public enum JobState {
2929
/**
3030
* The job is pending to be claimed by a runner.
3131
*/
@@ -49,5 +49,5 @@ public enum class JobState {
4949
/**
5050
* The job has failed.
5151
*/
52-
FAILED;
52+
FAILED
5353
}

opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt renamed to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 AtLarge Research
2+
* Copyright (c) 2023 AtLarge Research
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,12 +20,9 @@
2020
* SOFTWARE.
2121
*/
2222

23-
package org.opendc.web.proto
23+
package org.opendc.web.proto;
2424

2525
/**
2626
* Object describing the enabled operational phenomena for a scenario.
2727
*/
28-
public data class OperationalPhenomena(
29-
val failures: Boolean,
30-
val interference: Boolean
31-
)
28+
public record OperationalPhenomena(boolean failures, boolean interference) {}

opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt renamed to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 AtLarge Research
2+
* Copyright (c) 2023 AtLarge Research
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,9 +20,9 @@
2020
* SOFTWARE.
2121
*/
2222

23-
package org.opendc.web.proto
23+
package org.opendc.web.proto;
2424

2525
/**
2626
* Container for reporting errors.
2727
*/
28-
public data class ProtocolError(val code: Int, val message: String)
28+
public record ProtocolError(int code, String message) {}

opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt renamed to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 AtLarge Research
2+
* Copyright (c) 2023 AtLarge Research
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,18 +20,15 @@
2020
* SOFTWARE.
2121
*/
2222

23-
package org.opendc.web.proto
23+
package org.opendc.web.proto;
2424

25-
import jakarta.validation.constraints.Min
25+
import jakarta.validation.constraints.Min;
26+
import java.util.Set;
2627

2728
/**
2829
* The targets of a portfolio.
2930
*
3031
* @param metrics The selected metrics to track during simulation.
3132
* @param repeats The number of repetitions per scenario.
3233
*/
33-
public data class Targets(
34-
val metrics: Set<String>,
35-
@field:Min(1)
36-
val repeats: Int = 1
37-
)
34+
public record Targets(Set<String> metrics, @Min(1) int repeats) {}

opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt renamed to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 AtLarge Research
2+
* Copyright (c) 2023 AtLarge Research
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,7 +20,7 @@
2020
* SOFTWARE.
2121
*/
2222

23-
package org.opendc.web.proto
23+
package org.opendc.web.proto;
2424

2525
/**
2626
* A workload trace available for simulation.
@@ -29,8 +29,4 @@
2929
* @param name The name of the trace.
3030
* @param type The type of trace.
3131
*/
32-
public data class Trace(
33-
val id: String,
34-
val name: String,
35-
val type: String
36-
)
32+
public record Trace(String id, String name, String type) {}

opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt renamed to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 AtLarge Research
2+
* Copyright (c) 2023 AtLarge Research
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -20,25 +20,24 @@
2020
* SOFTWARE.
2121
*/
2222

23-
package org.opendc.web.proto
23+
package org.opendc.web.proto;
2424

25-
import jakarta.validation.constraints.DecimalMax
26-
import jakarta.validation.constraints.DecimalMin
25+
import jakarta.validation.constraints.DecimalMax;
26+
import jakarta.validation.constraints.DecimalMin;
2727

2828
/**
2929
* The workload to simulate for a scenario.
3030
*/
31-
public data class Workload(val trace: Trace, val samplingFraction: Double) {
31+
public record Workload(Trace trace, double samplingFraction) {
3232
/**
3333
* Specification for a workload.
3434
*
3535
* @param trace The unique identifier of the trace.
3636
* @param samplingFraction The fraction of the workload to sample.
3737
*/
38-
public data class Spec(
39-
val trace: String,
40-
@DecimalMin(value = "0.001", message = "Sampling fraction must be non-zero")
41-
@DecimalMax(value = "1", message = "Sampling fraction cannot exceed one")
42-
val samplingFraction: Double
43-
)
38+
public record Spec(
39+
String trace,
40+
@DecimalMin(value = "0.001", message = "Sampling fraction must be non-zero")
41+
@DecimalMax(value = "1", message = "Sampling fraction cannot exceed one")
42+
double samplingFraction) {}
4443
}

0 commit comments

Comments
 (0)