diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-10-06 15:34:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-06 15:34:19 +0200 |
| commit | 7ba3b953300c46b4e3afcde17cd3dd14b1af8406 (patch) | |
| tree | 950ba678869ec868c26ab3b95b57e4cabadb23c7 /opendc-simulator/opendc-simulator-flow | |
| parent | c2047d09b27b0c05f5c203509dde524e17d3b729 (diff) | |
| parent | 47357afd16f928260db34d4dd3e686fb9ee7c5ff (diff) | |
merge: Update build and runtime dependencies (#107)
This pull request updates the build and runtime dependencies used by OpenDC to their latest
version compatible with the project.
## Implementation Notes :hammer_and_pick:
* Update simulator dependency versions
* Remove unused distribution conventions
* Update next version to 3.0
* Eliminate use of wildcard imports
* Switch to Spotless for formatting
Diffstat (limited to 'opendc-simulator/opendc-simulator-flow')
12 files changed, 84 insertions, 36 deletions
diff --git a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt b/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt index 86fbe8e4..58f84d82 100644 --- a/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt +++ b/opendc-simulator/opendc-simulator-flow/src/jmh/kotlin/org/opendc/simulator/flow/FlowBenchmarks.kt @@ -22,13 +22,18 @@ package org.opendc.simulator.flow -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch import org.opendc.simulator.flow.mux.ForwardingFlowMultiplexer import org.opendc.simulator.flow.mux.MaxMinFlowMultiplexer import org.opendc.simulator.flow.source.TraceFlowSource import org.opendc.simulator.kotlin.runSimulation -import org.openjdk.jmh.annotations.* +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.concurrent.ThreadLocalRandom import java.util.concurrent.TimeUnit @@ -36,7 +41,6 @@ import java.util.concurrent.TimeUnit @Fork(1) @Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS) -@OptIn(ExperimentalCoroutinesApi::class) class FlowBenchmarks { private lateinit var trace: Sequence<TraceFlowSource.Fragment> diff --git a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/FlowForwarder.kt b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/FlowForwarder.kt index 6fa2971a..5202c252 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/FlowForwarder.kt +++ b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/FlowForwarder.kt @@ -226,10 +226,11 @@ public class FlowForwarder( * Reset the delegate. */ private fun reset() { - if (isCoupled) + if (isCoupled) { _innerCtx?.close() - else + } else { _innerCtx?.push(0.0) + } delegate = null hasDelegateStarted = false diff --git a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowConsumerContextImpl.kt b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowConsumerContextImpl.kt index bc6bae71..fba3af5f 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowConsumerContextImpl.kt +++ b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowConsumerContextImpl.kt @@ -23,8 +23,11 @@ package org.opendc.simulator.flow.internal import mu.KotlinLogging -import org.opendc.simulator.flow.* -import java.util.* +import org.opendc.simulator.flow.FlowConsumerContext +import org.opendc.simulator.flow.FlowConsumerLogic +import org.opendc.simulator.flow.FlowSource +import org.opendc.simulator.flow.batch +import java.util.ArrayDeque import kotlin.math.min /** @@ -84,19 +87,21 @@ internal class FlowConsumerContextImpl( get() = _flags and ConnConvergeSource == ConnConvergeSource set(value) { _flags = - if (value) + if (value) { _flags or ConnConvergeSource - else + } else { _flags and ConnConvergeSource.inv() + } } override var shouldConsumerConverge: Boolean get() = _flags and ConnConvergeConsumer == ConnConvergeConsumer set(value) { _flags = - if (value) + if (value) { _flags or ConnConvergeConsumer - else + } else { _flags and ConnConvergeConsumer.inv() + } } /** @@ -106,10 +111,11 @@ internal class FlowConsumerContextImpl( get() = _flags and ConnDisableTimers != ConnDisableTimers set(value) { _flags = - if (!value) + if (!value) { _flags or ConnDisableTimers - else + } else { _flags and ConnDisableTimers.inv() + } } /** @@ -238,10 +244,11 @@ internal class FlowConsumerContextImpl( // IMPORTANT: Re-fetch the flags after the callback might have changed those flags = _flags - if (duration != Long.MAX_VALUE) + if (duration != Long.MAX_VALUE) { now + duration - else + } else { duration + } } else { deadline } diff --git a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowDeque.kt b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowDeque.kt index 94232954..403a9aec 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowDeque.kt +++ b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowDeque.kt @@ -22,7 +22,7 @@ package org.opendc.simulator.flow.internal -import java.util.* +import java.util.ArrayDeque /** * A specialized [ArrayDeque] that tracks the [FlowConsumerContextImpl] instances that have updated in an interpreter diff --git a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowEngineImpl.kt b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowEngineImpl.kt index 3c79d54e..6fd1ef31 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowEngineImpl.kt +++ b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/internal/FlowEngineImpl.kt @@ -26,9 +26,12 @@ import kotlinx.coroutines.Delay import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.InternalCoroutinesApi import kotlinx.coroutines.Runnable -import org.opendc.simulator.flow.* +import org.opendc.simulator.flow.FlowConsumerContext +import org.opendc.simulator.flow.FlowConsumerLogic +import org.opendc.simulator.flow.FlowEngine +import org.opendc.simulator.flow.FlowSource import java.time.Clock -import java.util.* +import java.util.ArrayDeque import kotlin.coroutines.ContinuationInterceptor import kotlin.coroutines.CoroutineContext diff --git a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexer.kt b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexer.kt index c50e9bbc..53f94a94 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexer.kt +++ b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexer.kt @@ -22,7 +22,13 @@ package org.opendc.simulator.flow.mux -import org.opendc.simulator.flow.* +import org.opendc.simulator.flow.FlowConnection +import org.opendc.simulator.flow.FlowConsumer +import org.opendc.simulator.flow.FlowConvergenceListener +import org.opendc.simulator.flow.FlowCounters +import org.opendc.simulator.flow.FlowEngine +import org.opendc.simulator.flow.FlowForwarder +import org.opendc.simulator.flow.FlowSource import java.util.ArrayDeque /** diff --git a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt index f2a4c1a4..d9c6f893 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt +++ b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt @@ -22,7 +22,14 @@ package org.opendc.simulator.flow.mux -import org.opendc.simulator.flow.* +import org.opendc.simulator.flow.FlowConnection +import org.opendc.simulator.flow.FlowConsumer +import org.opendc.simulator.flow.FlowConsumerContext +import org.opendc.simulator.flow.FlowConsumerLogic +import org.opendc.simulator.flow.FlowConvergenceListener +import org.opendc.simulator.flow.FlowCounters +import org.opendc.simulator.flow.FlowEngine +import org.opendc.simulator.flow.FlowSource import org.opendc.simulator.flow.internal.D_MS_TO_S import org.opendc.simulator.flow.internal.MutableFlowCounters import kotlin.math.min @@ -248,7 +255,6 @@ public class MaxMinFlowMultiplexer( * This method is invoked when one of the inputs converges. */ fun convergeInput(input: Input, now: Long) { - val lastConverge = _lastConverge val lastConvergeInput = _lastConvergeInput val parent = parent @@ -511,7 +517,7 @@ public class MaxMinFlowMultiplexer( private val engine: FlowEngine, private val scheduler: Scheduler, @JvmField val isCoupled: Boolean, - initialCapacity: Double, + initialCapacity: Double ) : FlowConsumer, FlowConsumerLogic, Comparable<Input> { /** * A flag to indicate that the consumer is active. @@ -780,10 +786,11 @@ public class MaxMinFlowMultiplexer( return if (_isActivationOutput) { // If this output is the activation output, synchronously run the scheduler and return the new deadline val deadline = scheduler.runScheduler(now) - if (deadline == Long.MAX_VALUE) + if (deadline == Long.MAX_VALUE) { deadline - else + } else { deadline - now + } } else { // Output is not the activation output, so trigger activation output and do not install timer for this // output (by returning `Long.MAX_VALUE`) diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt index d782d036..f89133dd 100644 --- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt +++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowConsumerContextTest.kt @@ -22,8 +22,11 @@ package org.opendc.simulator.flow -import io.mockk.* -import org.junit.jupiter.api.* +import io.mockk.spyk +import io.mockk.verify +import net.bytebuddy.matcher.ElementMatchers.any +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows import org.opendc.simulator.flow.internal.FlowConsumerContextImpl import org.opendc.simulator.flow.internal.FlowEngineImpl import org.opendc.simulator.kotlin.runSimulation diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt index 2025dd52..f75e5037 100644 --- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt +++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowForwarderTest.kt @@ -22,9 +22,17 @@ package org.opendc.simulator.flow -import io.mockk.* -import kotlinx.coroutines.* -import org.junit.jupiter.api.Assertions.* +import io.mockk.spyk +import io.mockk.verify +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.yield +import net.bytebuddy.matcher.ElementMatchers.any +import org.junit.jupiter.api.Assertions.assertAll +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.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt index 22a84edb..746d752d 100644 --- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt +++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/FlowSinkTest.kt @@ -24,9 +24,13 @@ package org.opendc.simulator.flow import io.mockk.spyk import io.mockk.verify -import kotlinx.coroutines.* -import org.junit.jupiter.api.* +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.yield import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows import org.opendc.simulator.flow.internal.FlowEngineImpl import org.opendc.simulator.flow.source.FixedFlowSource import org.opendc.simulator.flow.source.FlowSourceRateAdapter diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt index cfd2bdf0..2409e174 100644 --- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt +++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/ForwardingFlowMultiplexerTest.kt @@ -27,7 +27,11 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertAll import org.junit.jupiter.api.assertThrows -import org.opendc.simulator.flow.* +import org.opendc.simulator.flow.FlowConnection +import org.opendc.simulator.flow.FlowForwarder +import org.opendc.simulator.flow.FlowSink +import org.opendc.simulator.flow.FlowSource +import org.opendc.simulator.flow.consume import org.opendc.simulator.flow.internal.FlowEngineImpl import org.opendc.simulator.flow.source.FixedFlowSource import org.opendc.simulator.flow.source.FlowSourceRateAdapter @@ -55,7 +59,7 @@ internal class ForwardingFlowMultiplexerTest { TraceFlowSource.Fragment(duration * 1000, 3500.0), TraceFlowSource.Fragment(duration * 1000, 0.0), TraceFlowSource.Fragment(duration * 1000, 183.0) - ), + ) ) val switch = ForwardingFlowMultiplexer(engine) diff --git a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt index 4e242292..a6bf8ad8 100644 --- a/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt +++ b/opendc-simulator/opendc-simulator-flow/src/test/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexerTest.kt @@ -25,8 +25,9 @@ package org.opendc.simulator.flow.mux import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.yield -import org.junit.jupiter.api.* +import org.junit.jupiter.api.Assertions.assertAll import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test import org.opendc.simulator.flow.FlowSink import org.opendc.simulator.flow.consume import org.opendc.simulator.flow.internal.FlowEngineImpl @@ -72,7 +73,7 @@ internal class MaxMinFlowMultiplexerTest { TraceFlowSource.Fragment(duration * 1000, 3500.0), TraceFlowSource.Fragment(duration * 1000, 0.0), TraceFlowSource.Fragment(duration * 1000, 183.0) - ), + ) ) val switch = MaxMinFlowMultiplexer(scheduler) @@ -110,7 +111,7 @@ internal class MaxMinFlowMultiplexerTest { TraceFlowSource.Fragment(duration * 1000, 3500.0), TraceFlowSource.Fragment(duration * 1000, 0.0), TraceFlowSource.Fragment(duration * 1000, 183.0) - ), + ) ) val workloadB = TraceFlowSource( |
