summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-simulator/src
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src')
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt21
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/ComputeSteps.kt2
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt2
-rw-r--r--opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt2
4 files changed, 14 insertions, 13 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 47650f5d..bfd21a3c 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
@@ -84,7 +84,7 @@ public class SimHost(
* The virtual machines running on the hypervisor.
*/
private val guests = HashMap<Server, Guest>()
- private val temporaryGuests = mutableListOf<Guest>() // TODO: Determine a better naming for this
+ private val localGuests = mutableListOf<Guest>()
private var localState: HostState = HostState.DOWN
set(value) {
@@ -96,8 +96,9 @@ public class SimHost(
private val model: HostModel =
HostModel(
- machine.model.cpus.sumOf { it.frequency },
+ machine.model.cpus.sumOf { it.frequency * it.node.coreCount },
machine.model.cpus.size,
+ machine.model.cpus.sumOf { it.node.coreCount },
machine.model.memory.sumOf { it.size },
)
@@ -145,7 +146,7 @@ public class SimHost(
override fun canFit(server: Server): Boolean {
val sufficientMemory = model.memoryCapacity >= server.flavor.memorySize
- val enoughCpus = model.cpuCount >= server.flavor.cpuCount
+ val enoughCpus = model.cpuCount >= server.flavor.coreCount
val canFit = hypervisor.canFit(server.flavor.toMachineModel())
return sufficientMemory && enoughCpus && canFit
@@ -167,7 +168,7 @@ public class SimHost(
machine,
)
- temporaryGuests.add(newGuest)
+ localGuests.add(newGuest)
newGuest
}
}
@@ -212,7 +213,7 @@ public class SimHost(
var error = 0
var invalid = 0
- val guests = temporaryGuests.listIterator()
+ val guests = localGuests.listIterator()
for (guest in guests) {
when (guest.state) {
ServerState.TERMINATED -> terminated++
@@ -277,7 +278,7 @@ public class SimHost(
public fun fail() {
reset(HostState.ERROR)
- for (guest in temporaryGuests) {
+ for (guest in localGuests) {
guest.fail()
}
}
@@ -310,7 +311,7 @@ public class SimHost(
hypervisor.onStart(ctx)
// Recover the guests that were running on the hypervisor.
- for (guest in temporaryGuests) {
+ for (guest in localGuests) {
guest.recover()
}
} catch (cause: Throwable) {
@@ -348,8 +349,8 @@ public class SimHost(
val originalCpu = machine.model.cpus[0]
val originalNode = originalCpu.node
val cpuCapacity = (this.meta["cpu-capacity"] as? Double ?: Double.MAX_VALUE).coerceAtMost(originalCpu.frequency)
- val processingNode = ProcessingNode(originalNode.vendor, originalNode.modelName, originalNode.architecture, cpuCount)
- val processingUnits = (0 until cpuCount).map { ProcessingUnit(processingNode, it, cpuCapacity) }
+ val processingNode = ProcessingNode(originalNode.vendor, originalNode.modelName, originalNode.architecture, coreCount)
+ val processingUnits = (0 until coreCount).map { ProcessingUnit(processingNode, it, cpuCapacity) }
val memoryUnits = listOf(MemoryUnit("Generic", "Generic", 3200.0, memorySize))
val model = MachineModel(processingUnits, memoryUnits)
@@ -377,7 +378,7 @@ public class SimHost(
localDowntime += duration
}
- val guests = temporaryGuests
+ val guests = localGuests
for (i in guests.indices) {
guests[i].updateUptime()
}
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/ComputeSteps.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/ComputeSteps.kt
index 53294b1b..452f08ad 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/ComputeSteps.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/ComputeSteps.kt
@@ -27,7 +27,7 @@ package org.opendc.compute.simulator.provisioner
import org.opendc.compute.service.ComputeService
import org.opendc.compute.service.scheduler.ComputeScheduler
import org.opendc.compute.telemetry.ComputeMonitor
-import org.opendc.compute.topology.HostSpec
+import org.opendc.compute.topology.specs.HostSpec
import java.time.Duration
/**
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt
index d9c5e7a6..a80be634 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt
@@ -24,7 +24,7 @@ package org.opendc.compute.simulator.provisioner
import org.opendc.compute.service.ComputeService
import org.opendc.compute.simulator.SimHost
-import org.opendc.compute.topology.HostSpec
+import org.opendc.compute.topology.specs.HostSpec
import org.opendc.simulator.compute.SimBareMetalMachine
import org.opendc.simulator.compute.kernel.SimHypervisor
import org.opendc.simulator.flow2.FlowEngine
diff --git a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
index 3a985486..19bb02ca 100644
--- a/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
+++ b/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
@@ -328,7 +328,7 @@ internal class SimHostTest {
}
private class MockFlavor(
- override val cpuCount: Int,
+ override val coreCount: Int,
override val memorySize: Long,
) : Flavor {
override val uid: UUID = UUID.randomUUID()