summaryrefslogtreecommitdiff
path: root/opendc
diff options
context:
space:
mode:
authorGeorgios Andreadis <G.Andreadis@student.tudelft.nl>2020-03-19 12:14:02 +0100
committerGeorgios Andreadis <G.Andreadis@student.tudelft.nl>2020-03-19 12:14:02 +0100
commitbc1f311e2d74d969717d670552e0511bb2bc9c61 (patch)
treef2c0ec4dee2f9d6a4f81d78cc6bf8429f027e31d /opendc
parent22b3568118493f2b3d18b37406e169f19b47a311 (diff)
Add option to submit selected VMs as file
This should shorten the command length and circumvent Windows quirks.
Diffstat (limited to 'opendc')
-rw-r--r--opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt35
1 files 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<String> = 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<String> {
+ return if (selectedVms.isEmpty()) {
+ selectedVmsFile
+ } else {
+ selectedVms
}
+ }
+
+ private fun parseVMs(string: String): List<String> {
+ // 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<String> = jacksonObjectMapper().readValue(sanitizedString)
+ return vms
+ }
}
/**
@@ -98,7 +111,7 @@ fun main(args: Array<String>) {
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()))