summaryrefslogtreecommitdiff
path: root/simulator/opendc-simulator/opendc-simulator-compute/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-23 11:38:25 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-23 11:41:32 +0100
commit38a13e5c201c828f9f21f17e89916b4638396945 (patch)
tree2a882a67667e8efcd51d74cfbe32fdeaad02f502 /simulator/opendc-simulator/opendc-simulator-compute/src/main
parentb5ac4b4f0c9a9e0c4b2ee744f8184adbe8e8d76a (diff)
simulator: Add support for emitting VM usage metrics
This change re-enables support for VM usage metrics by adding an adapter for SimResourceConsumer instances that can export the consumer speed.
Diffstat (limited to 'simulator/opendc-simulator/opendc-simulator-compute/src/main')
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt5
1 files changed, 2 insertions, 3 deletions
diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
index 52945354..1c0f94fd 100644
--- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
+++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
@@ -102,7 +102,7 @@ public abstract class SimAbstractMachine(private val clock: Clock) : SimMachine
val consumer = workload.getConsumer(ctx, cpu)
val job = source.speed
.onEach {
- _speed[cpu.id] = source.speed.value
+ _speed[cpu.id] = it
_usage.value = _speed.sum() / totalCapacity
}
.launchIn(this)
@@ -116,9 +116,8 @@ public abstract class SimAbstractMachine(private val clock: Clock) : SimMachine
override fun close() {
if (!isTerminated) {
- resources.forEach { (_, provider) -> provider.close() }
- } else {
isTerminated = true
+ resources.forEach { (_, provider) -> provider.close() }
}
}
}