summaryrefslogtreecommitdiff
path: root/opendc
diff options
context:
space:
mode:
Diffstat (limited to 'opendc')
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/Server.kt10
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/EmptyImage.kt7
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt12
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/Image.kt8
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt8
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt2
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorImage.kt10
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt3
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt3
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt3
-rw-r--r--opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/Resource.kt37
-rw-r--r--opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainer.kt62
-rw-r--r--opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainerImpl.kt51
-rw-r--r--opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagKey.kt30
-rw-r--r--opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/gwf/GwfTraceReader.kt3
-rw-r--r--opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt6
16 files changed, 233 insertions, 22 deletions
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/Server.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/Server.kt
index 60340286..cb11cfc7 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/Server.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/Server.kt
@@ -25,7 +25,8 @@
package com.atlarge.opendc.compute.core
import com.atlarge.opendc.compute.core.image.Image
-import com.atlarge.opendc.core.Identity
+import com.atlarge.opendc.core.resource.Resource
+import com.atlarge.opendc.core.resource.TagContainer
import com.atlarge.opendc.core.services.ServiceRegistry
import com.atlarge.opendc.core.services.ServiceRegistryImpl
import java.util.UUID
@@ -45,6 +46,11 @@ public data class Server(
public override val name: String,
/**
+ * The tags of this server.
+ */
+ public override val tags: TagContainer,
+
+ /**
* The hardware configuration of the server.
*/
public val flavor: ServerFlavor,
@@ -63,7 +69,7 @@ public data class Server(
* The services published by this server.
*/
public val serviceRegistry: ServiceRegistry = ServiceRegistryImpl()
-) : Identity {
+) : Resource {
override fun hashCode(): Int = uid.hashCode()
override fun equals(other: Any?): Boolean = other is Server && uid == other.uid
}
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/EmptyImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/EmptyImage.kt
index a51e55f9..6e6b8100 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/EmptyImage.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/EmptyImage.kt
@@ -25,12 +25,17 @@
package com.atlarge.opendc.compute.core.image
import com.atlarge.opendc.compute.core.execution.ServerContext
+import com.atlarge.opendc.core.resource.TagContainer
+import com.atlarge.opendc.core.resource.TagContainerImpl
+import java.util.UUID
/**
* An empty boot disk [Image] that exits immediately on start.
*/
object EmptyImage : Image {
- override val details: Map<String, Any> = emptyMap()
+ override val uid: UUID = UUID.randomUUID()
+ override val name: String = "empty"
+ override val tags: TagContainer = TagContainerImpl()
override suspend fun invoke(ctx: ServerContext) {}
}
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt
index 216a62a2..4af7c706 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt
@@ -25,22 +25,28 @@
package com.atlarge.opendc.compute.core.image
import com.atlarge.opendc.compute.core.execution.ServerContext
+import com.atlarge.opendc.core.resource.TagContainer
+import java.util.UUID
import kotlin.math.min
/**
* An application [Image] that models applications performing a static number of floating point operations ([flops]) on
* a compute resource.
*
+ * @property uid The unique identifier of this image.
+ * @property name The name of this image.
+ * @property tags The tags attached to the image.
* @property flops The number of floating point operations to perform for this task.
* @property cores The number of cores that the image is able to utilize.
* @property utilization A model of the CPU utilization of the application.
- * @property details The details of this image.
*/
class FlopsApplicationImage(
+ public override val uid: UUID,
+ public override val name: String,
+ public override val tags: TagContainer,
public val flops: Long,
public val cores: Int,
- public val utilization: Double = 0.8,
- public override val details: Map<String, Any> = emptyMap()
+ public val utilization: Double = 0.8
) : Image {
init {
require(flops >= 0) { "Negative number of flops" }
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/Image.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/Image.kt
index ff922aa9..52d4d7b5 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/Image.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/Image.kt
@@ -25,6 +25,7 @@
package com.atlarge.opendc.compute.core.image
import com.atlarge.opendc.compute.core.execution.ServerContext
+import com.atlarge.opendc.core.resource.Resource
/**
* An image containing a bootable operating system that can directly be executed by physical or virtual server.
@@ -34,12 +35,7 @@ import com.atlarge.opendc.compute.core.execution.ServerContext
* useful for backup purposes or for producing “gold” server images if you plan to deploy a particular server
* configuration frequently.
*/
-public interface Image {
- /**
- * The details of the image in key/value pairs.
- */
- public val details: Map<String, Any>
-
+public interface Image : Resource {
/**
* Launch the machine image in the specified [ServerContext].
*
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt
index 82aa28e4..be24aa00 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt
@@ -1,16 +1,20 @@
package com.atlarge.opendc.compute.core.image
import com.atlarge.opendc.compute.core.execution.ServerContext
+import com.atlarge.opendc.core.resource.TagContainer
import kotlinx.coroutines.delay
+import java.util.UUID
import kotlin.math.ceil
import kotlin.math.min
public val VM_SCHEDULING_SLICE_DURATION = 5 * 60 * 1000L
class VmImage(
+ public override val uid: UUID,
+ public override val name: String,
+ public override val tags: TagContainer,
public val flopsHistory: List<FlopsHistoryFragment>,
- public val cores: Int,
- public override val details: Map<String, Any> = emptyMap()
+ public val cores: Int
) : Image {
override suspend fun invoke(ctx: ServerContext) {
flopsHistory.forEach { fragment ->
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt
index 1dde8286..a0bb82fe 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt
@@ -34,6 +34,7 @@ import com.atlarge.opendc.compute.core.image.Image
import com.atlarge.opendc.compute.core.monitor.ServerMonitor
import com.atlarge.opendc.compute.metal.Node
import com.atlarge.opendc.compute.metal.PowerState
+import com.atlarge.opendc.core.resource.TagContainerImpl
import kotlinx.coroutines.delay
import java.util.UUID
import kotlin.math.max
@@ -72,6 +73,7 @@ public class SimpleBareMetalDriver(
PowerState.POWER_OFF to PowerState.POWER_ON -> Server(
UUID.randomUUID(),
node.name,
+ TagContainerImpl(),
flavor,
node.image,
ServerState.BUILD
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorImage.kt
index 4f482ab7..8bc9dc0c 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorImage.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorImage.kt
@@ -30,15 +30,21 @@ import com.atlarge.opendc.compute.core.image.Image
import com.atlarge.opendc.compute.virt.driver.SimpleVirtDriver
import com.atlarge.opendc.compute.virt.driver.VirtDriver
import com.atlarge.opendc.compute.virt.monitor.HypervisorMonitor
+import com.atlarge.opendc.core.resource.TagContainer
+import com.atlarge.opendc.core.resource.TagContainerImpl
import kotlinx.coroutines.suspendCancellableCoroutine
+import java.util.UUID
/**
* A hypervisor managing the VMs of a node.
*/
class HypervisorImage(
- private val hypervisorMonitor: HypervisorMonitor,
- public override val details: Map<String, Any> = emptyMap()
+ private val hypervisorMonitor: HypervisorMonitor
) : Image {
+ override val uid: UUID = UUID.randomUUID()
+ override val name: String = "esxi"
+ override val tags: TagContainer = TagContainerImpl()
+
override suspend fun invoke(ctx: ServerContext) {
val driver = SimpleVirtDriver(processContext, ctx, hypervisorMonitor)
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt
index cc24b49f..4e7c4eb3 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt
@@ -12,6 +12,7 @@ import com.atlarge.opendc.compute.core.image.VM_SCHEDULING_SLICE_DURATION
import com.atlarge.opendc.compute.core.monitor.ServerMonitor
import com.atlarge.opendc.compute.virt.RunRequest
import com.atlarge.opendc.compute.virt.monitor.HypervisorMonitor
+import com.atlarge.opendc.core.resource.TagContainerImpl
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.channels.Channel
@@ -73,7 +74,7 @@ class SimpleVirtDriver(
}
override suspend fun spawn(image: Image, monitor: ServerMonitor, flavor: ServerFlavor): Server {
- val server = Server(UUID.randomUUID(), "<unnamed>", flavor, image, ServerState.BUILD)
+ val server = Server(UUID.randomUUID(), "<unnamed>", TagContainerImpl(), flavor, image, ServerState.BUILD)
val context = VmServerContext(server, monitor, flavor, hostContext, Channel(Channel.CONFLATED))
serverContexts.add(context)
context.init()
diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
index 80ad18c5..88212abf 100644
--- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
+++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt
@@ -32,6 +32,7 @@ import com.atlarge.opendc.compute.core.ServerState
import com.atlarge.opendc.compute.core.image.FlopsApplicationImage
import com.atlarge.opendc.compute.core.monitor.ServerMonitor
import com.atlarge.opendc.compute.metal.PowerState
+import com.atlarge.opendc.core.resource.TagContainerImpl
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
@@ -47,7 +48,7 @@ internal class SimpleBareMetalDriverTest {
val provider = ServiceLoader.load(SimulationEngineProvider::class.java).first()
val system = provider({ _ ->
val flavor = ServerFlavor(listOf(ProcessingUnit("Intel", "Xeon", "amd64", 2300.0, 4)))
- val image = FlopsApplicationImage(1000, 2)
+ val image = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", TagContainerImpl(), 1000, 2)
val monitor = object : ServerMonitor {
override suspend fun onUpdate(server: Server, previousState: ServerState) {
println(server)
diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt
index 9c5f97aa..63305cbd 100644
--- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt
+++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt
@@ -32,6 +32,7 @@ import com.atlarge.opendc.compute.core.ServerState
import com.atlarge.opendc.compute.core.image.FlopsApplicationImage
import com.atlarge.opendc.compute.core.monitor.ServerMonitor
import com.atlarge.opendc.compute.metal.driver.SimpleBareMetalDriver
+import com.atlarge.opendc.core.resource.TagContainerImpl
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Test
@@ -50,7 +51,7 @@ internal class SimpleProvisioningServiceTest {
val provider = ServiceLoader.load(SimulationEngineProvider::class.java).first()
val system = provider({ _ ->
val flavor = ServerFlavor(listOf(ProcessingUnit("Intel", "Xeon", "amd64", 2300.0, 4)))
- val image = FlopsApplicationImage(1000, 2)
+ val image = FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", TagContainerImpl(), 1000, 2)
val monitor = object : ServerMonitor {
override suspend fun onUpdate(server: Server, previousState: ServerState) {
println(server)
diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/Resource.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/Resource.kt
new file mode 100644
index 00000000..25a494bc
--- /dev/null
+++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/Resource.kt
@@ -0,0 +1,37 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 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.core.resource
+
+import com.atlarge.opendc.core.Identity
+
+/**
+ * Represents a generic cloud resource.
+ */
+public interface Resource : Identity {
+ /**
+ * The tags of this cloud resource.
+ */
+ public val tags: TagContainer
+}
diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainer.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainer.kt
new file mode 100644
index 00000000..4167cd20
--- /dev/null
+++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainer.kt
@@ -0,0 +1,62 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 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.core.resource
+
+/**
+ * An immutable map containing the tags of some resource.
+ */
+public interface TagContainer {
+ /**
+ * The keys in this container.
+ */
+ public val keys: Collection<TagKey<*>>
+
+ /**
+ * Determine if this container contains a tag with the specified [TagKey].
+ *
+ * @param key The key of the tag to check for.
+ * @return `true` if the tag is in the container, `false` otherwise.
+ */
+ public operator fun contains(key: TagKey<*>): Boolean
+
+ /**
+ * Obtain the tag with the specified [TagKey].
+ *
+ * @param key The key of the tag to obtain.
+ * @return The value of the tag.
+ * @throws IllegalArgumentException if the tag does not exists in the container.
+ */
+ public operator fun <T : Any> get(key: TagKey<T>): T
+
+ /**
+ * Return the result of associating the specified [value] with the specified [key] in this container.
+ */
+ public fun <T : Any> put(key: TagKey<T>, value: T): TagContainer
+
+ /**
+ * Return the result of removing the specified [key] and its corresponding value from this container.
+ */
+ public fun remove(key: TagKey<*>): TagContainer
+}
diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainerImpl.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainerImpl.kt
new file mode 100644
index 00000000..1acc7de4
--- /dev/null
+++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainerImpl.kt
@@ -0,0 +1,51 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 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.core.resource
+
+/**
+ * Default implementation of [TagContainer] interface.
+ *
+ * @property map The internal map object to hold the tags.
+ */
+public class TagContainerImpl private constructor(private val map: Map<TagKey<*>, Any>) : TagContainer {
+ /**
+ * Construct an empty [TagContainerImpl].
+ */
+ public constructor() : this(emptyMap())
+
+ override val keys: Collection<TagKey<*>>
+ get() = map.keys
+
+ override fun contains(key: TagKey<*>): Boolean = map.contains(key)
+
+ override fun <T : Any> get(key: TagKey<T>): T {
+ @Suppress("UNCHECKED_CAST")
+ return map.getValue(key) as T
+ }
+
+ override fun <T : Any> put(key: TagKey<T>, value: T): TagContainer = TagContainerImpl(map.plus(key to value))
+
+ override fun remove(key: TagKey<*>): TagContainer = TagContainerImpl(map.minus(key))
+}
diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagKey.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagKey.kt
new file mode 100644
index 00000000..759f4461
--- /dev/null
+++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagKey.kt
@@ -0,0 +1,30 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 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.core.resource
+
+/**
+ * Represents a typed key for a resource tag with a unique name.
+ */
+public data class TagKey<T : Any>(val name: String)
diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/gwf/GwfTraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/gwf/GwfTraceReader.kt
index 33db78c9..6b721212 100644
--- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/gwf/GwfTraceReader.kt
+++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/gwf/GwfTraceReader.kt
@@ -26,6 +26,7 @@ package com.atlarge.opendc.format.trace.gwf
import com.atlarge.opendc.compute.core.image.FlopsApplicationImage
import com.atlarge.opendc.core.User
+import com.atlarge.opendc.core.resource.TagContainerImpl
import com.atlarge.opendc.format.trace.TraceEntry
import com.atlarge.opendc.format.trace.TraceReader
import com.atlarge.opendc.workflows.workload.Job
@@ -120,7 +121,7 @@ class GwfTraceReader(reader: BufferedReader) : TraceReader<Job> {
val workflow = entry.workload
val task = Task(
UUID(0L, taskId), "<unnamed>",
- FlopsApplicationImage(flops, cores),
+ FlopsApplicationImage(UUID.randomUUID(), "<unnamed>", TagContainerImpl(), flops, cores),
HashSet()
)
entry.submissionTime = min(entry.submissionTime, submitTime)
diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt
index b5c6ca0d..e8c8ac88 100644
--- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt
+++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt
@@ -28,6 +28,7 @@ import com.atlarge.opendc.compute.core.image.FlopsHistoryFragment
import com.atlarge.opendc.compute.core.image.VmImage
import com.atlarge.opendc.compute.core.workload.VmWorkload
import com.atlarge.opendc.core.User
+import com.atlarge.opendc.core.resource.TagContainerImpl
import com.atlarge.opendc.format.trace.TraceEntry
import com.atlarge.opendc.format.trace.TraceReader
import java.io.BufferedReader
@@ -108,9 +109,10 @@ class VmTraceReader(traceDirectory: File) : TraceReader<VmWorkload> {
}
}
+ val uuid = UUID(0L, vmId)
val vmWorkload = VmWorkload(
- UUID(0L, vmId), "<unnamed>", UnnamedUser,
- VmImage(flopsHistory, cores)
+ uuid, "<unnamed>", UnnamedUser,
+ VmImage(uuid, "<unnamed>", TagContainerImpl(), flopsHistory, cores)
)
entries[vmId] = TraceEntryImpl(
flopsHistory.firstOrNull()?.tick ?: -1,