summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-simulator/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-28 11:23:13 +0200
committerGitHub <noreply@github.com>2021-09-28 11:23:13 +0200
commit6196895bfd0334052afa4fb91b00adb259a661b6 (patch)
tree8a14988b30f6f5758b1f9f982d0086296eb5d416 /opendc-compute/opendc-compute-simulator/src/main
parent993c65d9c287d8db2db9ff1f95abb414803a502c (diff)
parent94d8ee69e52dcd375a662a08c198aa29670362fb (diff)
merge: Simplify usage of ComputeMetricExporter
This pull request addresses some issues with the current implementation of the `ComputeMetricExporter` class. In particular, the construction of `ComputeMetricExporter` does not require a `Clock` anymore. - Ensure shutdown of exporter is called - Do not require clock for ComputeMetricExporter - Do not recover guests in non-error state - Write null values explicitly in Parquet exporter - Report cause of compute exporter failure **Breaking API Changes** - `ComputeMetricExporter` is now an abstract class that can be extended to collect metrics - `ParquetComputeMonitor` has been renamed to `ParquetComputeMetricExporter` and extends `ComputeMetricExporter`
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src/main')
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt4
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt15
2 files changed, 15 insertions, 4 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
index ff55c585..fdb3f1dc 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
@@ -262,7 +262,7 @@ public class SimHost(
}
override suspend fun delete(server: Server) {
- val guest = guests.remove(server) ?: return
+ val guest = guests[server] ?: return
guest.terminate()
}
@@ -296,7 +296,7 @@ public class SimHost(
_bootTime = clock.millis()
for (guest in guests.values) {
- guest.start()
+ guest.recover()
}
}
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt
index 90562e2f..7f33154a 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt
@@ -96,8 +96,8 @@ internal class Guest(
}
ServerState.RUNNING -> return
ServerState.DELETED -> {
- logger.warn { "User tried to start terminated server" }
- throw IllegalArgumentException("Server is terminated")
+ logger.warn { "User tried to start deleted server" }
+ throw IllegalArgumentException("Server is deleted")
}
else -> assert(false) { "Invalid state transition" }
}
@@ -144,6 +144,17 @@ internal class Guest(
}
/**
+ * Recover the guest if it is in an error state.
+ */
+ suspend fun recover() {
+ if (state != ServerState.ERROR) {
+ return
+ }
+
+ doStart()
+ }
+
+ /**
* The [Job] representing the current active virtual machine instance or `null` if no virtual machine is active.
*/
private var job: Job? = null