summaryrefslogtreecommitdiff
path: root/simulator/opendc/opendc-runner-web/src
diff options
context:
space:
mode:
Diffstat (limited to 'simulator/opendc/opendc-runner-web/src')
-rw-r--r--simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/Main.kt6
-rw-r--r--simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ResultProcessor.kt20
-rw-r--r--simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ScenarioManager.kt2
-rw-r--r--simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/TopologyParser.kt19
4 files changed, 29 insertions, 18 deletions
diff --git a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/Main.kt b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/Main.kt
index 807c119e..9cfe5531 100644
--- a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/Main.kt
+++ b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/Main.kt
@@ -22,13 +22,13 @@ import com.mongodb.client.MongoClients
import com.mongodb.client.MongoCollection
import com.mongodb.client.MongoDatabase
import com.mongodb.client.model.Filters
-import java.io.File
-import java.util.*
-import kotlin.random.Random
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import mu.KotlinLogging
import org.bson.Document
+import java.io.File
+import java.util.*
+import kotlin.random.Random
private val logger = KotlinLogging.logger {}
diff --git a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ResultProcessor.kt b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ResultProcessor.kt
index 39092653..c0b0ac31 100644
--- a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ResultProcessor.kt
+++ b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ResultProcessor.kt
@@ -1,11 +1,11 @@
package com.atlarge.opendc.runner.web
-import java.io.File
import org.apache.spark.sql.Column
import org.apache.spark.sql.Dataset
import org.apache.spark.sql.Row
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions.*
+import java.io.File
/**
* A helper class for processing the experiment results using Apache Spark.
@@ -175,13 +175,19 @@ class ResultProcessor(private val master: String, private val outputPath: File)
val sliceLength = 5 * 60 * 1000
val states = map(
- lit("ERROR"), lit(1),
- lit("ACTIVE"), lit(0),
- lit("SHUTOFF"), lit(0)
+ lit("ERROR"),
+ lit(1),
+ lit("ACTIVE"),
+ lit(0),
+ lit("SHUTOFF"),
+ lit(0)
)
val oppositeStates = map(
- lit("ERROR"), lit(0),
- lit("ACTIVE"), lit(1),
- lit("SHUTOFF"), lit(1)
+ lit("ERROR"),
+ lit(0),
+ lit("ACTIVE"),
+ lit(1),
+ lit("SHUTOFF"),
+ lit(1)
)
}
diff --git a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ScenarioManager.kt b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ScenarioManager.kt
index 40ffd282..6ec4995d 100644
--- a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ScenarioManager.kt
+++ b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/ScenarioManager.kt
@@ -3,8 +3,8 @@ package com.atlarge.opendc.runner.web
import com.mongodb.client.MongoCollection
import com.mongodb.client.model.Filters
import com.mongodb.client.model.Updates
-import java.time.Instant
import org.bson.Document
+import java.time.Instant
/**
* Manages the queue of scenarios that need to be processed.
diff --git a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/TopologyParser.kt b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/TopologyParser.kt
index 499585ec..ab683985 100644
--- a/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/TopologyParser.kt
+++ b/simulator/opendc/opendc-runner-web/src/main/kotlin/com/atlarge/opendc/runner/web/TopologyParser.kt
@@ -1,6 +1,6 @@
package com.atlarge.opendc.runner.web
-import com.atlarge.odcsim.Domain
+import com.atlarge.odcsim.simulationContext
import com.atlarge.opendc.compute.core.MemoryUnit
import com.atlarge.opendc.compute.core.ProcessingNode
import com.atlarge.opendc.compute.core.ProcessingUnit
@@ -20,9 +20,10 @@ import com.mongodb.client.model.Aggregates
import com.mongodb.client.model.Field
import com.mongodb.client.model.Filters
import com.mongodb.client.model.Projections
-import java.util.*
+import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.bson.Document
+import java.util.*
/**
* A helper class that converts the MongoDB topology into an OpenDC environment.
@@ -31,7 +32,8 @@ class TopologyParser(private val collection: MongoCollection<Document>, private
/**
* Parse the topology with the specified [id].
*/
- override suspend fun construct(dom: Domain): Environment {
+ override suspend fun construct(coroutineScope: CoroutineScope): Environment {
+ val clock = simulationContext.clock
val nodes = mutableListOf<SimpleBareMetalDriver>()
val random = Random(0)
@@ -59,7 +61,8 @@ class TopologyParser(private val collection: MongoCollection<Document>, private
}
nodes.add(
SimpleBareMetalDriver(
- dom.newDomain(machineId),
+ coroutineScope,
+ clock,
UUID(random.nextLong(), random.nextLong()),
"node-$clusterId-$position",
mapOf(NODE_CLUSTER to clusterId),
@@ -73,8 +76,8 @@ class TopologyParser(private val collection: MongoCollection<Document>, private
)
}
- val provisioningService = SimpleProvisioningService(dom.newDomain("provisioner"))
- dom.launch {
+ val provisioningService = SimpleProvisioningService()
+ coroutineScope.launch {
for (node in nodes) {
provisioningService.create(node)
}
@@ -83,7 +86,9 @@ class TopologyParser(private val collection: MongoCollection<Document>, private
val serviceRegistry = ServiceRegistry().put(ProvisioningService, provisioningService)
val platform = Platform(
- UUID.randomUUID(), "opendc-platform", listOf(
+ UUID.randomUUID(),
+ "opendc-platform",
+ listOf(
Zone(UUID.randomUUID(), "zone", serviceRegistry)
)
)