summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-08-25 20:33:52 +0200
committerGitHub <noreply@github.com>2021-08-25 20:33:52 +0200
commit4f333808d823abadd603ef2221092d82dc0f02b4 (patch)
tree8e9b054a770b3a048b5cfb44e3f6bb4dff57315e /opendc-simulator/opendc-simulator-compute
parentac48fa12f36180de31154a7c828b4dc281dac94b (diff)
parente5b79b18dab4f2874f3c5730b7e599dc74573c8d (diff)
merge: Upgrade to OpenTelemetry 1.5
This pull request updates to OpenTelemetry version 1.5.0. * Update dependency to OpenTelemetry 1.5 * Fix breaking changes in metrics API * Eliminate unnecessary double to long conversions * Simplify metric extraction for monitor
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt6
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt8
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimHypervisor.kt14
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt40
4 files changed, 40 insertions, 28 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt
index d287312f..6002270a 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimAbstractHypervisor.kt
@@ -60,6 +60,12 @@ public abstract class SimAbstractHypervisor(
get() = _vms
/**
+ * The resource counters associated with the hypervisor.
+ */
+ public override val counters: SimResourceCounters
+ get() = switch.counters
+
+ /**
* The scaling governors attached to the physical CPUs backing this hypervisor.
*/
private val governors = mutableListOf<ScalingGovernor.Logic>()
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt
index c31b1f6b..3b44292d 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt
@@ -77,10 +77,10 @@ public class SimFairShareHypervisor(
if (timestamp > lastReport) {
listener.onSliceFinish(
this@SimFairShareHypervisor,
- (counters.demand - lastDemand).toLong(),
- (counters.actual - lastActual).toLong(),
- (counters.overcommit - lastOvercommit).toLong(),
- (counters.interference - lastInterference).toLong(),
+ counters.demand - lastDemand,
+ counters.actual - lastActual,
+ counters.overcommit - lastOvercommit,
+ counters.interference - lastInterference,
lastCpuUsage,
lastCpuDemand
)
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimHypervisor.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimHypervisor.kt
index e398ab36..af28c346 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimHypervisor.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimHypervisor.kt
@@ -25,6 +25,7 @@ package org.opendc.simulator.compute.kernel
import org.opendc.simulator.compute.SimMachine
import org.opendc.simulator.compute.model.MachineModel
import org.opendc.simulator.compute.workload.SimWorkload
+import org.opendc.simulator.resources.SimResourceCounters
/**
* A SimHypervisor facilitates the execution of multiple concurrent [SimWorkload]s, while acting as a single workload
@@ -37,6 +38,11 @@ public interface SimHypervisor : SimWorkload {
public val vms: Set<SimMachine>
/**
+ * The resource counters associated with the hypervisor.
+ */
+ public val counters: SimResourceCounters
+
+ /**
* Determine whether the specified machine characterized by [model] can fit on this hypervisor at this moment.
*/
public fun canFit(model: MachineModel): Boolean
@@ -58,10 +64,10 @@ public interface SimHypervisor : SimWorkload {
*/
public fun onSliceFinish(
hypervisor: SimHypervisor,
- requestedWork: Long,
- grantedWork: Long,
- overcommittedWork: Long,
- interferedWork: Long,
+ requestedWork: Double,
+ grantedWork: Double,
+ overcommittedWork: Double,
+ interferedWork: Double,
cpuUsage: Double,
cpuDemand: Double
)
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt
index afc4c949..918271d1 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/kernel/SimHypervisorTest.kt
@@ -68,16 +68,16 @@ internal class SimHypervisorTest {
@Test
fun testOvercommittedSingle() = runBlockingSimulation {
val listener = object : SimHypervisor.Listener {
- var totalRequestedWork = 0L
- var totalGrantedWork = 0L
- var totalOvercommittedWork = 0L
+ var totalRequestedWork = 0.0
+ var totalGrantedWork = 0.0
+ var totalOvercommittedWork = 0.0
override fun onSliceFinish(
hypervisor: SimHypervisor,
- requestedWork: Long,
- grantedWork: Long,
- overcommittedWork: Long,
- interferedWork: Long,
+ requestedWork: Double,
+ grantedWork: Double,
+ overcommittedWork: Double,
+ interferedWork: Double,
cpuUsage: Double,
cpuDemand: Double
) {
@@ -117,9 +117,9 @@ internal class SimHypervisorTest {
machine.close()
assertAll(
- { assertEquals(1113300, listener.totalRequestedWork, "Requested Burst does not match") },
- { assertEquals(1023300, listener.totalGrantedWork, "Granted Burst does not match") },
- { assertEquals(90000, listener.totalOvercommittedWork, "Overcommissioned Burst does not match") },
+ { assertEquals(1113300.0, listener.totalRequestedWork, "Requested Burst does not match") },
+ { assertEquals(1023300.0, listener.totalGrantedWork, "Granted Burst does not match") },
+ { assertEquals(90000.0, listener.totalOvercommittedWork, "Overcommissioned Burst does not match") },
{ assertEquals(listOf(0.0, 0.00875, 1.0, 0.0, 0.0571875, 0.0), res) { "VM usage is correct" } },
{ assertEquals(1200000, clock.millis()) { "Current time is correct" } }
)
@@ -131,16 +131,16 @@ internal class SimHypervisorTest {
@Test
fun testOvercommittedDual() = runBlockingSimulation {
val listener = object : SimHypervisor.Listener {
- var totalRequestedWork = 0L
- var totalGrantedWork = 0L
- var totalOvercommittedWork = 0L
+ var totalRequestedWork = 0.0
+ var totalGrantedWork = 0.0
+ var totalOvercommittedWork = 0.0
override fun onSliceFinish(
hypervisor: SimHypervisor,
- requestedWork: Long,
- grantedWork: Long,
- overcommittedWork: Long,
- interferedWork: Long,
+ requestedWork: Double,
+ grantedWork: Double,
+ overcommittedWork: Double,
+ interferedWork: Double,
cpuUsage: Double,
cpuDemand: Double
) {
@@ -196,9 +196,9 @@ internal class SimHypervisorTest {
yield()
assertAll(
- { assertEquals(2073600, listener.totalRequestedWork, "Requested Burst does not match") },
- { assertEquals(1053600, listener.totalGrantedWork, "Granted Burst does not match") },
- { assertEquals(1020000, listener.totalOvercommittedWork, "Overcommissioned Burst does not match") },
+ { assertEquals(2073600.0, listener.totalRequestedWork, "Requested Burst does not match") },
+ { assertEquals(1053600.0, listener.totalGrantedWork, "Granted Burst does not match") },
+ { assertEquals(1020000.0, listener.totalOvercommittedWork, "Overcommissioned Burst does not match") },
{ assertEquals(1200000, clock.millis()) }
)
}