summaryrefslogtreecommitdiff
path: root/opendc-format-sc18
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-format-sc18')
-rw-r--r--opendc-format-sc18/build.gradle.kts50
-rw-r--r--opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Model.kt44
-rw-r--r--opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt95
3 files changed, 189 insertions, 0 deletions
diff --git a/opendc-format-sc18/build.gradle.kts b/opendc-format-sc18/build.gradle.kts
new file mode 100644
index 00000000..b656f4e3
--- /dev/null
+++ b/opendc-format-sc18/build.gradle.kts
@@ -0,0 +1,50 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018 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.
+ */
+
+/* Build configuration */
+apply(from = "../gradle/kotlin.gradle")
+plugins {
+ `java-library`
+}
+
+/* Project configuration */
+repositories {
+ jcenter()
+}
+
+val junitJupiterVersion: String by extra
+val junitPlatformVersion: String by extra
+
+dependencies {
+ api(project(":opendc-core"))
+ api(project(":opendc-format"))
+ api(project(":opendc-workflows"))
+ api("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.8")
+ implementation(kotlin("stdlib"))
+ implementation(kotlin("reflect"))
+
+ testImplementation("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
+ testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
+ testImplementation("org.junit.platform:junit-platform-launcher:$junitPlatformVersion")
+}
diff --git a/opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Model.kt b/opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Model.kt
new file mode 100644
index 00000000..4fbde269
--- /dev/null
+++ b/opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Model.kt
@@ -0,0 +1,44 @@
+package com.atlarge.opendc.format.environment.sc18
+
+import com.fasterxml.jackson.annotation.JsonSubTypes
+import com.fasterxml.jackson.annotation.JsonTypeInfo
+
+/**
+ * A datacenter setup.
+ *
+ * @property name The name of the setup.
+ * @property rooms The rooms in the datacenter.
+ */
+data class Setup(val name: String, val rooms: List<Room>)
+
+/**
+ * A room in a datacenter.
+ *
+ * @property type The type of room in the datacenter.
+ * @property objects The objects in the room.
+ */
+data class Room(val type: String, val objects: List<RoomObject>)
+
+/**
+ * An object in a [Room].
+ *
+ * @property type The type of the room object.
+ */
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
+@JsonSubTypes(value = [JsonSubTypes.Type(name = "RACK", value = RoomObject.Rack::class)])
+sealed class RoomObject(val type: String) {
+ /**
+ * A rack in a server room.
+ *
+ * @property machines The machines in the rack.
+ */
+ data class Rack(val machines: List<Machine>) : RoomObject("RACK")
+}
+
+/**
+ * A machine in the setup that consists of the specified CPU's represented as
+ * integer identifiers and ethernet speed.
+ *
+ * @property cpus The CPUs in the machine represented as integer identifiers.
+ */
+data class Machine(val cpus: List<Int>)
diff --git a/opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt b/opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt
new file mode 100644
index 00000000..40ed5a45
--- /dev/null
+++ b/opendc-format-sc18/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt
@@ -0,0 +1,95 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2019 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 com.atlarge.opendc.format.environment.sc18
+
+import com.atlarge.opendc.format.environment.EnvironmentReader
+import com.atlarge.opendc.model.Cluster
+import com.atlarge.opendc.model.Environment
+import com.atlarge.opendc.model.Platform
+import com.atlarge.opendc.model.Zone
+import com.atlarge.opendc.model.resources.compute.ProcessingElement
+import com.atlarge.opendc.model.resources.compute.ProcessingUnit
+import com.atlarge.opendc.model.resources.compute.host.Host
+import com.atlarge.opendc.model.resources.compute.scheduling.SpaceSharedMachineScheduler
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
+import com.fasterxml.jackson.module.kotlin.readValue
+import java.io.InputStream
+import java.util.UUID
+
+/**
+ * A parser for the JSON experiment setup files used for the SC18 paper: "A Reference Architecture for Datacenter
+ * Schedulers".
+ *
+ * @param input The input stream to read from.
+ * @param mapper The Jackson object mapper to use.
+ */
+class Sc18EnvironmentReader(input: InputStream, mapper: ObjectMapper = jacksonObjectMapper()) : EnvironmentReader {
+ /**
+ * The environment that was read from the file.
+ */
+ private val environment: Environment
+
+ init {
+ val setup = mapper.readValue<Setup>(input)
+ val clusters = setup.rooms.mapIndexed { i, room ->
+ var counter = 0
+ val hosts = room.objects.flatMap { roomObject ->
+ when (roomObject) {
+ is RoomObject.Rack -> {
+ roomObject.machines.map { machine ->
+ val cores = machine.cpus.flatMap { id ->
+ when (id) {
+ 1 -> List(4) { ProcessingElement(it, CPUS[0]) }
+ 2 -> List(2) { ProcessingElement(it, CPUS[1]) }
+ else -> throw IllegalArgumentException("The cpu id $id is not recognized")
+ }
+ }
+ Host(UUID.randomUUID(), "node-${counter++}", SpaceSharedMachineScheduler, cores)
+ }
+ }
+ }
+ }
+ Cluster(UUID.randomUUID(), "cluster-$i", hosts)
+ }
+
+ val platform = Platform(UUID.randomUUID(), "sc18-platform", listOf(
+ Zone(UUID.randomUUID(), "zone", emptySet(), clusters)
+ ))
+
+ environment = Environment(setup.name, null, listOf(platform))
+ }
+
+ override fun read(): Environment = environment
+
+ override fun close() {}
+
+ companion object {
+ val CPUS = arrayOf(
+ ProcessingUnit("Intel", 6, 6920, "Intel(R) Core(TM) i7-6920HQ CPU @ 4.10GHz", 4100.0, 1),
+ ProcessingUnit("Intel", 6, 6930, "Intel(R) Core(TM) i7-6920HQ CPU @ 3.50GHz", 3500.0, 1)
+ )
+ }
+}