From bc1f311e2d74d969717d670552e0511bb2bc9c61 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 19 Mar 2020 12:14:02 +0100 Subject: Add option to submit selected VMs as file This should shorten the command length and circumvent Windows quirks. --- .../opendc/experiments/sc20/TestExperiment.kt | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt index 415a7628..82ca2061 100644 --- a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt +++ b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt @@ -44,6 +44,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import java.io.File +import java.io.FileReader import java.util.ServiceLoader import kotlin.math.max @@ -52,17 +53,29 @@ class ExperimentParameters(parser: ArgParser) { val environmentFile by parser.storing("path to the environment file") val outputFile by parser.storing("path to where the output should be stored") .default { "sc20-experiment-results.csv" } - val selectedVms by parser.storing("the VMs to run") { - // Handle case where VM list contains a VM name with an (escaped) single-quote in it - val string = this.replace("\\'", "\\\\[") - .replace("'", "\"") - .replace("\\\\[", "'") - val vms: List = jacksonObjectMapper().readValue(string) - vms - } - .default { - emptyList() + val selectedVms by parser.storing("the VMs to run") { parseVMs(this) } + .default { emptyList() } + val selectedVmsFile by parser.storing("path to a file containing the VMs to run") { + parseVMs(FileReader(File(this)).readText()) + } + .default { emptyList() } + + fun getSelectedVmList(): List { + return if (selectedVms.isEmpty()) { + selectedVmsFile + } else { + selectedVms } + } + + private fun parseVMs(string: String): List { + // Handle case where VM list contains a VM name with an (escaped) single-quote in it + val sanitizedString = string.replace("\\'", "\\\\[") + .replace("'", "\"") + .replace("\\\\[", "'") + val vms: List = jacksonObjectMapper().readValue(sanitizedString) + return vms + } } /** @@ -98,7 +111,7 @@ fun main(args: Array) { hypervisorMonitor ) - val reader = Sc20TraceReader(File(traceDirectory), performanceInterferenceModel, selectedVms) + val reader = Sc20TraceReader(File(traceDirectory), performanceInterferenceModel, getSelectedVmList()) while (reader.hasNext()) { val (time, workload) = reader.next() delay(max(0, time - simulationContext.clock.millis())) -- cgit v1.2.3