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 e1ccdfaf4..f34e135df 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 @@ -31,12 +31,12 @@ import org.opendc.compute.simulator.telemetry.GuestCpuStats 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 -import org.opendc.simulator.engine.FlowGraph +import org.opendc.simulator.engine.graph.FlowDistributor +import org.opendc.simulator.engine.graph.FlowGraph import java.time.Duration import java.time.Instant import java.time.InstantSource @@ -62,7 +62,7 @@ public class SimHost( private val graph: FlowGraph, private val machineModel: MachineModel, private val cpuPowerModel: CpuPowerModel, - private val powerMux: Multiplexer, + private val powerMux: FlowDistributor, ) : AutoCloseable { /** * The event listeners registered with this host. 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 8e7293c88..8dcf2fa13 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 @@ -27,9 +27,9 @@ import org.opendc.compute.simulator.host.SimHost import org.opendc.compute.simulator.service.ComputeService import org.opendc.compute.topology.specs.ClusterSpec import org.opendc.compute.topology.specs.HostSpec -import org.opendc.simulator.Multiplexer import org.opendc.simulator.compute.power.SimPowerSource -import org.opendc.simulator.engine.FlowEngine +import org.opendc.simulator.engine.engine.FlowEngine +import org.opendc.simulator.engine.graph.FlowDistributor /** * A [ProvisioningStep] that provisions a list of hosts for a [ComputeService]. @@ -64,7 +64,7 @@ public class HostsProvisioningStep internal constructor( service.addPowerSource(simPowerSource) simPowerSources.add(simPowerSource) - val powerMux = Multiplexer(graph) + val powerMux = FlowDistributor(graph) graph.addEdge(powerMux, simPowerSource) // Create hosts, they are connected to the powerMux when SimMachine is created diff --git a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt index 1956ffde2..0d0dd24df 100644 --- a/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt +++ b/opendc-compute/opendc-compute-topology/src/main/kotlin/org/opendc/compute/topology/specs/HostSpec.kt @@ -33,8 +33,7 @@ import java.util.UUID * @param name The name of the host. * @param meta The metadata of the host. * @param model The physical model of the machine. - * @param cpuPowerModel The [SimPsuFactory] to construct the PSU that models the power consumption of the machine. - * @param multiplexerFactory The [FlowMultiplexerFactory] that is used to multiplex the virtual machines over the host. + * @param cpuPowerModel The [cpuPowerModel] that determines the power draw based on cpu utilization */ public data class HostSpec( val uid: UUID, diff --git a/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/MultiplexerTest.kt b/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/FlowDistributorTest.kt similarity index 94% rename from opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/MultiplexerTest.kt rename to opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/FlowDistributorTest.kt index 049e0d326..31c7dfd08 100644 --- a/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/MultiplexerTest.kt +++ b/opendc-experiments/opendc-experiments-base/src/test/kotlin/org/opendc/experiments/base/FlowDistributorTest.kt @@ -55,9 +55,9 @@ import java.util.ArrayList import java.util.UUID /** - * Testing suite containing tests that specifically test the Multiplexer + * Testing suite containing tests that specifically test the FlowDistributor */ -class MultiplexerTest { +class FlowDistributorTest { /** * The monitor used to keep track of the metrics. */ @@ -73,7 +73,7 @@ class MultiplexerTest { */ private lateinit var workloadLoader: ComputeWorkloadLoader - private val basePath = "src/test/resources/Multiplexer" + private val basePath = "src/test/resources/FlowDistributor" /** * Set up the experimental environment. @@ -135,12 +135,12 @@ class MultiplexerTest { } /** - * Multiplexer test 1: A single fitting task - * In this test, a single task is scheduled that should fit the Multiplexer + * FlowDistributor test 1: A single fitting task + * In this test, a single task is scheduled that should fit the FlowDistributor * We check if both the host and the Task show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer1() { + fun testFlowDistributor1() { val workload: ArrayList = arrayListOf( createTestTask( @@ -171,13 +171,13 @@ class MultiplexerTest { } /** - * Multiplexer test 2: A single overloaded task - * In this test, a single task is scheduled that does not fit the Multiplexer + * FlowDistributor test 2: A single overloaded task + * In this test, a single task is scheduled that does not fit the FlowDistributor * In this test we expect the usage to be lower than the demand. * We check if both the host and the Task show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer2() { + fun testFlowDistributor2() { val workload: ArrayList = arrayListOf( createTestTask( @@ -208,13 +208,13 @@ class MultiplexerTest { } /** - * Multiplexer test 3: A single task transition fit to overloaded + * FlowDistributor test 3: A single task transition fit to overloaded * In this test, a single task is scheduled where the first fragment fits, but the second does not. * For the first fragment, we expect the usage of the second fragment to be lower than the demand * We check if both the host and the Task show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer3() { + fun testFlowDistributor3() { val workload: ArrayList = arrayListOf( createTestTask( @@ -245,13 +245,13 @@ class MultiplexerTest { } /** - * Multiplexer test 4: A single task transition overload to fit + * FlowDistributor test 4: A single task transition overload to fit * In this test, a single task is scheduled where the first fragment does not fit, and the second does. * For the first fragment, we expect the usage of the first fragment to be lower than the demand * We check if both the host and the Task show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer4() { + fun testFlowDistributor4() { val workload: ArrayList = arrayListOf( createTestTask( @@ -282,13 +282,13 @@ class MultiplexerTest { } /** - * Multiplexer test 5: Two task, same time, both fit + * FlowDistributor test 5: Two task, same time, both fit * In this test, two tasks are scheduled, and they fit together on the host . The tasks start and finish at the same time - * This test shows how the multiplexer handles two tasks that can fit and no redistribution is required. + * This test shows how the FlowDistributor handles two tasks that can fit and no redistribution is required. * We check if both the host and the Tasks show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer5() { + fun testFlowDistributor5() { val workload: ArrayList = arrayListOf( createTestTask( @@ -331,13 +331,13 @@ class MultiplexerTest { } /** - * Multiplexer test 6: Two task, same time, can not fit + * FlowDistributor test 6: Two task, same time, can not fit * In this test, two tasks are scheduled, and they can not both fit. The tasks start and finish at the same time - * This test shows how the multiplexer handles two tasks that both do not fit and redistribution is required. + * This test shows how the FlowDistributor handles two tasks that both do not fit and redistribution is required. * We check if both the host and the Tasks show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer6() { + fun testFlowDistributor6() { val workload: ArrayList = arrayListOf( createTestTask( @@ -380,12 +380,12 @@ class MultiplexerTest { } /** - * Multiplexer test 7: Two task, both fit, second task is delayed + * FlowDistributor test 7: Two task, both fit, second task is delayed * In this test, two tasks are scheduled, the second task is delayed. * We check if both the host and the Tasks show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer7() { + fun testFlowDistributor7() { val workload: ArrayList = arrayListOf( createTestTask( @@ -437,15 +437,15 @@ class MultiplexerTest { } /** - * Multiplexer test 8: Two task, both fit on their own but not together, second task is delayed + * FlowDistributor test 8: Two task, both fit on their own but not together, second task is delayed * In this test, two tasks are scheduled, the second task is delayed. * We check if both the host and the Tasks show the correct cpu usage and demand during the two fragments. * When the second task comes in, the host is overloaded. - * This test shows how the multiplexer can handle redistribution when a new task comes in. + * This test shows how the FlowDistributor can handle redistribution when a new task comes in. * We check if both the host and the Tasks show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer8() { + fun testFlowDistributor8() { val workload: ArrayList = arrayListOf( createTestTask( @@ -494,14 +494,14 @@ class MultiplexerTest { } /** - * Multiplexer test 9: Two task, one changes demand, causing overload + * FlowDistributor test 9: Two task, one changes demand, causing overload * In this test, two tasks are scheduled, and they can both fit. - * However, task 0 increases its demand which overloads the multiplexer. - * This test shows how the multiplexer handles transition from fitting to overloading when multiple tasks are running. + * However, task 0 increases its demand which overloads the FlowDistributor. + * This test shows how the FlowDistributor handles transition from fitting to overloading when multiple tasks are running. * We check if both the host and the Tasks show the correct cpu usage and demand during the two fragments. */ @Test - fun testMultiplexer9() { + fun testFlowDistributor9() { val workload: ArrayList = arrayListOf( createTestTask( @@ -560,7 +560,7 @@ class MultiplexerTest { * Obtain the topology factory for the test. */ private fun createTopology(name: String): List { - val stream = checkNotNull(object {}.javaClass.getResourceAsStream("/Multiplexer/topologies/$name")) + val stream = checkNotNull(object {}.javaClass.getResourceAsStream("/FlowDistributor/topologies/$name")) return stream.use { clusterTopology(stream) } } diff --git a/opendc-experiments/opendc-experiments-base/src/test/resources/Multiplexer/topologies/single_1_2000.json b/opendc-experiments/opendc-experiments-base/src/test/resources/FlowDistributor/topologies/single_1_2000.json similarity index 100% rename from opendc-experiments/opendc-experiments-base/src/test/resources/Multiplexer/topologies/single_1_2000.json rename to opendc-experiments/opendc-experiments-base/src/test/resources/FlowDistributor/topologies/single_1_2000.json diff --git a/opendc-experiments/opendc-experiments-base/src/test/resources/Multiplexer/topologies/single_2_2000.json b/opendc-experiments/opendc-experiments-base/src/test/resources/FlowDistributor/topologies/single_2_2000.json similarity index 100% rename from opendc-experiments/opendc-experiments-base/src/test/resources/Multiplexer/topologies/single_2_2000.json rename to opendc-experiments/opendc-experiments-base/src/test/resources/FlowDistributor/topologies/single_2_2000.json diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt deleted file mode 100644 index 8d8f4ef8b..000000000 --- a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.simulator.compute - -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.launch -import org.opendc.simulator.compute.old.SimBareMetalMachine -import org.opendc.simulator.compute.old.kernel.SimHypervisor -import org.opendc.simulator.compute.old.model.CpuModel -import org.opendc.simulator.compute.old.model.MachineModel -import org.opendc.simulator.compute.old.model.MemoryUnit -import org.opendc.simulator.compute.old.model.ProcessingNode -import org.opendc.simulator.compute.old.workload.SimTrace -import org.opendc.simulator.flow2.FlowEngine -import org.opendc.simulator.flow2.mux.FlowMultiplexerFactory -import org.opendc.simulator.kotlin.runSimulation -import org.openjdk.jmh.annotations.Benchmark -import org.openjdk.jmh.annotations.Fork -import org.openjdk.jmh.annotations.Measurement -import org.openjdk.jmh.annotations.Scope -import org.openjdk.jmh.annotations.Setup -import org.openjdk.jmh.annotations.State -import org.openjdk.jmh.annotations.Warmup -import java.util.SplittableRandom -import java.util.concurrent.ThreadLocalRandom -import java.util.concurrent.TimeUnit - -@State(Scope.Thread) -@Fork(1) -@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) -@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS) -class SimMachineBenchmarks { - private lateinit var machineModel: MachineModel - private lateinit var trace: SimTrace - - @Setup - fun setUp() { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2) - - machineModel = - MachineModel( - // cpus - List(cpuNode.coreCount) { - CpuModel( - cpuNode, - it, - 1000.0, - ) - }, - // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, - ) - - val random = ThreadLocalRandom.current() - val builder = SimTrace.builder() - repeat(1000000) { - val timestamp = it.toLong() * 1000 - val deadline = timestamp + 1000 - builder.add(deadline, random.nextDouble(0.0, 4500.0), 1) - } - trace = builder.build() - } - - @Benchmark - fun benchmarkBareMetal() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - return@runSimulation machine.runWorkload(trace.createWorkload(0)) - } - } - - @Benchmark - fun benchmarkSpaceSharedHypervisor() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1)) - - launch { machine.runWorkload(hypervisor) } - - val vm = hypervisor.newMachine(machineModel) - - try { - return@runSimulation vm.runWorkload(trace.createWorkload(0)) - } finally { - vm.cancel() - machine.cancel() - } - } - } - - @Benchmark - fun benchmarkFairShareHypervisorSingle() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1)) - - launch { machine.runWorkload(hypervisor) } - - val vm = hypervisor.newMachine(machineModel) - - try { - return@runSimulation vm.runWorkload(trace.createWorkload(0)) - } finally { - vm.cancel() - machine.cancel() - } - } - } - - @Benchmark - fun benchmarkFairShareHypervisorDouble() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1)) - - launch { machine.runWorkload(hypervisor) } - - coroutineScope { - repeat(2) { - val vm = hypervisor.newMachine(machineModel) - - launch { - try { - vm.runWorkload(trace.createWorkload(0)) - } finally { - machine.cancel() - } - } - } - } - machine.cancel() - } - } -} 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 63331a6cb..c5b8a9eab 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 @@ -24,11 +24,11 @@ import org.opendc.simulator.compute.machine.PerformanceCounters; import org.opendc.simulator.compute.models.CpuModel; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimCpu} of a machine. 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 8364324a9..074f0ed8a 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 @@ -24,7 +24,6 @@ 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; @@ -32,7 +31,8 @@ import org.opendc.simulator.compute.power.SimPsu; import org.opendc.simulator.compute.workload.SimWorkload; import org.opendc.simulator.compute.workload.Workload; -import org.opendc.simulator.engine.FlowGraph; +import org.opendc.simulator.engine.graph.FlowDistributor; +import org.opendc.simulator.engine.graph.FlowGraph; /** * A machine that is able to execute {@link SimWorkload} objects. @@ -44,7 +44,7 @@ public class SimMachine { private final InstantSource clock; private SimCpu cpu; - private Multiplexer cpuMux; + private FlowDistributor cpuMux; private SimPsu psu; private Memory memory; @@ -74,7 +74,7 @@ public SimCpu getCpu() { return cpu; } - public Multiplexer getCpuMux() { + public FlowDistributor getCpuMux() { return cpuMux; } @@ -114,7 +114,7 @@ public double getCpuUsage() { public SimMachine( FlowGraph graph, MachineModel machineModel, - Multiplexer powerMux, + FlowDistributor powerMux, CpuPowerModel cpuPowerModel, Consumer completion) { this.graph = graph; @@ -132,8 +132,8 @@ public SimMachine( this.memory = new Memory(graph, this.machineModel.getMemory()); - // Create a Multiplexer and add the cpu as supplier - this.cpuMux = new Multiplexer(this.graph); + // Create a FlowDistributor and add the cpu as supplier + this.cpuMux = new FlowDistributor(this.graph); graph.addEdge(this.cpuMux, this.cpu); this.completion = completion; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java index 15a1b1c4d..b8a9c7389 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java @@ -26,11 +26,11 @@ import org.opendc.simulator.compute.cpu.SimCpu; import org.opendc.simulator.compute.workload.SimWorkload; import org.opendc.simulator.compute.workload.Workload; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /* A virtual Machine created to run a single workload diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java index 2656a99a7..d4406b206 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java @@ -23,7 +23,7 @@ package org.opendc.simulator.compute.memory; import org.opendc.simulator.compute.models.MemoryUnit; -import org.opendc.simulator.engine.FlowGraph; +import org.opendc.simulator.engine.graph.FlowGraph; /** * The [SimMemory] implementation for a machine. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java index 98ef2b72a..91095c018 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java @@ -23,8 +23,8 @@ package org.opendc.simulator.compute.power; import java.util.List; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; /** * CarbonModel used to provide the Carbon Intensity of a {@link SimPowerSource} diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java index ea500c813..e8626e40d 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java @@ -24,10 +24,10 @@ import java.util.List; import org.opendc.simulator.compute.cpu.SimCpu; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimPsu} implementation that estimates the power consumption based on CPU usage. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java index 709d3e152..c1e8a1b9e 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java @@ -23,11 +23,11 @@ package org.opendc.simulator.compute.power; import org.opendc.simulator.compute.cpu.SimCpu; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimPsu} implementation that estimates the power consumption based on CPU usage. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java index 78e8b5d48..ecd4c47f2 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java @@ -23,7 +23,7 @@ package org.opendc.simulator.compute.workload; import java.util.ArrayList; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowSupplier; public class ChainWorkload implements Workload { private ArrayList workloads; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java index 723c450de..f4f7cdd6b 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java @@ -29,8 +29,8 @@ import java.time.InstantSource; import org.jetbrains.annotations.NotNull; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; public class CheckpointModel extends FlowNode { private SimWorkload simWorkload; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java index 5b7c10bb9..75bdde923 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java @@ -23,9 +23,9 @@ package org.opendc.simulator.compute.workload; import java.util.LinkedList; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimChainWorkload} that composes multiple {@link SimWorkload}s. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java index 59994fe6a..72c095dc5 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java @@ -23,11 +23,11 @@ package org.opendc.simulator.compute.workload; import java.util.LinkedList; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; public class SimTraceWorkload extends SimWorkload implements FlowConsumer { private LinkedList remainingFragments; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java index b5c899417..2919fc3a2 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java @@ -22,9 +22,9 @@ package org.opendc.simulator.compute.workload; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; /** * A model that characterizes the runtime behavior of some particular workload. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java index 39bb61110..7f82ab714 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowSupplier; public class TraceWorkload implements Workload { private ArrayList fragments; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java index cd34921a3..d85669bbe 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java @@ -22,7 +22,7 @@ package org.opendc.simulator.compute.workload; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowSupplier; public interface Workload { diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEngine.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowEngine.java similarity index 94% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEngine.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowEngine.java index 10af7c510..1a068b40d 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEngine.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowEngine.java @@ -20,12 +20,14 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.engine; import java.time.Clock; import java.time.InstantSource; import kotlin.coroutines.CoroutineContext; import org.opendc.common.Dispatcher; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; /** * A {@link FlowEngine} simulates a generic flow network. @@ -89,7 +91,7 @@ public FlowGraph newGraph() { * This method should be used when the state of a flow context is invalidated/interrupted and needs to be * re-computed. */ - void scheduleImmediate(long now, FlowNode ctx) { + public void scheduleImmediate(long now, FlowNode ctx) { scheduleImmediateInContext(ctx); // In-case the engine is already running in the call-stack, return immediately. The changes will be picked @@ -109,14 +111,14 @@ void scheduleImmediate(long now, FlowNode ctx) { *

* This method should only be invoked while inside an engine cycle. */ - void scheduleImmediateInContext(FlowNode ctx) { + public void scheduleImmediateInContext(FlowNode ctx) { queue.add(ctx); } /** * Enqueue the specified {@link FlowNode} to be updated at its updated deadline. */ - void scheduleDelayed(FlowNode ctx) { + public void scheduleDelayed(FlowNode ctx) { scheduleDelayedInContext(ctx); // In-case the engine is already running in the call-stack, return immediately. The changes will be picked @@ -136,7 +138,7 @@ void scheduleDelayed(FlowNode ctx) { *

* This method should only be invoked while inside an engine cycle. */ - void scheduleDelayedInContext(FlowNode ctx) { + public void scheduleDelayedInContext(FlowNode ctx) { FlowTimerQueue timerQueue = this.timerQueue; timerQueue.enqueue(ctx); } diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowNodeQueue.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowNodeQueue.java similarity index 97% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowNodeQueue.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowNodeQueue.java index 37b3c65b8..bd6220837 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowNodeQueue.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowNodeQueue.java @@ -20,10 +20,11 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.engine; import java.util.ArrayDeque; import java.util.Arrays; +import org.opendc.simulator.engine.graph.FlowNode; /** * A specialized {@link ArrayDeque} implementation that contains the {@link FlowNode}s diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowTimerQueue.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowTimerQueue.java similarity index 88% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowTimerQueue.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowTimerQueue.java index 1e348b109..049eb40d8 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowTimerQueue.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/FlowTimerQueue.java @@ -20,9 +20,10 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.engine; import java.util.Arrays; +import org.opendc.simulator.engine.graph.FlowNode; /** * A specialized priority queue for timers of {@link FlowNode}s. @@ -55,9 +56,9 @@ public FlowTimerQueue(int initialCapacity) { */ public void enqueue(FlowNode node) { FlowNode[] es = queue; - int k = node.timerIndex; + int k = node.getTimerIndex(); - if (node.deadline != Long.MAX_VALUE) { + if (node.getDeadline() != Long.MAX_VALUE) { if (k >= 0) { update(es, node, k); } else { @@ -82,7 +83,7 @@ public FlowNode poll(long now) { final FlowNode[] es = queue; final FlowNode head = es[0]; - if (now < head.deadline) { + if (now < head.getDeadline()) { return null; } @@ -95,7 +96,7 @@ public FlowNode poll(long now) { siftDown(0, next, es, n); } - head.timerIndex = -1; + head.setTimerIndex(-1); return head; } @@ -104,7 +105,7 @@ public FlowNode poll(long now) { */ public long peekDeadline() { if (this.size > 0) { - return this.queue[0].deadline; + return this.queue[0].getDeadline(); } return Long.MAX_VALUE; @@ -130,7 +131,7 @@ private void add(FlowNode[] es, FlowNode node) { private void update(FlowNode[] es, FlowNode node, int k) { if (k > 0) { int parent = (k - 1) >>> 1; - if (es[parent].deadline > node.deadline) { + if (es[parent].getDeadline() > node.getDeadline()) { siftUp(k, node, es); return; } @@ -175,13 +176,13 @@ private static void siftUp(int k, FlowNode key, FlowNode[] es) { while (k > 0) { int parent = (k - 1) >>> 1; FlowNode e = es[parent]; - if (key.deadline >= e.deadline) break; + if (key.getDeadline() >= e.getDeadline()) break; es[k] = e; - e.timerIndex = k; + e.setTimerIndex(k); k = parent; } es[k] = key; - key.timerIndex = k; + key.setTimerIndex(k); } private static void siftDown(int k, FlowNode key, FlowNode[] es, int n) { @@ -190,16 +191,16 @@ private static void siftDown(int k, FlowNode key, FlowNode[] es, int n) { int child = (k << 1) + 1; // assume left child is least FlowNode c = es[child]; int right = child + 1; - if (right < n && c.deadline > es[right].deadline) c = es[child = right]; + if (right < n && c.getDeadline() > es[right].getDeadline()) c = es[child = right]; - if (key.deadline <= c.deadline) break; + if (key.getDeadline() <= c.getDeadline()) break; es[k] = c; - c.timerIndex = k; + c.setTimerIndex(k); k = child; } es[k] = key; - key.timerIndex = k; + key.setTimerIndex(k); } } diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/InvocationStack.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/InvocationStack.java similarity index 98% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/InvocationStack.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/InvocationStack.java index 15da2f235..5607278c3 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/InvocationStack.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/engine/InvocationStack.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.engine; import java.util.Arrays; diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowConsumer.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowConsumer.java similarity index 96% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowConsumer.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowConsumer.java index ddb407947..2130d3767 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowConsumer.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowConsumer.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.graph; public interface FlowConsumer { diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java similarity index 90% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java index 481774121..7ef091f8d 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/Multiplexer.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowDistributor.java @@ -20,17 +20,12 @@ * SOFTWARE. */ -package org.opendc.simulator; +package org.opendc.simulator.engine.graph; import java.util.ArrayList; import java.util.Arrays; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; -public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer { +public class FlowDistributor extends FlowNode implements FlowSupplier, FlowConsumer { private final ArrayList consumerEdges = new ArrayList<>(); private FlowEdge supplierEdge; @@ -45,7 +40,7 @@ public class Multiplexer extends FlowNode implements FlowSupplier, FlowConsumer private double capacity; // What is the max capacity - public Multiplexer(FlowGraph graph) { + public FlowDistributor(FlowGraph graph) { super(graph); } @@ -70,7 +65,7 @@ private void distributeSupply() { // if supply >= demand -> push supplies to all tasks if (this.totalSupply > this.totalDemand) { - // If this came from a state of over provisioning, provide all consumers with their demand + // If this came from a state of overload, provide all consumers with their demand if (this.overLoaded) { for (int idx = 0; idx < this.consumerEdges.size(); idx++) { this.pushSupply(this.consumerEdges.get(idx), this.demands.get(idx)); @@ -99,6 +94,12 @@ private void distributeSupply() { private record Demand(int idx, double value) {} + /** + * Distributed the available supply over the different demands. + * The supply is distributed using MaxMin Fairness. + * + * TODO: Move this outside of the Distributor so we can easily add different redistribution methods + */ private static double[] redistributeSupply(ArrayList demands, double totalSupply) { int inputSize = demands.size(); @@ -198,7 +199,7 @@ public void handleDemand(FlowEdge consumerEdge, double newDemand) { this.currentConsumerIdx = idx; if (idx == -1) { - System.out.println("Error (Multiplexer): Demand pushed by an unknown consumer"); + System.out.println("Error (FlowDistributor): Demand pushed by an unknown consumer"); return; } @@ -234,7 +235,7 @@ public void pushSupply(FlowEdge consumerEdge, double newSupply) { int idx = consumerEdge.getConsumerIndex(); if (idx == -1) { - System.out.println("Error (Multiplexer): pushing supply to an unknown consumer"); + System.out.println("Error (FlowDistributor): pushing supply to an unknown consumer"); } if (supplies.get(idx) == newSupply) { diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEdge.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java similarity index 98% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEdge.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java index 95fe79285..b7162508d 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowEdge.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowEdge.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.graph; /** * An edge that connects two FlowStages. diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowGraph.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowGraph.java similarity index 97% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowGraph.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowGraph.java index d82b542bd..0e6e137cc 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowGraph.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowGraph.java @@ -20,10 +20,11 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.graph; import java.util.ArrayList; import java.util.HashMap; +import org.opendc.simulator.engine.engine.FlowEngine; public class FlowGraph { private final FlowEngine engine; diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowNode.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowNode.java similarity index 86% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowNode.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowNode.java index d1faf4655..6ee947bc9 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowNode.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowNode.java @@ -20,9 +20,11 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.graph; import java.time.InstantSource; +import org.opendc.simulator.engine.engine.FlowEngine; +import org.opendc.simulator.engine.engine.FlowTimerQueue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,20 +44,78 @@ protected enum NodeState { protected NodeState nodeState = NodeState.PENDING; + public NodeState getNodeState() { + return nodeState; + } + + public void setNodeState(NodeState nodeState) { + this.nodeState = nodeState; + } + + public int getTimerIndex() { + return timerIndex; + } + + public void setTimerIndex(int index) { + this.timerIndex = index; + } + + public InstantSource getClock() { + return clock; + } + + public void setClock(InstantSource clock) { + this.clock = clock; + } + + public FlowGraph getParentGraph() { + return parentGraph; + } + + public void setParentGraph(FlowGraph parentGraph) { + this.parentGraph = parentGraph; + } + + public FlowEngine getEngine() { + return engine; + } + + public void setEngine(FlowEngine engine) { + this.engine = engine; + } + + /** + * Return the current deadline of the {@link FlowNode}'s timer (in milliseconds after epoch). + */ + public long getDeadline() { + return deadline; + } + + public void setDeadline(long deadline) { + this.deadline = deadline; + } + /** * The deadline of the stage after which an update should run. */ - long deadline = Long.MAX_VALUE; + private long deadline = Long.MAX_VALUE; /** * The index of the timer in the {@link FlowTimerQueue}. */ - int timerIndex = -1; + private int timerIndex = -1; protected InstantSource clock; protected FlowGraph parentGraph; protected FlowEngine engine; + /** + * Return the {@link FlowGraph} to which this stage belongs. + */ + public FlowGraph getGraph() { + return parentGraph; + } + /** * Construct a new {@link FlowNode} instance. * @@ -69,27 +129,6 @@ public FlowNode(FlowGraph parentGraph) { this.parentGraph.addNode(this); } - /** - * Return the {@link FlowGraph} to which this stage belongs. - */ - public FlowGraph getGraph() { - return parentGraph; - } - - /** - * Return the current deadline of the {@link FlowNode}'s timer (in milliseconds after epoch). - */ - public long getDeadline() { - return deadline; - } - - public void setDeadline(long deadline) { - this.deadline = deadline; - } - - public void setTimerIndex(int index) { - this.timerIndex = index; - } /** * Invalidate the {@link FlowNode} forcing the stage to update. * diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowSupplier.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java similarity index 97% rename from opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowSupplier.java rename to opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java index 955f49436..84602ee0c 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/FlowSupplier.java +++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/engine/graph/FlowSupplier.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.simulator.engine; +package org.opendc.simulator.engine.graph; public interface FlowSupplier { diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/InvocationStackTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/InvocationStackTest.kt index 7744d7b21..4dd17dbe5 100644 --- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/InvocationStackTest.kt +++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/InvocationStackTest.kt @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test -import org.opendc.simulator.engine.InvocationStack +import org.opendc.simulator.engine.engine.InvocationStack /** * Test suite for the [InvocationStack] class.