summaryrefslogtreecommitdiff
path: root/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration')
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/ParallelizableConverter.kt62
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/SchedulerConverter.kt66
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Cpu.kt58
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Datacenter.kt66
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Experiment.kt60
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/ExperimentState.kt53
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Gpu.kt58
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Job.kt59
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Machine.kt45
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/MachineState.kt53
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Path.kt40
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Rack.kt52
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Room.kt50
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomObject.kt36
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomType.kt34
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Section.kt45
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Task.kt141
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/TaskState.kt49
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Trace.kt44
19 files changed, 1071 insertions, 0 deletions
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/ParallelizableConverter.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/ParallelizableConverter.kt
new file mode 100644
index 00000000..11d5836e
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/ParallelizableConverter.kt
@@ -0,0 +1,62 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.converter
+
+import javax.persistence.AttributeConverter
+
+/**
+ * An internal [AttributeConverter] that maps the values _PARALLEL_ and _SEQUENTIAL_ to a
+ * boolean value indicating whether a task is parallelizable.
+ *
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+class ParallelizableConverter : AttributeConverter<Boolean, String> {
+ /**
+ * Converts the data stored in the database column into the
+ * value to be stored in the entity attribute.
+ * Note that it is the responsibility of the converter writer to
+ * specify the correct dbData type for the corresponding column
+ * for use by the JDBC driver: i.e., persistence providers are
+ * not expected to do such type conversion.
+ *
+ * @param dbData the data from the database column to be converted
+ * @return the converted value to be stored in the entity attribute
+ */
+ override fun convertToEntityAttribute(dbData: String?): Boolean = when(dbData?.toUpperCase()) {
+ "SEQUENTIAL" -> false
+ "PARALLEL" -> true
+ else -> false
+ }
+
+ /**
+ * Converts the value stored in the entity attribute into the
+ * data representation to be stored in the database.
+ *
+ * @param attribute the entity attribute value to be converted
+ * @return the converted data to be stored in the database column
+ */
+ override fun convertToDatabaseColumn(attribute: Boolean?): String =
+ if (attribute == true) "PARALLEL" else "SEQUENTIAL"
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/SchedulerConverter.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/SchedulerConverter.kt
new file mode 100644
index 00000000..95027440
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/converter/SchedulerConverter.kt
@@ -0,0 +1,66 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.converter
+
+import nl.atlarge.opendc.platform.scheduler.FifoScheduler
+import nl.atlarge.opendc.platform.scheduler.Scheduler
+import nl.atlarge.opendc.platform.scheduler.SrtfScheduler
+import javax.persistence.AttributeConverter
+
+/**
+ * An internal [AttributeConverter] that maps a name of a scheduler to the actual scheduler implementation.
+ * The converter currently chooses between the following two schedulers:
+ * - [FifoScheduler] (default)
+ * - [SrtfScheduler]
+ *
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+class SchedulerConverter : AttributeConverter<Scheduler, String> {
+ /**
+ * Converts the data stored in the database column into the
+ * value to be stored in the entity attribute.
+ * Note that it is the responsibility of the converter writer to
+ * specify the correct dbData type for the corresponding column
+ * for use by the JDBC driver: i.e., persistence providers are
+ * not expected to do such type conversion.
+ *
+ * @param dbData the data from the database column to be converted
+ * @return the converted value to be stored in the entity attribute
+ */
+ override fun convertToEntityAttribute(dbData: String?): Scheduler = when(dbData?.toUpperCase()) {
+ "SRTF" -> SrtfScheduler()
+ else -> FifoScheduler()
+ }
+
+ /**
+ * Converts the value stored in the entity attribute into the
+ * data representation to be stored in the database.
+ *
+ * @param attribute the entity attribute value to be converted
+ * @return the converted data to be stored in the database column
+ */
+ override fun convertToDatabaseColumn(attribute: Scheduler?): String =
+ attribute?.name?.toUpperCase() ?: "FIFO"
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Cpu.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Cpu.kt
new file mode 100644
index 00000000..b775eb6e
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Cpu.kt
@@ -0,0 +1,58 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.topology.machine.Cpu
+import javax.persistence.Entity
+
+/**
+ * A cpu entity in the persistent schema.
+ *
+ * @property id The unique identifier of the cpu.
+ * @property manufacturer The manufacturer of the cpu.
+ * @property family The family of the cpu.
+ * @property generation The generation of the cpu.
+ * @property model The model of the cpu.
+ * @property clockRate The clock rate of the cpu.
+ * @property cores The amount of cores in the gpu.
+ * @property energyConsumption The energy consumption of the cpu in Watt.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Cpu(
+ val id: Int,
+ val manufacturer: String,
+ val family: String,
+ val generation: String,
+ val model: String,
+ override val clockRate: Int,
+ override val cores: Int,
+ override val energyConsumption: Double
+) : Cpu {
+ /**
+ * The initial state of the entity.
+ */
+ override val initialState = Unit
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Datacenter.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Datacenter.kt
new file mode 100644
index 00000000..26cf9706
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Datacenter.kt
@@ -0,0 +1,66 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.kernel.time.Duration
+import nl.atlarge.opendc.platform.scheduler.Scheduler
+import nl.atlarge.opendc.topology.container.Datacenter
+import javax.persistence.Entity
+
+/**
+ * A datacenter entity in the persistent schema.
+ *
+ * @property id The unique identifier of the datacenter.
+ * @property rooms The rooms in the datacenter.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Datacenter(
+ val id: Int,
+ val rooms: Set<Room>
+): Datacenter {
+ /**
+ * Construct a datacenter. We need this useless constructor in order for Kotlin correctly initialise the
+ * constant fields of the class.
+ */
+ private constructor() : this(-1, emptySet())
+
+ /**
+ * The task scheduler the datacenter uses.
+ */
+ override lateinit var scheduler: Scheduler
+ internal set
+
+ /**
+ * The interval at which task will be (re)scheduled.
+ * We set this to a fixed constant since the database provides no way of configuring this.
+ */
+ override val interval: Duration = 50
+
+ /**
+ * The initial state of the datacenter.
+ */
+ override val initialState = Unit
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Experiment.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Experiment.kt
new file mode 100644
index 00000000..0b352cb4
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Experiment.kt
@@ -0,0 +1,60 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.kernel.time.Instant
+import nl.atlarge.opendc.platform.Experiment
+import nl.atlarge.opendc.platform.scheduler.Scheduler
+import nl.atlarge.opendc.platform.workload.Trace
+import javax.persistence.Entity
+
+/**
+ * An experiment definition for the OpenDC database schema.
+ *
+ * @property id The identifier of the experiment.
+ * @property name The name of the experiment.
+ * @property scheduler The scheduler used in the experiment.
+ * @property trace The trace used for the simulation.
+ * @property path The path of the experiment.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Experiment(
+ val id: Int,
+ val name: String,
+ val scheduler: Scheduler,
+ val trace: Trace,
+ val path: Path
+) {
+ /**
+ * The state of the experiment.
+ */
+ var state: ExperimentState = ExperimentState.QUEUED
+
+ /**
+ * The last tick that has been simulated.
+ */
+ var last: Instant = 0
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/ExperimentState.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/ExperimentState.kt
new file mode 100644
index 00000000..96fc112c
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/ExperimentState.kt
@@ -0,0 +1,53 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+/**
+ * Enumerations of the states an [Experiment] can assume.
+ *
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+enum class ExperimentState {
+ /**
+ * This state indicates the experiment has been queued for simulation, but has not yet started.
+ */
+ QUEUED,
+
+ /**
+ * This state indicates the experiment has been claimed by a simulator for simulation, but
+ * not yet started.
+ */
+ CLAIMED,
+
+ /**
+ * This state indicates the experiment is currently in simulation.
+ */
+ SIMULATING,
+
+ /**
+ * This state indicates the experiment has finished simulating.
+ */
+ FINISHED,
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Gpu.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Gpu.kt
new file mode 100644
index 00000000..94625242
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Gpu.kt
@@ -0,0 +1,58 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.topology.machine.Gpu
+import javax.persistence.Entity
+
+/**
+ * A gpu entity in the persistent schema.
+ *
+ * @property id The unique identifier of the gpu.
+ * @property manufacturer The manufacturer of the gpu.
+ * @property family The family of the gpu.
+ * @property generation The generation of the gpu.
+ * @property model The model of the gpu.
+ * @property clockRate The clock rate of the gpu.
+ * @property cores The amount of cores in the gpu.
+ * @property energyConsumption The energy consumption of the gpu in Watt.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Gpu(
+ val id: Int,
+ val manufacturer: String,
+ val family: String,
+ val generation: String,
+ val model: String,
+ override val clockRate: Int,
+ override val cores: Int,
+ override val energyConsumption: Double
+) : Gpu {
+ /**
+ * The initial state of the entity.
+ */
+ override val initialState = Unit
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Job.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Job.kt
new file mode 100644
index 00000000..394cf478
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Job.kt
@@ -0,0 +1,59 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.platform.workload.Job
+import nl.atlarge.opendc.platform.workload.Task
+import nl.atlarge.opendc.platform.workload.User
+import javax.persistence.*
+
+/**
+ * A [Job] backed by the JPA API and an underlying database connection.
+ *
+ * @property id The unique identifier of the job.
+ * @property tasks The collection of tasks the job consists of.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Job(
+ override val id: Int,
+ override val tasks: Set<Task>
+) : Job {
+ /**
+ * The owner of the job, which is a singleton, since the database has no
+ * concept of ownership yet.
+ */
+ override val owner: User = object : User {
+ /**
+ * The unique identifier of the user.
+ */
+ override val id: Int = 0
+
+ /**
+ * The name of this user.
+ */
+ override val name: String = "admin"
+ }
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Machine.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Machine.kt
new file mode 100644
index 00000000..4071b342
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Machine.kt
@@ -0,0 +1,45 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.topology.machine.Machine
+import javax.persistence.Entity
+
+/**
+ * A machine entity in the persistent schema.
+ *
+ * @property id The unique identifier of the machine.
+ * @property position The position of the machine in the rack.
+ * @property cpus The CPUs in the machine.
+ * @property gpus The GPUs in the machine.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Machine(
+ val id: Int,
+ val position: Int,
+ val cpus: Set<Cpu>,
+ val gpus: Set<Gpu>
+): Machine()
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/MachineState.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/MachineState.kt
new file mode 100644
index 00000000..23efe888
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/MachineState.kt
@@ -0,0 +1,53 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.kernel.time.Instant
+import javax.persistence.Entity
+
+/**
+ * The state of a [Machine].
+ *
+ * @property id The unique identifier of the state.
+ * @property machine The machine of the state.
+ * @property task The task the machine has been assigned.
+ * @property experiment The experiment the machine is running in.
+ * @property time The current moment in time.
+ * @property temperature The temperature of the machine.
+ * @property memoryUsage The memory usage of the machine.
+ * @property load The load of the machine.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class MachineState(
+ val id: Int,
+ val machine: Machine,
+ val task: Task?,
+ val experiment: Experiment,
+ val time: Instant,
+ val temperature: Double,
+ val memoryUsage: Int,
+ val load: Double
+)
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Path.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Path.kt
new file mode 100644
index 00000000..ccf3b6e8
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Path.kt
@@ -0,0 +1,40 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import javax.persistence.Entity
+
+/**
+ * A [Path] holds all sections of the parent experiment.
+ *
+ * @property id The unique identifier of the path.
+ * @property sections The sections of the path.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+open class Path(
+ val id: Int,
+ val sections: List<Section>
+)
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Rack.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Rack.kt
new file mode 100644
index 00000000..2d2099a2
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Rack.kt
@@ -0,0 +1,52 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.topology.container.Rack
+import javax.persistence.Entity
+
+/**
+ * A rack entity in a room in the persistent schema.
+ *
+ * @property id The unique identifier of the rack.
+ * @property name The name of the rack.
+ * @property capacity The capacity of the rack in terms of units.
+ * @property powerCapacity The power capacity of the rack in Watt.
+ * @property machines The machines in the rack.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+class Rack(
+ id: Int,
+ val name: String,
+ val capacity: Int,
+ val powerCapacity: Int,
+ val machines: List<Machine>
+): RoomObject(id), Rack {
+ /**
+ * The initial state of the entity.
+ */
+ override val initialState = Unit
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Room.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Room.kt
new file mode 100644
index 00000000..f3b7ae06
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Room.kt
@@ -0,0 +1,50 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.topology.container.Room
+import javax.persistence.Entity
+
+/**
+ * A room entity in the persistent schema.
+ *
+ * @property id The unique identifier of the room.
+ * @property name The name of the room.
+ * @property type The type of the room.
+ * @property objects The objects in the room.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Room(
+ val id: Int,
+ val name: String,
+ val type: RoomType,
+ val objects: Set<RoomObject>
+): Room {
+ /**
+ * The initial state of the entity.
+ */
+ override val initialState = Unit
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomObject.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomObject.kt
new file mode 100644
index 00000000..0e9fb84f
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomObject.kt
@@ -0,0 +1,36 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import javax.persistence.Entity
+
+/**
+ * An object in a room.
+ *
+ * @property id The unique identifier of the room.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+abstract class RoomObject(val id: Int)
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomType.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomType.kt
new file mode 100644
index 00000000..5e138947
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/RoomType.kt
@@ -0,0 +1,34 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+/**
+ * This enumeration defines the room types available in the OpenDC frontend.
+ *
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+enum class RoomType {
+ COOLING, HALLWAY, OFFICE, POWER, SERVER
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Section.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Section.kt
new file mode 100644
index 00000000..e3b8c350
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Section.kt
@@ -0,0 +1,45 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.kernel.time.Instant
+import javax.persistence.Entity
+
+/**
+ * A [Section] holds a datacenter and the tick on which the parent experiment should
+ * switch to this section.
+ *
+ * @property id The unique identifier of the section.
+ * @property datacenter The datacenter of this section.
+ * @property startTime The position in time when the experiment should start using the
+ * topology of this section.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Section(
+ val id: Int,
+ val datacenter: Datacenter,
+ val startTime: Instant
+)
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Task.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Task.kt
new file mode 100644
index 00000000..500c7e99
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Task.kt
@@ -0,0 +1,141 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.kernel.Context
+import nl.atlarge.opendc.kernel.time.Instant
+import nl.atlarge.opendc.platform.workload.Task
+import nl.atlarge.opendc.topology.container.Datacenter
+import nl.atlarge.opendc.topology.machine.Machine
+import javax.persistence.*
+
+/**
+ * A [Task] backed by the JPA API and an underlying database connection.
+ *
+ * @property id The unique identifier of the job.
+ * @property flops The total amount of flops for the task.
+ * @property dependency A dependency on another task.
+ * @property parallelizable A flag to indicate the task is parallelizable.
+ * @property startTime The start time in the simulation.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Task(
+ override val id: Int,
+ override val flops: Long,
+ private val dependency: Task?,
+ override val parallelizable: Boolean,
+ val startTime: Instant
+) : Task {
+ /**
+ * The dependencies of the task.
+ */
+ override val dependencies: Set<Task>
+ get() {
+ if (_dependencies != null)
+ return _dependencies!!
+ _dependencies = dependency?.let(::setOf) ?: emptySet()
+ return _dependencies!!
+ }
+
+ /**
+ * The dependencies set cache.
+ */
+ private var _dependencies: Set<Task>? = null
+
+ /**
+ * The remaining amount of flops to compute.
+ */
+ override var remaining: Long
+ get() {
+ if (_remaining == null)
+ _remaining = flops
+ return _remaining!!
+ }
+ private set(value) { _remaining = value }
+ private var _remaining: Long? = -1
+
+ /**
+ * A flag to indicate the task has been accepted by the datacenter.
+ */
+ override var accepted: Boolean = false
+ private set
+
+ /**
+ * A flag to indicate the task has been started.
+ */
+ override var started: Boolean = false
+ private set
+
+ /**
+ * A flag to indicate whether the task is finished.
+ */
+ override var finished: Boolean = false
+ private set
+
+ /**
+ * Accept the task into the scheduling queue.
+ */
+ override fun Context<Datacenter>.accept() {
+ accepted = true
+ }
+
+ /**
+ * Start a task.
+ */
+ override fun Context<Machine>.start() {
+ started = true
+ }
+
+ /**
+ * Consume the given amount of flops of this task.
+ *
+ * @param flops The total amount of flops to consume.
+ */
+ override fun Context<Machine>.consume(flops: Long) {
+ if (finished)
+ return
+ if (remaining <= flops) {
+ remaining = 0
+ } else {
+ remaining -= flops
+ }
+ }
+
+ /**
+ * Finalise the task.
+ */
+ override fun Context<Machine>.finalize() {
+ finished = true
+ }
+
+ /**
+ * Reset the task.
+ */
+ internal fun reset() {
+ remaining = flops
+ finished = false
+ }
+}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/TaskState.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/TaskState.kt
new file mode 100644
index 00000000..14441752
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/TaskState.kt
@@ -0,0 +1,49 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.kernel.time.Instant
+import javax.persistence.Entity
+
+/**
+ * The state of a [Task].
+ *
+ * @property id The unique identifier of the state.
+ * @property task The task this is the state of.
+ * @property experiment The experiment the machine is running in.
+ * @property time The current moment in time.
+ * @property remaining The remaining flops for the task.
+ * @property cores The cores used for the task.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class TaskState(
+ val id: Int,
+ val task: Task,
+ val experiment: Experiment,
+ val time: Instant,
+ val remaining: Int,
+ val cores: Int
+)
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Trace.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Trace.kt
new file mode 100644
index 00000000..cd3d9348
--- /dev/null
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/integration/jpa/schema/Trace.kt
@@ -0,0 +1,44 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2017 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 nl.atlarge.opendc.integration.jpa.schema
+
+import nl.atlarge.opendc.platform.workload.Job
+import nl.atlarge.opendc.platform.workload.Trace
+import javax.persistence.Entity
+
+/**
+ * A [Trace] backed by the JPA API and an underlying database connection.
+ *
+ * @property id The unique identifier of the trace.
+ * @property name The name of the trace.
+ * @property jobs The collection of jobs for this trace.
+ * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl)
+ */
+@Entity
+data class Trace(
+ val id: Int,
+ val name: String,
+ override val jobs: Set<Job>
+) : Trace