summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-api/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-trace/opendc-trace-api/src/main')
-rw-r--r--opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/ResourceColumns.kt4
-rw-r--r--opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Table.kt4
-rw-r--r--opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TaskColumns.kt17
-rw-r--r--opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Trace.kt35
4 files changed, 49 insertions, 11 deletions
diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/ResourceColumns.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/ResourceColumns.kt
index 44dec95b..e2e5ea6d 100644
--- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/ResourceColumns.kt
+++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/ResourceColumns.kt
@@ -41,7 +41,7 @@ public val RESOURCE_START_TIME: TableColumn<Instant> = TableColumn("resource:sta
* End time for the resource.
*/
@JvmField
-public val RESOURCE_END_TIME: TableColumn<Instant> = TableColumn("resource:end_time", Instant::class.java)
+public val RESOURCE_STOP_TIME: TableColumn<Instant> = TableColumn("resource:stop_time", Instant::class.java)
/**
* Number of CPUs for the resource.
@@ -50,7 +50,7 @@ public val RESOURCE_END_TIME: TableColumn<Instant> = TableColumn("resource:end_t
public val RESOURCE_NCPUS: TableColumn<Int> = intColumn("resource:num_cpus")
/**
- * Memory capacity for the resource.
+ * Memory capacity for the resource in KB.
*/
@JvmField
public val RESOURCE_MEM_CAPACITY: TableColumn<Double> = doubleColumn("resource:mem_capacity")
diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Table.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Table.kt
index 11e5d6b7..6aca2051 100644
--- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Table.kt
+++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Table.kt
@@ -37,9 +37,9 @@ public interface Table {
public val isSynthetic: Boolean
/**
- * Determine whether the specified [column] is supported by this table.
+ * The list of columns supported in this table.
*/
- public fun isSupported(column: TableColumn<*>): Boolean
+ public val columns: List<TableColumn<*>>
/**
* Open a [TableReader] for this table.
diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TaskColumns.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TaskColumns.kt
index 88bbc623..46920dce 100644
--- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TaskColumns.kt
+++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/TaskColumns.kt
@@ -23,49 +23,52 @@
@file:JvmName("TaskColumns")
package org.opendc.trace
+import java.time.Duration
+import java.time.Instant
+
/**
* A column containing the task identifier.
*/
@JvmField
-public val TASK_ID: TableColumn<Long> = longColumn("task:id")
+public val TASK_ID: TableColumn<String> = stringColumn("task:id")
/**
* A column containing the identifier of the workflow.
*/
@JvmField
-public val TASK_WORKFLOW_ID: TableColumn<Long> = longColumn("task:workflow_id")
+public val TASK_WORKFLOW_ID: TableColumn<String> = stringColumn("task:workflow_id")
/**
* A column containing the submit time of the task.
*/
@JvmField
-public val TASK_SUBMIT_TIME: TableColumn<Long> = longColumn("task:submit_time")
+public val TASK_SUBMIT_TIME: TableColumn<Instant> = TableColumn("task:submit_time", type = Instant::class.java)
/**
* A column containing the wait time of the task.
*/
@JvmField
-public val TASK_WAIT_TIME: TableColumn<Long> = longColumn("task:wait_time")
+public val TASK_WAIT_TIME: TableColumn<Instant> = TableColumn("task:wait_time", type = Instant::class.java)
/**
* A column containing the runtime time of the task.
*/
@JvmField
-public val TASK_RUNTIME: TableColumn<Long> = longColumn("task:runtime")
+public val TASK_RUNTIME: TableColumn<Duration> = TableColumn("task:runtime", type = Duration::class.java)
/**
* A column containing the parents of a task.
*/
@Suppress("UNCHECKED_CAST")
@JvmField
-public val TASK_PARENTS: TableColumn<Set<Long>> = TableColumn("task:parents", type = Set::class.java as Class<Set<Long>>)
+public val TASK_PARENTS: TableColumn<Set<String>> = TableColumn("task:parents", type = Set::class.java as Class<Set<String>>)
/**
* A column containing the children of a task.
*/
@Suppress("UNCHECKED_CAST")
@JvmField
-public val TASK_CHILDREN: TableColumn<Set<Long>> = TableColumn("task:children", type = Set::class.java as Class<Set<Long>>)
+public val TASK_CHILDREN: TableColumn<Set<String>> = TableColumn("task:children", type = Set::class.java as Class<Set<String>>)
/**
* A column containing the requested CPUs of a task.
diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Trace.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Trace.kt
index 36e93b52..0ae45e86 100644
--- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Trace.kt
+++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/Trace.kt
@@ -22,6 +22,11 @@
package org.opendc.trace
+import org.opendc.trace.spi.TraceFormat
+import java.io.File
+import java.net.URL
+import java.nio.file.Path
+
/**
* A trace is a collection of related tables that characterize a workload.
*/
@@ -40,4 +45,34 @@ public interface Trace {
* Obtain a [Table] with the specified [name].
*/
public fun getTable(name: String): Table?
+
+ public companion object {
+ /**
+ * Open a [Trace] at the specified [url] in the given [format].
+ *
+ * @throws IllegalArgumentException if [format] is not supported.
+ */
+ public fun open(url: URL, format: String): Trace {
+ val provider = requireNotNull(TraceFormat.byName(format)) { "Unknown format $format" }
+ return provider.open(url)
+ }
+
+ /**
+ * Open a [Trace] at the specified [path] in the given [format].
+ *
+ * @throws IllegalArgumentException if [format] is not supported.
+ */
+ public fun open(path: File, format: String): Trace {
+ return open(path.toURI().toURL(), format)
+ }
+
+ /**
+ * Open a [Trace] at the specified [path] in the given [format].
+ *
+ * @throws IllegalArgumentException if [format] is not supported.
+ */
+ public fun open(path: Path, format: String): Trace {
+ return open(path.toUri().toURL(), format)
+ }
+ }
}