diff options
Diffstat (limited to 'opendc-trace/opendc-trace-azure/src/main')
3 files changed, 14 insertions, 9 deletions
diff --git a/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceStateTableReader.kt b/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceStateTableReader.kt index da8181fe..94a91999 100644 --- a/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceStateTableReader.kt +++ b/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceStateTableReader.kt @@ -53,7 +53,7 @@ internal class AzureResourceStateTableReader(private val parser: CsvParser) : Ta when (parser.currentName) { "timestamp" -> timestamp = Instant.ofEpochSecond(parser.longValue) "vm id" -> id = parser.text - "CPU avg cpu" -> cpuUsagePct = parser.doubleValue + "CPU avg cpu" -> cpuUsagePct = (parser.doubleValue / 100.0) // Convert from % to [0, 1] } } diff --git a/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceTableReader.kt b/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceTableReader.kt index a6352613..6246dc35 100644 --- a/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceTableReader.kt +++ b/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureResourceTableReader.kt @@ -52,8 +52,8 @@ internal class AzureResourceTableReader(private val parser: CsvParser) : TableRe when (parser.currentName) { "vm id" -> id = parser.text - "vm created" -> startTime = Instant.ofEpochSecond(parser.longValue) - "vm deleted" -> stopTime = Instant.ofEpochSecond(parser.longValue) + "timestamp vm created" -> startTime = Instant.ofEpochSecond(parser.longValue) + "timestamp vm deleted" -> stopTime = Instant.ofEpochSecond(parser.longValue) "vm virtual core count" -> cpuCores = parser.intValue "vm memory" -> memCapacity = parser.doubleValue * 1e6 // GB to KB } diff --git a/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureTraceFormat.kt b/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureTraceFormat.kt index 253c7057..c9982877 100644 --- a/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureTraceFormat.kt +++ b/opendc-trace/opendc-trace-azure/src/main/kotlin/org/opendc/trace/azure/AzureTraceFormat.kt @@ -31,8 +31,9 @@ import org.opendc.trace.util.CompositeTableReader import java.nio.file.Files import java.nio.file.Path import java.util.stream.Collectors -import kotlin.io.path.extension -import kotlin.io.path.nameWithoutExtension +import java.util.zip.GZIPInputStream +import kotlin.io.path.inputStream +import kotlin.io.path.name /** * A format implementation for the Azure v1 format. @@ -81,7 +82,10 @@ public class AzureTraceFormat : TraceFormat { override fun newReader(path: Path, table: String): TableReader { return when (table) { - TABLE_RESOURCES -> AzureResourceTableReader(factory.createParser(path.resolve("vmtable/vmtable.csv").toFile())) + TABLE_RESOURCES -> { + val stream = GZIPInputStream(path.resolve("vmtable/vmtable.csv.gz").inputStream()) + AzureResourceTableReader(factory.createParser(stream)) + } TABLE_RESOURCE_STATES -> newResourceStateReader(path) else -> throw IllegalArgumentException("Table $table not supported") } @@ -96,8 +100,8 @@ public class AzureTraceFormat : TraceFormat { */ private fun newResourceStateReader(path: Path): TableReader { val partitions = Files.walk(path.resolve("vm_cpu_readings"), 1) - .filter { !Files.isDirectory(it) && it.extension == "csv" } - .collect(Collectors.toMap({ it.nameWithoutExtension }, { it })) + .filter { !Files.isDirectory(it) && it.name.endsWith(".csv.gz") } + .collect(Collectors.toMap({ it.name.removeSuffix(".csv.gz") }, { it })) .toSortedMap() val it = partitions.iterator() @@ -105,7 +109,8 @@ public class AzureTraceFormat : TraceFormat { override fun nextReader(): TableReader? { return if (it.hasNext()) { val (_, partPath) = it.next() - return AzureResourceStateTableReader(factory.createParser(partPath.toFile())) + val stream = GZIPInputStream(partPath.inputStream()) + return AzureResourceStateTableReader(factory.createParser(stream)) } else { null } |
