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.kt6
-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.kt1
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorImage.kt9
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt2
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt2
-rw-r--r--opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/service/SimpleProvisioningServiceTest.kt2
-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.kt36
-rw-r--r--opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/gwf/GwfTraceReader.kt2
-rw-r--r--opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt5
14 files changed, 118 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..8f6c4682 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,16 @@
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
/**
* 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 = emptyMap()
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..827c1d38 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
@@ -72,6 +72,7 @@ public class SimpleBareMetalDriver(
PowerState.POWER_OFF to PowerState.POWER_ON -> Server(
UUID.randomUUID(),
node.name,
+ emptyMap(),
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..b66e04d2 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,20 @@ 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 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 = "vmm"
+ override val tags: TagContainer = emptyMap()
+
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..863626ad 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
@@ -73,7 +73,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>", emptyMap(), 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..05e943e2 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
@@ -47,7 +47,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>", emptyMap(), 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..a2112657 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
@@ -50,7 +50,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>", emptyMap(), 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..6ba1cf0b
--- /dev/null
+++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/resource/TagContainer.kt
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+typealias TagContainer = Map<String, Any>
+
+/**
+ * Obtain the value of the tag with the specified [key] of type [T]. If the tag does not exist or the tag is of
+ * different type, `null` is returned.
+ */
+inline fun <reified T : Any> TagContainer.typed(key: String): T? = this[key] as? T
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..498e2d1d 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
@@ -120,7 +120,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>", emptyMap(), 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..f4ed0f57 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
@@ -108,9 +108,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>", emptyMap(), flopsHistory, cores)
)
entries[vmId] = TraceEntryImpl(
flopsHistory.firstOrNull()?.tick ?: -1,