summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt11
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/provisioner/HostsProvisioningStep.kt1
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java4
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java9
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java2
-rw-r--r--site/docs/getting-started/1-first-experiment.md12
6 files changed, 30 insertions, 9 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt
index 0b9916ed..e1ccdfaf 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/host/SimHost.kt
@@ -32,6 +32,7 @@ import org.opendc.compute.simulator.telemetry.GuestSystemStats
import org.opendc.compute.simulator.telemetry.HostCpuStats
import org.opendc.compute.simulator.telemetry.HostSystemStats
import org.opendc.simulator.Multiplexer
+import org.opendc.simulator.compute.cpu.CpuPowerModel
import org.opendc.simulator.compute.machine.SimMachine
import org.opendc.simulator.compute.models.MachineModel
import org.opendc.simulator.compute.models.MemoryUnit
@@ -60,6 +61,7 @@ public class SimHost(
private val clock: InstantSource,
private val graph: FlowGraph,
private val machineModel: MachineModel,
+ private val cpuPowerModel: CpuPowerModel,
private val powerMux: Multiplexer,
) : AutoCloseable {
/**
@@ -83,8 +85,8 @@ public class SimHost(
private val model: HostModel =
HostModel(
- machineModel.cpu.totalCapacity,
- machineModel.cpu.coreCount,
+ machineModel.cpuModel.totalCapacity,
+ machineModel.cpuModel.coreCount,
machineModel.memory.size,
)
@@ -108,7 +110,7 @@ public class SimHost(
private var totalUptime = 0L
private var totalDowntime = 0L
private var bootTime: Instant? = null
- private val cpuLimit = machineModel.cpu.totalCapacity
+ private val cpuLimit = machineModel.cpuModel.totalCapacity
init {
launch()
@@ -130,6 +132,7 @@ public class SimHost(
this.graph,
this.machineModel,
this.powerMux,
+ this.cpuPowerModel,
) { cause ->
hostState = if (cause != null) HostState.ERROR else HostState.DOWN
}
@@ -343,7 +346,7 @@ public class SimHost(
* Convert flavor to machine model.
*/
private fun Flavor.toMachineModel(): MachineModel {
- return MachineModel(simMachine!!.machineModel.cpu, MemoryUnit("Generic", "Generic", 3200.0, memorySize))
+ return MachineModel(simMachine!!.machineModel.cpuModel, MemoryUnit("Generic", "Generic", 3200.0, memorySize))
}
/**
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 30b50c4b..8e7293c8 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
@@ -77,6 +77,7 @@ public class HostsProvisioningStep internal constructor(
ctx.dispatcher.timeSource,
graph,
hostSpec.model,
+ hostSpec.cpuPowerModel,
powerMux,
)
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java
index 18214172..d3edc957 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java
@@ -101,13 +101,13 @@ public final class SimCpu extends FlowNode implements FlowSupplier, FlowConsumer
// Constructors
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public SimCpu(FlowGraph graph, CpuModel cpuModel, int id) {
+ public SimCpu(FlowGraph graph, CpuModel cpuModel, CpuPowerModel powerModel, int id) {
super(graph);
this.cpuModel = cpuModel;
this.maxCapacity = this.cpuModel.getTotalCapacity();
// TODO: connect this to the front-end
- this.cpuPowerModel = CpuPowerModels.linear(400, 200);
+ this.cpuPowerModel = powerModel;
this.lastCounterUpdate = graph.getEngine().getClock().millis();
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java
index c7caa63f..8364324a 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java
@@ -25,6 +25,7 @@ package org.opendc.simulator.compute.machine;
import java.time.InstantSource;
import java.util.function.Consumer;
import org.opendc.simulator.Multiplexer;
+import org.opendc.simulator.compute.cpu.CpuPowerModel;
import org.opendc.simulator.compute.cpu.SimCpu;
import org.opendc.simulator.compute.memory.Memory;
import org.opendc.simulator.compute.models.MachineModel;
@@ -111,7 +112,11 @@ public class SimMachine {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public SimMachine(
- FlowGraph graph, MachineModel machineModel, Multiplexer powerMux, Consumer<Exception> completion) {
+ FlowGraph graph,
+ MachineModel machineModel,
+ Multiplexer powerMux,
+ CpuPowerModel cpuPowerModel,
+ Consumer<Exception> completion) {
this.graph = graph;
this.machineModel = machineModel;
this.clock = graph.getEngine().getClock();
@@ -121,7 +126,7 @@ public class SimMachine {
graph.addEdge(this.psu, powerMux);
- this.cpu = new SimCpu(graph, this.machineModel.getCpu(), 0);
+ this.cpu = new SimCpu(graph, this.machineModel.getCpuModel(), cpuPowerModel, 0);
graph.addEdge(this.cpu, this.psu);
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java
index d6d139d7..6c47fbe6 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java
+++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/models/MachineModel.java
@@ -67,7 +67,7 @@ public final class MachineModel {
/**
* Return the processing units of this machine.
*/
- public CpuModel getCpu() {
+ public CpuModel getCpuModel() {
return this.cpuModel;
}
diff --git a/site/docs/getting-started/1-first-experiment.md b/site/docs/getting-started/1-first-experiment.md
index 313d757b..9c84c435 100644
--- a/site/docs/getting-started/1-first-experiment.md
+++ b/site/docs/getting-started/1-first-experiment.md
@@ -6,6 +6,18 @@ description: Designing a simple experiment
Now that you have downloaded OpenDC, we will start creating a simple experiment.
In this experiment we will compare the performance of a small, and a big data center on the same workload.
+<details>
+<summary>Expand this</summary>
+
+This is content
+</details>
+
+:::tip Answer
+<details>
+<summary>Expand for the Answer</summary>
+</details>
+:::
+
:::info Learning goal
During this tutorial, we will learn how to create and execute a simple experiment in OpenDC.
:::