From a7e1888383a677708d58365df423935722de511c Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 6 Sep 2017 11:25:33 +0200 Subject: Rename kernel package to simulator This change renames the package named 'kernel' to 'simulator' to better convey the use of this package. --- .../nl/atlarge/opendc/kernel/ChannelContext.kt | 35 --- .../kotlin/nl/atlarge/opendc/kernel/Context.kt | 68 ------ .../nl/atlarge/opendc/kernel/DefaultSimulator.kt | 237 --------------------- .../nl/atlarge/opendc/kernel/EntityContext.kt | 45 ---- .../main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt | 46 ---- .../kotlin/nl/atlarge/opendc/kernel/Simulator.kt | 44 ---- .../kotlin/nl/atlarge/opendc/kernel/clock/Clock.kt | 53 ----- .../nl/atlarge/opendc/kernel/messaging/Channel.kt | 49 ----- .../opendc/kernel/messaging/DuplexChannel.kt | 33 --- .../atlarge/opendc/kernel/messaging/DuplexPort.kt | 33 --- .../nl/atlarge/opendc/kernel/messaging/Envelope.kt | 44 ---- .../nl/atlarge/opendc/kernel/messaging/Port.kt | 33 --- .../nl/atlarge/opendc/kernel/messaging/Readable.kt | 47 ---- .../opendc/kernel/messaging/ReadableChannel.kt | 33 --- .../opendc/kernel/messaging/ReadablePort.kt | 33 --- .../nl/atlarge/opendc/kernel/messaging/Writable.kt | 42 ---- .../opendc/kernel/messaging/WritableChannel.kt | 33 --- .../opendc/kernel/messaging/WritablePort.kt | 33 --- .../nl/atlarge/opendc/simulator/ChannelContext.kt | 35 +++ .../kotlin/nl/atlarge/opendc/simulator/Context.kt | 68 ++++++ .../atlarge/opendc/simulator/DefaultSimulator.kt | 237 +++++++++++++++++++++ .../nl/atlarge/opendc/simulator/EntityContext.kt | 45 ++++ .../kotlin/nl/atlarge/opendc/simulator/Kernel.kt | 46 ++++ .../nl/atlarge/opendc/simulator/Simulator.kt | 44 ++++ .../nl/atlarge/opendc/simulator/clock/Clock.kt | 53 +++++ .../atlarge/opendc/simulator/messaging/Channel.kt | 49 +++++ .../opendc/simulator/messaging/DuplexChannel.kt | 33 +++ .../opendc/simulator/messaging/DuplexPort.kt | 33 +++ .../atlarge/opendc/simulator/messaging/Envelope.kt | 44 ++++ .../nl/atlarge/opendc/simulator/messaging/Port.kt | 33 +++ .../atlarge/opendc/simulator/messaging/Readable.kt | 47 ++++ .../opendc/simulator/messaging/ReadableChannel.kt | 33 +++ .../opendc/simulator/messaging/ReadablePort.kt | 33 +++ .../atlarge/opendc/simulator/messaging/Writable.kt | 42 ++++ .../opendc/simulator/messaging/WritableChannel.kt | 33 +++ .../opendc/simulator/messaging/WritablePort.kt | 33 +++ .../nl/atlarge/opendc/topology/machine/Machine.kt | 4 +- .../src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt | 2 +- 38 files changed, 944 insertions(+), 944 deletions(-) delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/ChannelContext.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/DefaultSimulator.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/EntityContext.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulator.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/clock/Clock.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Channel.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexChannel.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexPort.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Port.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadableChannel.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadablePort.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritableChannel.kt delete mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritablePort.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/ChannelContext.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Context.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/DefaultSimulator.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/EntityContext.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Kernel.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Simulator.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/clock/Clock.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Channel.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexChannel.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexPort.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Envelope.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Port.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Readable.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadableChannel.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadablePort.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Writable.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritableChannel.kt create mode 100644 opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritablePort.kt (limited to 'opendc-core') diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/ChannelContext.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/ChannelContext.kt deleted file mode 100644 index aaf5abba..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/ChannelContext.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel - -import nl.atlarge.opendc.kernel.messaging.Writable -import nl.atlarge.opendc.topology.Edge - -/** - * The context provided to a simulation kernel for communication channels between entities. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface ChannelContext: Context>, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt deleted file mode 100644 index 37d21d60..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel - -import nl.atlarge.opendc.kernel.messaging.Readable -import nl.atlarge.opendc.topology.Component -import nl.atlarge.opendc.topology.Entity -import nl.atlarge.opendc.topology.Topology - -/** - * The [Context] interface provides a context for a simulation kernel, which defines the environment in which the - * simulation is run. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Context>: Readable { - /** - * The [Topology] over which the simulation is run. - */ - val topology: Topology - - /** - * The [Component] that is simulated. - */ - val component: T - - /** - * The observable state of an [Entity] within the simulation is provided by context. - */ - val Entity.state: S - - /** - * Suspend the simulation kernel until the next tick occurs in the simulation. - */ - suspend fun tick(): Boolean { - wait(1) - return true - } - - /** - * Suspend the simulation kernel for n ticks before resuming the execution. - * - * @param n The amount of ticks to suspend the simulation kernel. - */ - suspend fun wait(n: Int) -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/DefaultSimulator.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/DefaultSimulator.kt deleted file mode 100644 index a3d978e4..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/DefaultSimulator.kt +++ /dev/null @@ -1,237 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel - -import mu.KotlinLogging -import nl.atlarge.opendc.kernel.clock.Clock -import nl.atlarge.opendc.kernel.clock.Tick -import nl.atlarge.opendc.kernel.messaging.Envelope -import nl.atlarge.opendc.topology.* -import java.util.* -import kotlin.coroutines.experimental.* - -/** - * A [DefaultSimulator] runs the simulation over the specified topology. - * - * @param topology The topology to run the simulation over. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -class DefaultSimulator(override val topology: Topology): Simulator, Iterator { - /** - * The logger instance to use for the simulator. - */ - private val logger = KotlinLogging.logger {} - - /** - * The registry of the simulation kernels used in the experiment. - */ - private val registry: MutableMap, Context<*>?> = HashMap() - - /** - * A mapping of the entities in the topology to their current state. - */ - private val states: MutableMap, Any?> = HashMap() - - /** - * The clock of the simulator. - */ - private val clock: DefaultClock = DefaultClock() - - /** - * Initialize the simulator. - */ - init { - topology.forEach { node -> - resolve(node) - node.outgoingEdges().forEach { resolve(it) } - } - - registry.values.forEach { context -> - if (context == null) - return@forEach - @Suppress("UNCHECKED_CAST") - val kernel = context.component.label as Kernel> - - // Start all kernel co-routines - val block: suspend () -> Unit = { kernel.run { context.simulate() } } - block.startCoroutine(KernelCoroutine()) - } - } - - /** - * Resolve the given [Component] to the [Kernel] of that component. - * - * @param component The component to resolve. - * @return The [Kernel] that simulates that [Component]. - */ - fun > resolve(component: T): Context? { - @Suppress("UNCHECKED_CAST") - return registry.computeIfAbsent(component, { - if (component.label !is Kernel<*>) - null - else when (component) { - is Node<*> -> DefaultEntityContext(component as Node<*>) - is Edge<*> -> DefaultChannelContext(component as Edge<*>) - else -> null - } - }) as Context? - } - - /** - * Determine whether the simulator has a next non-empty cycle available. - * - * @return true if the simulator has a next non-empty cycle, false otherwise. - */ - override fun hasNext(): Boolean = clock.queue.isNotEmpty() - - /** - * Run the next cycle in the simulation. - */ - override fun next() { - clock.tick++ - while (true) { - val (tick, block) = clock.queue.peek() ?: return - - if (tick > clock.tick) - // Tick has yet to occur - break - else if (tick < clock.tick) - // Tick has already occurred - logger.warn {"tick was not handled correctly"} - - clock.queue.poll() - block() - } - } - - /** - * The co-routine which runs a simulation kernel. - */ - private class KernelCoroutine: Continuation { - override val context: CoroutineContext = EmptyCoroutineContext - override fun resume(value: Unit) {} - - override fun resumeWithException(exception: Throwable) { - val currentThread = Thread.currentThread() - currentThread.uncaughtExceptionHandler.uncaughtException(currentThread, exception) - } - } - - /** - * The [Context] for an entity within the simulation. - */ - private inner class DefaultEntityContext>(override val component: Node): EntityContext { - /** - * The [Topology] over which the simulation is run. - */ - override val topology: Topology = this@DefaultSimulator.topology - - /** - * Retrieves and removes a single message from this channel suspending the caller while the channel is empty. - * - * @param block The block to process the message with. - * @return The processed message. - */ - suspend override fun receive(block: Envelope<*>.(Any?) -> T): T = suspendCoroutine {} - - /** - * The observable state of an [Entity] within the simulation is provided by context. - */ - @Suppress("UNCHECKED_CAST") - override val Entity.state: S - get() = states.computeIfAbsent(this, { initialState }) as S - - /** - * Update the state of the entity being simulated. - * - *

Instead of directly mutating the entity, we create a new instance of the entity to prevent other objects - * referencing the old entity having their data changed. - * - * @param next The next state of the entity. - */ - suspend override fun , E: Entity, S> C.update(next: S) { - states.put(component.entity as Entity<*>, next) - } - - /** - * Suspend the simulation kernel for n ticks before resuming the execution. - * - * @param n The amount of ticks to suspend the simulation kernel. - */ - suspend override fun wait(n: Int): Unit = suspendCoroutine { cont -> clock.scheduleAfter(n, { cont.resume(Unit) }) } - } - - /** - * The [Context] for an edge within the simulation. - */ - private inner class DefaultChannelContext(override val component: Edge): ChannelContext { - /** - * The [Topology] over which the simulation is run. - */ - override val topology: Topology = this@DefaultSimulator.topology - - /** - * Retrieves and removes a single message from this channel suspending the caller while the channel is empty. - * - * @param block The block to process the message with. - * @return The processed message. - */ - suspend override fun receive(block: Envelope<*>.(Any?) -> T): T = suspendCoroutine {} - - /** - * Send the given message downstream. - * - * @param msg The message to send. - * @param sender The sender of the message. - */ - suspend override fun send(msg: Any?, sender: Node<*>): Unit = suspendCoroutine {} - - /** - * The observable state of an [Entity] within the simulation is provided by context. - */ - @Suppress("UNCHECKED_CAST") - override val Entity.state: S - get() = states.computeIfAbsent(this, { initialState }) as S - - /** - * Suspend the simulation kernel for n ticks before resuming the execution. - * - * @param n The amount of ticks to suspend the simulation kernel. - */ - suspend override fun wait(n: Int): Unit = suspendCoroutine { cont -> clock.scheduleAfter(n, { cont.resume(Unit) }) } - } - - /** - * The [Clock] for this [DefaultSimulator] that keeps track of the simulation time in ticks. - */ - private inner class DefaultClock: Clock { - override var tick: Tick = 0 - internal val queue: PriorityQueue Unit>> = PriorityQueue(Comparator.comparingLong { it.first }) - - override fun scheduleAt(tick: Tick, block: () -> Unit) { - queue.add(Pair(tick, block)) - } - } -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/EntityContext.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/EntityContext.kt deleted file mode 100644 index ea9c6b04..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/EntityContext.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel - -import nl.atlarge.opendc.topology.Entity -import nl.atlarge.opendc.topology.Node - -/** - * The context provided to a simulation kernel for stateful entities in the topology. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface EntityContext>: Context> { - /** - * Update the state of the entity being simulated. - * - *

Instead of directly mutating the entity, we create a new instance of the entity to prevent other objects - * referencing the old entity having their data changed. - * - * @param next The next state of the entity. - */ - suspend fun , E: Entity, S> C.update(next: S) -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt deleted file mode 100644 index 4a289580..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel - -import nl.atlarge.opendc.topology.Component - -/** - * A simulation kernel that simulates a single [Component] instance in a cloud network. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Kernel> { - /** - * This method is invoked to start the simulation of the [Component] associated with this [Kernel]. - * - *

This method is assumed to be running during the experiment, but should hand back control to the simulator at - * some point by calling [Context.tick] to wait for the next tick to occur, which allows to allows other entity - * simulators to do work in the current tick of the simulation. - * - *

If this method exists early, before the simulation has finished, the entity is assumed to be shutdown and its - * simulation will not run any further. - */ - suspend fun C.simulate() -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulator.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulator.kt deleted file mode 100644 index f336bf1b..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulator.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel - -import nl.atlarge.opendc.topology.Topology - -/** - * A [Simulator] implementation runs a simulation over the specified topology. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Simulator { - /** - * The [Topology] over which the simulation runs. - */ - val topology: Topology - - /** - * Run the next cycle in the simulation. - */ - fun next() -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/clock/Clock.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/clock/Clock.kt deleted file mode 100644 index db13eee1..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/clock/Clock.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.clock - -/** - * A tick represents a moment of time in which some work is done by an entity. - */ -typealias Tick = Long - -/** - * The clock of a simulation manages the ticks that have elapsed and schedules the tick events. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Clock { - /** - * The tick the clock is currently at. - */ - val tick: Tick - - /** - * - * @throws IllegalArgumentException - */ - fun scheduleAt(tick: Tick, block: () -> Unit) - - /** - * @throws IllegalArgumentException - */ - fun scheduleAfter(n: Int, block: () -> Unit) = scheduleAt(tick + n, block) -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Channel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Channel.kt deleted file mode 100644 index ad966719..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Channel.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -import nl.atlarge.opendc.topology.Edge -import nl.atlarge.opendc.topology.Node - -/** - * A unidirectional communication channel between two [Node] instances as seen from one of the entities. - * - *

A [Channel] is viewed as a directed edge that connects two entities in the topology of a cloud network. - * - * @param T The shape of the label of the edge of this channel. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Channel { - /** - * The directed edge between two nodes which represents this unidirectional communication channel. - */ - val edge: Edge - - /** - * The channel the message originates from. - */ - val Envelope<*>.channel: Channel - get() = this@Channel -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexChannel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexChannel.kt deleted file mode 100644 index a4ef7409..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexChannel.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A [DuplexChannel] instance allows bi-directional communication over the channel. - * - * @param T The shape of the label of the edge of this channel. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface DuplexChannel: Channel, Readable, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexPort.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexPort.kt deleted file mode 100644 index 5917ac71..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/DuplexPort.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A [DuplexPort] instance allows bi-directional communication with multiple channels. - * - * @param T The shape of the label of the edges of the channels of this port. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface DuplexPort: Port>, Readable, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt deleted file mode 100644 index d4d363d5..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Envelope.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -import nl.atlarge.opendc.topology.Node - -/** - * The envelope of a message that is received from a [Channel], also containing the metadata of the message. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -data class Envelope( - /** - * The message in this envelope. - */ - val message: T, - - /** - * The sender of the message. - */ - val sender: Node<*> -) diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Port.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Port.kt deleted file mode 100644 index 18ec1918..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Port.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A port connects multiple [Channel]s to an entity in the topology of a cloud network. - * - * @param C The shape of the channels that are connected to this port. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Port>: Iterable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt deleted file mode 100644 index 422c5668..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Readable.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A [Readable] instance allows objects to pull messages from the instance. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Readable { - /** - * Retrieves and removes a single message from this channel suspending the caller while the channel is empty. - * - * @param block The block to process the message with. - * @return The processed message. - */ - suspend fun receive(block: Envelope<*>.(Any?) -> T): T - - /** - * Retrieve a single message from this [Channel]. - * - * @return The message that was received from the channel - */ - suspend fun receive(): Any? = receive { it } -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadableChannel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadableChannel.kt deleted file mode 100644 index c291b1ea..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadableChannel.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A [ReadableChannel] instance allows objects to receive messages from the channel. - * - * @param T The shape of the label of the edge of this channel. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface ReadableChannel: Channel, Readable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadablePort.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadablePort.kt deleted file mode 100644 index bfad9490..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/ReadablePort.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A [ReadablePort] instance allows objects to receive messages from the channel. - * - * @param T The shape of the label of the edges of the channels of this port. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface ReadablePort: Port>, Readable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt deleted file mode 100644 index 6bd1ce30..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/Writable.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -import nl.atlarge.opendc.topology.Node - -/** - * A [Writable] instance allows objects to send messages to it. - * - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface Writable { - /** - * Send the given message downstream. - * - * @param msg The message to send. - * @param sender The sender of the message. - */ - suspend fun send(msg: Any?, sender: Node<*>) -} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritableChannel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritableChannel.kt deleted file mode 100644 index 60f89a97..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritableChannel.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A [WritableChannel] instance allows objects to write messages to the channel. - * - * @param T The shape of the label of the edge of this channel. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface WritableChannel: Channel, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritablePort.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritablePort.kt deleted file mode 100644 index 0dc92680..00000000 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/messaging/WritablePort.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 nl.atlarge.opendc.kernel.messaging - -/** - * A [WritablePort] instance allows objects to write messages to multiple channels. - * - * @param T The shape of the label of the edges of the channels of this port. - * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) - */ -interface WritablePort: Port>, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/ChannelContext.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/ChannelContext.kt new file mode 100644 index 00000000..dee55730 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/ChannelContext.kt @@ -0,0 +1,35 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator + +import nl.atlarge.opendc.simulator.messaging.Writable +import nl.atlarge.opendc.topology.Edge + +/** + * The context provided to a simulation kernel for communication channels between entities. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface ChannelContext: Context>, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Context.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Context.kt new file mode 100644 index 00000000..61ba8192 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Context.kt @@ -0,0 +1,68 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator + +import nl.atlarge.opendc.simulator.messaging.Readable +import nl.atlarge.opendc.topology.Component +import nl.atlarge.opendc.topology.Entity +import nl.atlarge.opendc.topology.Topology + +/** + * The [Context] interface provides a context for a simulation kernel, which defines the environment in which the + * simulation is run. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Context>: Readable { + /** + * The [Topology] over which the simulation is run. + */ + val topology: Topology + + /** + * The [Component] that is simulated. + */ + val component: T + + /** + * The observable state of an [Entity] within the simulation is provided by context. + */ + val Entity.state: S + + /** + * Suspend the simulation kernel until the next tick occurs in the simulation. + */ + suspend fun tick(): Boolean { + wait(1) + return true + } + + /** + * Suspend the simulation kernel for n ticks before resuming the execution. + * + * @param n The amount of ticks to suspend the simulation kernel. + */ + suspend fun wait(n: Int) +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/DefaultSimulator.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/DefaultSimulator.kt new file mode 100644 index 00000000..6f025ed1 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/DefaultSimulator.kt @@ -0,0 +1,237 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator + +import mu.KotlinLogging +import nl.atlarge.opendc.simulator.clock.Clock +import nl.atlarge.opendc.simulator.clock.Tick +import nl.atlarge.opendc.simulator.messaging.Envelope +import nl.atlarge.opendc.topology.* +import java.util.* +import kotlin.coroutines.experimental.* + +/** + * A [DefaultSimulator] runs the simulation over the specified topology. + * + * @param topology The topology to run the simulation over. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +class DefaultSimulator(override val topology: Topology): Simulator, Iterator { + /** + * The logger instance to use for the simulator. + */ + private val logger = KotlinLogging.logger {} + + /** + * The registry of the simulation kernels used in the experiment. + */ + private val registry: MutableMap, Context<*>?> = HashMap() + + /** + * A mapping of the entities in the topology to their current state. + */ + private val states: MutableMap, Any?> = HashMap() + + /** + * The clock of the simulator. + */ + private val clock: DefaultClock = DefaultClock() + + /** + * Initialize the simulator. + */ + init { + topology.forEach { node -> + resolve(node) + node.outgoingEdges().forEach { resolve(it) } + } + + registry.values.forEach { context -> + if (context == null) + return@forEach + @Suppress("UNCHECKED_CAST") + val kernel = context.component.label as Kernel> + + // Start all kernel co-routines + val block: suspend () -> Unit = { kernel.run { context.simulate() } } + block.startCoroutine(KernelCoroutine()) + } + } + + /** + * Resolve the given [Component] to the [Kernel] of that component. + * + * @param component The component to resolve. + * @return The [Kernel] that simulates that [Component]. + */ + fun > resolve(component: T): Context? { + @Suppress("UNCHECKED_CAST") + return registry.computeIfAbsent(component, { + if (component.label !is Kernel<*>) + null + else when (component) { + is Node<*> -> DefaultEntityContext(component as Node<*>) + is Edge<*> -> DefaultChannelContext(component as Edge<*>) + else -> null + } + }) as Context? + } + + /** + * Determine whether the simulator has a next non-empty cycle available. + * + * @return true if the simulator has a next non-empty cycle, false otherwise. + */ + override fun hasNext(): Boolean = clock.queue.isNotEmpty() + + /** + * Run the next cycle in the simulation. + */ + override fun next() { + clock.tick++ + while (true) { + val (tick, block) = clock.queue.peek() ?: return + + if (tick > clock.tick) + // Tick has yet to occur + break + else if (tick < clock.tick) + // Tick has already occurred + logger.warn {"tick was not handled correctly"} + + clock.queue.poll() + block() + } + } + + /** + * The co-routine which runs a simulation kernel. + */ + private class KernelCoroutine: Continuation { + override val context: CoroutineContext = EmptyCoroutineContext + override fun resume(value: Unit) {} + + override fun resumeWithException(exception: Throwable) { + val currentThread = Thread.currentThread() + currentThread.uncaughtExceptionHandler.uncaughtException(currentThread, exception) + } + } + + /** + * The [Context] for an entity within the simulation. + */ + private inner class DefaultEntityContext>(override val component: Node): EntityContext { + /** + * The [Topology] over which the simulation is run. + */ + override val topology: Topology = this@DefaultSimulator.topology + + /** + * Retrieves and removes a single message from this channel suspending the caller while the channel is empty. + * + * @param block The block to process the message with. + * @return The processed message. + */ + suspend override fun receive(block: Envelope<*>.(Any?) -> T): T = suspendCoroutine {} + + /** + * The observable state of an [Entity] within the simulation is provided by context. + */ + @Suppress("UNCHECKED_CAST") + override val Entity.state: S + get() = states.computeIfAbsent(this, { initialState }) as S + + /** + * Update the state of the entity being simulated. + * + *

Instead of directly mutating the entity, we create a new instance of the entity to prevent other objects + * referencing the old entity having their data changed. + * + * @param next The next state of the entity. + */ + suspend override fun , E: Entity, S> C.update(next: S) { + states.put(component.entity as Entity<*>, next) + } + + /** + * Suspend the simulation kernel for n ticks before resuming the execution. + * + * @param n The amount of ticks to suspend the simulation kernel. + */ + suspend override fun wait(n: Int): Unit = suspendCoroutine { cont -> clock.scheduleAfter(n, { cont.resume(Unit) }) } + } + + /** + * The [Context] for an edge within the simulation. + */ + private inner class DefaultChannelContext(override val component: Edge): ChannelContext { + /** + * The [Topology] over which the simulation is run. + */ + override val topology: Topology = this@DefaultSimulator.topology + + /** + * Retrieves and removes a single message from this channel suspending the caller while the channel is empty. + * + * @param block The block to process the message with. + * @return The processed message. + */ + suspend override fun receive(block: Envelope<*>.(Any?) -> T): T = suspendCoroutine {} + + /** + * Send the given message downstream. + * + * @param msg The message to send. + * @param sender The sender of the message. + */ + suspend override fun send(msg: Any?, sender: Node<*>): Unit = suspendCoroutine {} + + /** + * The observable state of an [Entity] within the simulation is provided by context. + */ + @Suppress("UNCHECKED_CAST") + override val Entity.state: S + get() = states.computeIfAbsent(this, { initialState }) as S + + /** + * Suspend the simulation kernel for n ticks before resuming the execution. + * + * @param n The amount of ticks to suspend the simulation kernel. + */ + suspend override fun wait(n: Int): Unit = suspendCoroutine { cont -> clock.scheduleAfter(n, { cont.resume(Unit) }) } + } + + /** + * The [Clock] for this [DefaultSimulator] that keeps track of the simulation time in ticks. + */ + private inner class DefaultClock: Clock { + override var tick: Tick = 0 + internal val queue: PriorityQueue Unit>> = PriorityQueue(Comparator.comparingLong { it.first }) + + override fun scheduleAt(tick: Tick, block: () -> Unit) { + queue.add(Pair(tick, block)) + } + } +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/EntityContext.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/EntityContext.kt new file mode 100644 index 00000000..3cbbea71 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/EntityContext.kt @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator + +import nl.atlarge.opendc.topology.Entity +import nl.atlarge.opendc.topology.Node + +/** + * The context provided to a simulation kernel for stateful entities in the topology. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface EntityContext>: Context> { + /** + * Update the state of the entity being simulated. + * + *

Instead of directly mutating the entity, we create a new instance of the entity to prevent other objects + * referencing the old entity having their data changed. + * + * @param next The next state of the entity. + */ + suspend fun , E: Entity, S> C.update(next: S) +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Kernel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Kernel.kt new file mode 100644 index 00000000..0e0a62a6 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Kernel.kt @@ -0,0 +1,46 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator + +import nl.atlarge.opendc.topology.Component + +/** + * A simulation kernel that simulates a single [Component] instance in a cloud network. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Kernel> { + /** + * This method is invoked to start the simulation of the [Component] associated with this [Kernel]. + * + *

This method is assumed to be running during the experiment, but should hand back control to the simulator at + * some point by calling [Context.tick] to wait for the next tick to occur, which allows to allows other entity + * simulators to do work in the current tick of the simulation. + * + *

If this method exists early, before the simulation has finished, the entity is assumed to be shutdown and its + * simulation will not run any further. + */ + suspend fun C.simulate() +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Simulator.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Simulator.kt new file mode 100644 index 00000000..23bf6818 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/Simulator.kt @@ -0,0 +1,44 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator + +import nl.atlarge.opendc.topology.Topology + +/** + * A [Simulator] implementation runs a simulation over the specified topology. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Simulator { + /** + * The [Topology] over which the simulation runs. + */ + val topology: Topology + + /** + * Run the next cycle in the simulation. + */ + fun next() +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/clock/Clock.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/clock/Clock.kt new file mode 100644 index 00000000..07377e4a --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/clock/Clock.kt @@ -0,0 +1,53 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.clock + +/** + * A tick represents a moment of time in which some work is done by an entity. + */ +typealias Tick = Long + +/** + * The clock of a simulation manages the ticks that have elapsed and schedules the tick events. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Clock { + /** + * The tick the clock is currently at. + */ + val tick: Tick + + /** + * + * @throws IllegalArgumentException + */ + fun scheduleAt(tick: Tick, block: () -> Unit) + + /** + * @throws IllegalArgumentException + */ + fun scheduleAfter(n: Int, block: () -> Unit) = scheduleAt(tick + n, block) +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Channel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Channel.kt new file mode 100644 index 00000000..35407897 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Channel.kt @@ -0,0 +1,49 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +import nl.atlarge.opendc.topology.Edge +import nl.atlarge.opendc.topology.Node + +/** + * A unidirectional communication channel between two [Node] instances as seen from one of the entities. + * + *

A [Channel] is viewed as a directed edge that connects two entities in the topology of a cloud network. + * + * @param T The shape of the label of the edge of this channel. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Channel { + /** + * The directed edge between two nodes which represents this unidirectional communication channel. + */ + val edge: Edge + + /** + * The channel the message originates from. + */ + val Envelope<*>.channel: Channel + get() = this@Channel +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexChannel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexChannel.kt new file mode 100644 index 00000000..942f56c8 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexChannel.kt @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A [DuplexChannel] instance allows bi-directional communication over the channel. + * + * @param T The shape of the label of the edge of this channel. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface DuplexChannel: Channel, Readable, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexPort.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexPort.kt new file mode 100644 index 00000000..bc67ae65 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/DuplexPort.kt @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A [DuplexPort] instance allows bi-directional communication with multiple channels. + * + * @param T The shape of the label of the edges of the channels of this port. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface DuplexPort: Port>, Readable, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Envelope.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Envelope.kt new file mode 100644 index 00000000..2c09fe8a --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Envelope.kt @@ -0,0 +1,44 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +import nl.atlarge.opendc.topology.Node + +/** + * The envelope of a message that is received from a [Channel], also containing the metadata of the message. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +data class Envelope( + /** + * The message in this envelope. + */ + val message: T, + + /** + * The sender of the message. + */ + val sender: Node<*> +) diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Port.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Port.kt new file mode 100644 index 00000000..a7d7caba --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Port.kt @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A port connects multiple [Channel]s to an entity in the topology of a cloud network. + * + * @param C The shape of the channels that are connected to this port. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Port>: Iterable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Readable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Readable.kt new file mode 100644 index 00000000..161bcbd8 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Readable.kt @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A [Readable] instance allows objects to pull messages from the instance. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Readable { + /** + * Retrieves and removes a single message from this channel suspending the caller while the channel is empty. + * + * @param block The block to process the message with. + * @return The processed message. + */ + suspend fun receive(block: Envelope<*>.(Any?) -> T): T + + /** + * Retrieve a single message from this [Channel]. + * + * @return The message that was received from the channel + */ + suspend fun receive(): Any? = receive { it } +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadableChannel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadableChannel.kt new file mode 100644 index 00000000..6bbc3b7d --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadableChannel.kt @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A [ReadableChannel] instance allows objects to receive messages from the channel. + * + * @param T The shape of the label of the edge of this channel. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface ReadableChannel: Channel, Readable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadablePort.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadablePort.kt new file mode 100644 index 00000000..a8ad6e16 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/ReadablePort.kt @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A [ReadablePort] instance allows objects to receive messages from the channel. + * + * @param T The shape of the label of the edges of the channels of this port. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface ReadablePort: Port>, Readable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Writable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Writable.kt new file mode 100644 index 00000000..c8b354b1 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/Writable.kt @@ -0,0 +1,42 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +import nl.atlarge.opendc.topology.Node + +/** + * A [Writable] instance allows objects to send messages to it. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface Writable { + /** + * Send the given message downstream. + * + * @param msg The message to send. + * @param sender The sender of the message. + */ + suspend fun send(msg: Any?, sender: Node<*>) +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritableChannel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritableChannel.kt new file mode 100644 index 00000000..fcfbd5b4 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritableChannel.kt @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A [WritableChannel] instance allows objects to write messages to the channel. + * + * @param T The shape of the label of the edge of this channel. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface WritableChannel: Channel, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritablePort.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritablePort.kt new file mode 100644 index 00000000..a475709a --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/simulator/messaging/WritablePort.kt @@ -0,0 +1,33 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 nl.atlarge.opendc.simulator.messaging + +/** + * A [WritablePort] instance allows objects to write messages to multiple channels. + * + * @param T The shape of the label of the edges of the channels of this port. + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface WritablePort: Port>, Writable diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt index 049f82b8..95594e27 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/machine/Machine.kt @@ -25,8 +25,8 @@ package nl.atlarge.opendc.topology.machine import nl.atlarge.opendc.experiment.Task -import nl.atlarge.opendc.kernel.EntityContext -import nl.atlarge.opendc.kernel.Kernel +import nl.atlarge.opendc.simulator.EntityContext +import nl.atlarge.opendc.simulator.Kernel import nl.atlarge.opendc.topology.Entity import nl.atlarge.opendc.topology.outgoing import java.util.* diff --git a/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt b/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt index 3af0f8f3..f56a13e6 100644 --- a/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt +++ b/opendc-core/src/test/kotlin/nl/atlarge/opendc/SmokeTest.kt @@ -24,7 +24,7 @@ package nl.atlarge.opendc -import nl.atlarge.opendc.kernel.DefaultSimulator +import nl.atlarge.opendc.simulator.DefaultSimulator import nl.atlarge.opendc.topology.AdjacencyListTopologyBuilder import nl.atlarge.opendc.topology.container.Rack import nl.atlarge.opendc.topology.machine.Cpu -- cgit v1.2.3