summaryrefslogtreecommitdiff
path: root/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-09 17:25:59 +0000
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-11-13 15:24:47 +0000
commit7a4b2c45a9926de59754b1d7219159656eea6e6d (patch)
tree4cf2cd842ec046128401a5b15bd42d86505422c6 /opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org
parentc22d744464f91eaa5f1aabee408351e864f36f1d (diff)
refactor: Use InstantSource as time source
This change updates the modules of OpenDC to always accept the `InstantSource` interface as source of time. Previously we used `java.time.Clock`, but this class is bound to a time zone which does not make sense for our use-cases. Since `java.time.Clock` implements `java.time.InstantSource`, it can be used in places that require an `InstantSource` as parameter. Conversion from `InstantSource` to `Clock` is also possible by invoking `InstantSource#withZone`.
Diffstat (limited to 'opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org')
-rw-r--r--opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt4
1 files changed, 2 insertions, 2 deletions
diff --git a/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt b/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt
index b622362a..2037dad4 100644
--- a/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt
+++ b/opendc-experiments/opendc-experiments-workflow/src/main/kotlin/org/opendc/experiments/workflow/TraceHelpers.kt
@@ -42,7 +42,7 @@ import org.opendc.workflow.api.Task
import org.opendc.workflow.api.WORKFLOW_TASK_CORES
import org.opendc.workflow.api.WORKFLOW_TASK_DEADLINE
import org.opendc.workflow.service.WorkflowService
-import java.time.Clock
+import java.time.InstantSource
import java.util.UUID
import kotlin.collections.HashMap
import kotlin.collections.HashSet
@@ -110,7 +110,7 @@ public fun Trace.toJobs(): List<Job> {
/**
* Helper method to replay the specified list of [jobs] and suspend execution util all jobs have finished.
*/
-public suspend fun WorkflowService.replay(clock: Clock, jobs: List<Job>) {
+public suspend fun WorkflowService.replay(clock: InstantSource, jobs: List<Job>) {
// Sort jobs by their arrival time
val orderedJobs = jobs.sortedBy { it.metadata.getOrDefault("WORKFLOW_SUBMIT_TIME", Long.MAX_VALUE) as Long }
if (orderedJobs.isEmpty()) {