summaryrefslogtreecommitdiff
path: root/simulator/opendc-runner-web
diff options
context:
space:
mode:
Diffstat (limited to 'simulator/opendc-runner-web')
-rw-r--r--simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/Main.kt10
-rw-r--r--simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ResultProcessor.kt48
-rw-r--r--simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ScenarioManager.kt12
-rw-r--r--simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/TopologyParser.kt2
4 files changed, 36 insertions, 36 deletions
diff --git a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/Main.kt b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/Main.kt
index 69b2e69d..67ec046a 100644
--- a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/Main.kt
+++ b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/Main.kt
@@ -59,7 +59,7 @@ private val logger = KotlinLogging.logger {}
* Represents the CLI command for starting the OpenDC web runner.
*/
@OptIn(ExperimentalCoroutinesApi::class)
-class RunnerCli : CliktCommand(name = "runner") {
+public class RunnerCli : CliktCommand(name = "runner") {
/**
* The name of the database to use.
*/
@@ -299,10 +299,10 @@ class RunnerCli : CliktCommand(name = "runner") {
}
}
- val POLL_INTERVAL = 5000L // ms = 5 s
- val HEARTBEAT_INTERVAL = 60000L // ms = 1 min
+ private val POLL_INTERVAL = 5000L // ms = 5 s
+ private val HEARTBEAT_INTERVAL = 60000L // ms = 1 min
- override fun run() = runBlocking(Dispatchers.Default) {
+ override fun run(): Unit = runBlocking(Dispatchers.Default) {
logger.info { "Starting OpenDC web runner" }
logger.info { "Connecting to MongoDB instance" }
val database = createDatabase()
@@ -365,4 +365,4 @@ class RunnerCli : CliktCommand(name = "runner") {
/**
* Main entry point of the runner.
*/
-fun main(args: Array<String>) = RunnerCli().main(args)
+public fun main(args: Array<String>): Unit = RunnerCli().main(args)
diff --git a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ResultProcessor.kt b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ResultProcessor.kt
index 5cae6aa8..f9a3cd2b 100644
--- a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ResultProcessor.kt
+++ b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ResultProcessor.kt
@@ -32,11 +32,11 @@ import java.io.File
/**
* A helper class for processing the experiment results using Apache Spark.
*/
-class ResultProcessor(private val master: String, private val outputPath: File) {
+public class ResultProcessor(private val master: String, private val outputPath: File) {
/**
* Process the results of the scenario with the given [id].
*/
- fun process(id: String): Result {
+ public fun process(id: String): Result {
val spark = SparkSession.builder()
.master(master)
.appName("opendc-simulator-$id")
@@ -70,22 +70,22 @@ class ResultProcessor(private val master: String, private val outputPath: File)
}
}
- data class Result(
- val totalRequestedBurst: List<Long>,
- val totalGrantedBurst: List<Long>,
- val totalOvercommittedBurst: List<Long>,
- val totalInterferedBurst: List<Long>,
- val meanCpuUsage: List<Double>,
- val meanCpuDemand: List<Double>,
- val meanNumDeployedImages: List<Double>,
- val maxNumDeployedImages: List<Int>,
- val totalPowerDraw: List<Long>,
- val totalFailureSlices: List<Long>,
- val totalFailureVmSlices: List<Long>,
- val totalVmsSubmitted: List<Int>,
- val totalVmsQueued: List<Int>,
- val totalVmsFinished: List<Int>,
- val totalVmsFailed: List<Int>
+ public data class Result(
+ public val totalRequestedBurst: List<Long>,
+ public val totalGrantedBurst: List<Long>,
+ public val totalOvercommittedBurst: List<Long>,
+ public val totalInterferedBurst: List<Long>,
+ public val meanCpuUsage: List<Double>,
+ public val meanCpuDemand: List<Double>,
+ public val meanNumDeployedImages: List<Double>,
+ public val maxNumDeployedImages: List<Int>,
+ public val totalPowerDraw: List<Long>,
+ public val totalFailureSlices: List<Long>,
+ public val totalFailureVmSlices: List<Long>,
+ public val totalVmsSubmitted: List<Int>,
+ public val totalVmsQueued: List<Int>,
+ public val totalVmsFinished: List<Int>,
+ public val totalVmsFailed: List<Int>
)
/**
@@ -191,12 +191,12 @@ class ResultProcessor(private val master: String, private val outputPath: File)
}
// Spark helper functions
- operator fun Column.times(other: Column): Column = `$times`(other)
- operator fun Column.div(other: Column): Column = `$div`(other)
- operator fun Column.get(other: Column): Column = this.apply(other)
+ private operator fun Column.times(other: Column): Column = `$times`(other)
+ private operator fun Column.div(other: Column): Column = `$div`(other)
+ private operator fun Column.get(other: Column): Column = this.apply(other)
- val sliceLength = 5 * 60 * 1000
- val states = map(
+ private val sliceLength = 5 * 60 * 1000
+ private val states = map(
lit("ERROR"),
lit(1),
lit("ACTIVE"),
@@ -204,7 +204,7 @@ class ResultProcessor(private val master: String, private val outputPath: File)
lit("SHUTOFF"),
lit(0)
)
- val oppositeStates = map(
+ private val oppositeStates = map(
lit("ERROR"),
lit(0),
lit("ACTIVE"),
diff --git a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ScenarioManager.kt b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ScenarioManager.kt
index 0c6c8fee..504fccdc 100644
--- a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ScenarioManager.kt
+++ b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/ScenarioManager.kt
@@ -31,11 +31,11 @@ import java.time.Instant
/**
* Manages the queue of scenarios that need to be processed.
*/
-class ScenarioManager(private val collection: MongoCollection<Document>) {
+public class ScenarioManager(private val collection: MongoCollection<Document>) {
/**
* Find the next scenario that the simulator needs to process.
*/
- fun findNext(): Document? {
+ public fun findNext(): Document? {
return collection
.find(Filters.eq("simulation.state", "QUEUED"))
.first()
@@ -44,7 +44,7 @@ class ScenarioManager(private val collection: MongoCollection<Document>) {
/**
* Claim the scenario in the database with the specified id.
*/
- fun claim(id: String): Boolean {
+ public fun claim(id: String): Boolean {
val res = collection.findOneAndUpdate(
Filters.and(
Filters.eq("_id", id),
@@ -61,7 +61,7 @@ class ScenarioManager(private val collection: MongoCollection<Document>) {
/**
* Update the heartbeat of the specified scenario.
*/
- fun heartbeat(id: String) {
+ public fun heartbeat(id: String) {
collection.findOneAndUpdate(
Filters.and(
Filters.eq("_id", id),
@@ -74,7 +74,7 @@ class ScenarioManager(private val collection: MongoCollection<Document>) {
/**
* Mark the scenario as failed.
*/
- fun fail(id: String) {
+ public fun fail(id: String) {
collection.findOneAndUpdate(
Filters.eq("_id", id),
Updates.combine(
@@ -87,7 +87,7 @@ class ScenarioManager(private val collection: MongoCollection<Document>) {
/**
* Persist the specified results.
*/
- fun finish(id: String, result: ResultProcessor.Result) {
+ public fun finish(id: String, result: ResultProcessor.Result) {
collection.findOneAndUpdate(
Filters.eq("_id", id),
Updates.combine(
diff --git a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/TopologyParser.kt b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/TopologyParser.kt
index 884833cb..de9ece75 100644
--- a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/TopologyParser.kt
+++ b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/TopologyParser.kt
@@ -50,7 +50,7 @@ import java.util.*
/**
* A helper class that converts the MongoDB topology into an OpenDC environment.
*/
-class TopologyParser(private val collection: MongoCollection<Document>, private val id: String) : EnvironmentReader {
+public class TopologyParser(private val collection: MongoCollection<Document>, private val id: String) : EnvironmentReader {
/**
* Parse the topology with the specified [id].
*/