summaryrefslogtreecommitdiff
path: root/opendc-format/src/main/kotlin/com
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2019-05-15 22:37:35 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2019-05-15 22:43:59 +0200
commit7c8a3fd217418c6f956a9315eb13c2a31a9f85a0 (patch)
treee10534cd58f4e2b9a568fbf14e56166fa7585863 /opendc-format/src/main/kotlin/com
parentb0b1577ace36022faec1a4ed0369f1c1271d5ccd (diff)
feat: Add initial version of OpenDC simulation model
This change adds the initial version of the port of the OpenDC simulation model to version 2.x of the simulator. The simulation model has been reworked to support immutability and event-driven simulation, with speed-ups up to 75x.
Diffstat (limited to 'opendc-format/src/main/kotlin/com')
-rw-r--r--opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/EnvironmentReader.kt38
-rw-r--r--opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceEntry.kt55
-rw-r--r--opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceReader.kt37
-rw-r--r--opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceWriter.kt46
4 files changed, 176 insertions, 0 deletions
diff --git a/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/EnvironmentReader.kt b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/EnvironmentReader.kt
new file mode 100644
index 00000000..0ba3ae25
--- /dev/null
+++ b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/EnvironmentReader.kt
@@ -0,0 +1,38 @@
+/*
+ * 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
+
+import com.atlarge.opendc.model.Environment
+import java.io.Closeable
+
+/**
+ * An interface for reading descriptions of datacenter environments into memory as [Environment].
+ */
+interface EnvironmentReader : Closeable {
+ /**
+ * Read the description of the datacenter environment as [Environment].
+ */
+ fun read(): Environment
+}
diff --git a/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceEntry.kt b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceEntry.kt
new file mode 100644
index 00000000..cf0ab526
--- /dev/null
+++ b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceEntry.kt
@@ -0,0 +1,55 @@
+/*
+ * 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.trace
+
+import com.atlarge.odcsim.Instant
+import com.atlarge.opendc.model.workload.Workload
+
+/**
+ * An entry in a workload trace.
+ *
+ * @param T The shape of the workload in this entry.
+ */
+interface TraceEntry<T : Workload> {
+ /**
+ * The time of submission of the workload.
+ */
+ val submissionTime: Instant
+
+ /**
+ * The workload in this trace entry.
+ */
+ val workload: T
+
+ /**
+ * Extract the submission time from this entry.
+ */
+ operator fun component1() = submissionTime
+
+ /**
+ * Extract the workload from this entry.
+ */
+ operator fun component2() = workload
+}
diff --git a/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceReader.kt b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceReader.kt
new file mode 100644
index 00000000..af8b272d
--- /dev/null
+++ b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceReader.kt
@@ -0,0 +1,37 @@
+/*
+ * 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.trace
+
+import com.atlarge.opendc.model.workload.Workload
+import java.io.Closeable
+
+/**
+ * An interface for reading [Workload]s into memory.
+ *
+ * This interface must guarantee that the entries are delivered in order of submission time.
+ *
+ * @param T The shape of the workloads supported by this reader.
+ */
+interface TraceReader<T : Workload> : Iterator<TraceEntry<T>>, Closeable
diff --git a/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceWriter.kt b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceWriter.kt
new file mode 100644
index 00000000..b5424fd2
--- /dev/null
+++ b/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/TraceWriter.kt
@@ -0,0 +1,46 @@
+/*
+ * 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.trace
+
+import com.atlarge.odcsim.Instant
+import com.atlarge.opendc.model.workload.Workload
+import java.io.Closeable
+
+/**
+ * An interface for persisting workload traces (e.g. to disk).
+ *
+ * @param T The type of [Workload] supported by this writer.
+ */
+interface TraceWriter<T : Workload> : Closeable {
+ /**
+ * Write an entry to the trace.
+ *
+ * Entries must be written in order of submission time. Failing to do so results in a [IllegalArgumentException].
+ *
+ * @param submissionTime The time of submission of the workload.
+ * @param workload The workload to write to the trace.
+ */
+ fun write(submissionTime: Instant, workload: T)
+}