summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-swf/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-10 22:10:22 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-11 11:33:25 +0200
commitb7be3400bb4b21d0cd7021e2baf1f6ce43aba189 (patch)
tree7e44a27d5d10e9f0d4b3c0dd3546fbb513175b96 /opendc-trace/opendc-trace-swf/src
parent9e8ea96270701e643f95b18d2b91583d9fca08d2 (diff)
feat(trace): Add support for WfCommons (WorkflowHub) traces
This change adds support for reading WfCommons workflow traces in OpenDC. This functionality is available in the new `opendc-trace-wfformat` module.
Diffstat (limited to 'opendc-trace/opendc-trace-swf/src')
-rw-r--r--opendc-trace/opendc-trace-swf/src/main/kotlin/org/opendc/trace/swf/SwfTaskTableReader.kt18
-rw-r--r--opendc-trace/opendc-trace-swf/src/test/kotlin/org/opendc/trace/swf/SwfTraceFormatTest.kt4
2 files changed, 9 insertions, 13 deletions
diff --git a/opendc-trace/opendc-trace-swf/src/main/kotlin/org/opendc/trace/swf/SwfTaskTableReader.kt b/opendc-trace/opendc-trace-swf/src/main/kotlin/org/opendc/trace/swf/SwfTaskTableReader.kt
index 5f879a54..3f49c770 100644
--- a/opendc-trace/opendc-trace-swf/src/main/kotlin/org/opendc/trace/swf/SwfTaskTableReader.kt
+++ b/opendc-trace/opendc-trace-swf/src/main/kotlin/org/opendc/trace/swf/SwfTaskTableReader.kt
@@ -24,6 +24,8 @@ package org.opendc.trace.swf
import org.opendc.trace.*
import java.io.BufferedReader
+import java.time.Duration
+import java.time.Instant
/**
* A [TableReader] implementation for the SWF format.
@@ -85,10 +87,10 @@ internal class SwfTaskTableReader(private val reader: BufferedReader) : TableRea
override fun <T> get(column: TableColumn<T>): T {
val res: Any = when (column) {
- TASK_ID -> getLong(TASK_ID)
- TASK_SUBMIT_TIME -> getLong(TASK_SUBMIT_TIME)
- TASK_WAIT_TIME -> getLong(TASK_WAIT_TIME)
- TASK_RUNTIME -> getLong(TASK_RUNTIME)
+ TASK_ID -> fields[COL_JOB_ID]
+ TASK_SUBMIT_TIME -> Instant.ofEpochSecond(fields[COL_SUBMIT_TIME].toLong(10))
+ TASK_WAIT_TIME -> Duration.ofSeconds(fields[COL_WAIT_TIME].toLong(10))
+ TASK_RUNTIME -> Duration.ofSeconds(fields[COL_RUN_TIME].toLong(10))
TASK_REQ_NCPUS -> getInt(TASK_REQ_NCPUS)
TASK_ALLOC_NCPUS -> getInt(TASK_ALLOC_NCPUS)
TASK_PARENTS -> {
@@ -121,13 +123,7 @@ internal class SwfTaskTableReader(private val reader: BufferedReader) : TableRea
}
override fun getLong(column: TableColumn<Long>): Long {
- return when (column) {
- TASK_ID -> fields[COL_JOB_ID].toLong(10)
- TASK_SUBMIT_TIME -> fields[COL_SUBMIT_TIME].toLong(10)
- TASK_WAIT_TIME -> fields[COL_WAIT_TIME].toLong(10)
- TASK_RUNTIME -> fields[COL_RUN_TIME].toLong(10)
- else -> throw IllegalArgumentException("Invalid column")
- }
+ throw IllegalArgumentException("Invalid column")
}
override fun getDouble(column: TableColumn<Double>): Double {
diff --git a/opendc-trace/opendc-trace-swf/src/test/kotlin/org/opendc/trace/swf/SwfTraceFormatTest.kt b/opendc-trace/opendc-trace-swf/src/test/kotlin/org/opendc/trace/swf/SwfTraceFormatTest.kt
index 9686891b..828c2bfa 100644
--- a/opendc-trace/opendc-trace-swf/src/test/kotlin/org/opendc/trace/swf/SwfTraceFormatTest.kt
+++ b/opendc-trace/opendc-trace-swf/src/test/kotlin/org/opendc/trace/swf/SwfTraceFormatTest.kt
@@ -85,10 +85,10 @@ internal class SwfTraceFormatTest {
assertAll(
{ assertTrue(reader.nextRow()) },
- { assertEquals(1, reader.getLong(TASK_ID)) },
+ { assertEquals("1", reader.get(TASK_ID)) },
{ assertEquals(306, reader.getInt(TASK_ALLOC_NCPUS)) },
{ assertTrue(reader.nextRow()) },
- { assertEquals(2, reader.getLong(TASK_ID)) },
+ { assertEquals("2", reader.get(TASK_ID)) },
{ assertEquals(17, reader.getInt(TASK_ALLOC_NCPUS)) },
)