diff options
14 files changed, 161 insertions, 345 deletions
diff --git a/opendc-common/src/main/kotlin/org/opendc/common/annotations/Endpoint.kt b/opendc-common/src/main/kotlin/org/opendc/common/annotations/Endpoint.kt deleted file mode 100644 index 4ef08a71..00000000 --- a/opendc-common/src/main/kotlin/org/opendc/common/annotations/Endpoint.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.opendc.common.annotations - -@RequiresOptIn(message = "This is a registered API endpoint.") -@Retention(AnnotationRetention.BINARY) -@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR) -public annotation class Endpoint(val method: String, val name : String)
\ No newline at end of file diff --git a/opendc-common/src/main/kotlin/org/opendc/common/api/AssetsController.kt b/opendc-common/src/main/kotlin/org/opendc/common/api/AssetsController.kt deleted file mode 100644 index c6f34d19..00000000 --- a/opendc-common/src/main/kotlin/org/opendc/common/api/AssetsController.kt +++ /dev/null @@ -1,72 +0,0 @@ -package org.opendc.common.api - -import org.opendc.common.annotations.Endpoint -import io.javalin.http.Handler - -/** - * This class represents the `/assets` endpoint. - * - * @author Mateusz Kwiatkowski - * - * */ - - -//TODO: fix -> this is all wrong. -// Sending the experiment file is completely useless. -// You need to send tasks.parquet -public class AssetsController { - /** - * Returns a concatenated JSON string of all assets. - */ - @Endpoint("GET","/assets") - public fun getAssets() : Handler { - return Handler { ctx -> ctx.status(200) - println(ctx.body()) - } - } - - /** - * Returns an asset with `id` as a JSON string. - */ - @Endpoint("GET", "/assets/{id}") - public fun getAssetsId(): Handler { - return Handler { ctx -> ctx.status(200) } - } - - /** - * Saves the asset specified in the HTTP body. - * Returns the asset `id`. - */ - @Endpoint("POST", "/assets") - public fun postAsset() : Handler { - return Handler { ctx -> ctx.status(200) - println(ctx.body()) - } - } - - /** - * Modifies the specified asset. - * Deletes all results from experiments with this asset. - */ - @Endpoint("PUT", "/assets/{id}") - public fun putAssetId() : Handler { - return Handler { ctx -> ctx.status(200) } - } - - /** - * Deletes an asset with `id`. - * Deletes all results from experiments with this asset. - */ - @Endpoint("DELETE", "/assets/{id}") - public fun deleteAssetId() : Handler { - return Handler { ctx -> ctx.status(200) } - } - - /** - * Deletes all assets - */ - @Endpoint("DELETE", "/assets") - public fun deleteAsset() : Handler { - return Handler { ctx -> ctx.status(200) } - } -}
\ No newline at end of file diff --git a/opendc-common/src/main/kotlin/org/opendc/common/api/ResourceController.kt b/opendc-common/src/main/kotlin/org/opendc/common/api/ResourceController.kt deleted file mode 100644 index cf1d3cac..00000000 --- a/opendc-common/src/main/kotlin/org/opendc/common/api/ResourceController.kt +++ /dev/null @@ -1,30 +0,0 @@ -package org.opendc.common.api - -import org.opendc.common.annotations.Endpoint - -/** - * This class represents the `/resources` endpoint. - * - * @author Mateusz Kwiatkowski - * - * */ - -public class ResourceController { - - /** - * Returns all data analytics for all experiments. - */ - @Endpoint("GET", "/resources") - public fun getResources() { - return - } - - /** - * Returns data analytics for experiment with `id`. - * - * */ - @Endpoint("GET", "/resources") - public fun getResourcesId() { - return - } -}
\ No newline at end of file diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt deleted file mode 100644 index 23baac27..00000000 --- a/opendc-common/src/main/kotlin/org/opendc/common/utils/JavalinRunner.kt +++ /dev/null @@ -1,33 +0,0 @@ -package org.opendc.common.utils - -import io.javalin.Javalin -import org.opendc.common.annotations.Endpoint -import org.opendc.common.api.AssetsController - -/** - * Represents the digital twin monitoring server. - * For endpoint documentation see `AssetsController`. - * @author Mateusz Kwiatkowski - * @see <a href=https://javalin.io/documentation>https://javalin.io/documentation</a> - * @see org.opendc.common.api.AssetsController - */ - -@OptIn(Endpoint::class) -public class JavalinRunner { - private val assetsController : AssetsController = AssetsController() - - init { - val app = Javalin.create().start() - app.get("/assets", assetsController.getAssets()) - - app.get("/assets/{id}", assetsController.getAssetsId()) - - app.post("/assets", assetsController.postAsset()) - - app.put("/assets/{id}", assetsController.putAssetId()) - - app.delete("/assets/{id}", assetsController.deleteAssetId()) - - app.delete("/assets", assetsController.deleteAsset()) - } -}
\ No newline at end of file diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt deleted file mode 100644 index 35d03feb..00000000 --- a/opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt +++ /dev/null @@ -1,52 +0,0 @@ -package org.opendc.common.utils - -import com.fasterxml.jackson.dataformat.toml.TomlMapper -import java.sql.Connection -import java.sql.DriverManager -import java.sql.SQLException -import java.util.Properties -/** - * Represents the Postgresql database. - * On setup cleans the entire database. - * - * @author Mateusz Kwiatkowski - * - * @see <a href=https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/DriverManager.html> - * https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/DriverManager.html</a> - */ -@Suppress("DEPRECATION") -public class PostgresqlDB { - private var properties = Properties() - private var connection : Connection? = null - - init { - try { - properties = TomlMapper().readerFor(Properties().javaClass) - .readValue(PostgresqlDB::class.java.getResource("/database.toml")) - connection = DriverManager.getConnection( - properties.getProperty("address").asJdbc(properties.getProperty("database")), - properties.getProperty("user"), - properties.getProperty("password")) - clear() - } catch (e: SQLException) { - print("${e.message}") - } - } - public fun clear(){ - val DELETE_ALL_TABLES = """ - DROP SCHEMA public CASCADE; - CREATE SCHEMA public; - """.trimIndent() - try { - val st = connection?.createStatement() - st?.executeQuery(DELETE_ALL_TABLES) - } catch (e: SQLException){ - println("${e.message}") - } - } - - private fun String.asJdbc(database : String) : String { - return "jdbc:postgresql://$this/$database" - } - -}
\ No newline at end of file diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt deleted file mode 100644 index bf674a33..00000000 --- a/opendc-common/src/main/kotlin/org/opendc/common/utils/Redis.kt +++ /dev/null @@ -1,71 +0,0 @@ -package org.opendc.common.utils - -import com.fasterxml.jackson.dataformat.toml.TomlMapper -import redis.clients.jedis.RedisClient -import redis.clients.jedis.StreamEntryID -import redis.clients.jedis.params.XReadParams -import java.util.Map -import java.util.Properties - - -/** - * This class represents the Redis server instance. - * @author Mateusz Kwiatkowski - * @see <a href=https://redis.io/docs/latest/>https://redis.io/docs/latest/</a> - * - * @see <a href=https://redis.io/docs/latest/develop/data-types/streams/>https://redis.io/docs/latest/develop/data-types/streams/</a> - * - * @see <a href=https://www.javadoc.io/doc/redis.clients/jedis/latest/index.html>https://www.javadoc.io/doc/redis.clients/jedis/latest/index.html</a> - */ - -@Suppress("DEPRECATION") -public class Redis private constructor() { - private var jedis : RedisClient? = null - private var properties : Properties? = null - - init { - properties = TomlMapper().readerFor(Properties().javaClass).readValue(Kafka::class.java.getResource("/subscriber.toml")) - jedis = RedisClient.create("redis://localhost:${properties?.getProperty("port")}") - } - - public companion object { - private var instance: Redis? = null - - public fun getInstance(): Redis? { - if (instance == null) { - instance = Redis() - } - return instance - } - } - - public fun readOne() { - while(true) { - val messages = jedis?.xread( - XReadParams.xReadParams(), - Map.of("${properties?.getProperty("table")}", StreamEntryID() - )); - - if (messages != null) { - for (stream in messages) { - for (entry in stream.value) { - if(entry.getFields().get("downtime") != null) { - entry.getFields().get("downtime")?.toDouble()?.let { - if (it > 0) { - println("ID: " + entry.getID()) - } - } - } - } - } - } - } - // https://redis.io/docs/latest/develop/use-cases/streaming/java-jedis/ - // In Redis you can subscribe to updates to a stream. - // You should base your application off this. - // You can listen for new items with XREAD - - // do not close for now - //jedis.close() - } -} diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/ComputeSchedulers.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/ComputeSchedulers.kt index fc40fac0..240d21d5 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/ComputeSchedulers.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/ComputeSchedulers.kt @@ -39,6 +39,7 @@ import java.util.SplittableRandom import java.util.random.RandomGenerator public enum class ComputeSchedulerEnum { + Smart, Mem, MemInv, CoreMem, @@ -81,6 +82,9 @@ public fun createPrefabComputeScheduler( /** * Create a [ComputeScheduler] for the experiment. + * I have changed this to use the new SmartScheduler. + * + * @author Mateusz Kwiatkowski */ public fun createPrefabComputeScheduler( name: ComputeSchedulerEnum, @@ -92,6 +96,8 @@ public fun createPrefabComputeScheduler( val ramAllocationRatio = 1.0 val gpuAllocationRatio = 1.0 return when (name) { + ComputeSchedulerEnum.Smart -> + SmartScheduler() ComputeSchedulerEnum.Mem -> FilterScheduler( filters = listOf(VCpuFilter(cpuAllocationRatio), RamFilter(ramAllocationRatio)), diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/SmartScheduler.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/SmartScheduler.kt index 0edd97cf..7a540e86 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/SmartScheduler.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/SmartScheduler.kt @@ -1,69 +1,167 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - package org.opendc.compute.simulator.scheduler -import org.opendc.common.utils.HTTPClient + +import org.opendc.compute.simulator.scheduler.filters.HostFilter import org.opendc.compute.simulator.service.HostView import org.opendc.compute.simulator.service.ServiceTask +import java.util.SplittableRandom +import java.util.random.RandomGenerator +/** + * A scheduler that is able to cooperate with a digital twin. + * Currently, this is hardcoded. + * Important: the random seed can aid you in finding good standard deviation measure. + * The scheduling significantly affects downtime. + * + * @author Mateusz Kwiatkowski + */ public class SmartScheduler : ComputeScheduler { - private val client = HTTPClient.getInstance() - // the point is that a smart scheduler listens for suggestions from the - // digital twin - // and here is where you change your actions based on the result from the DT - // predictive analytics is going to be much easier to do. - // you will completely overcome the overhead of having to tap-into - // the digital twin mid-through the simulation/in between two hosts being scheduled - // i.e., the normal simulation will NOT have to wait. - // predictive analytics will overcome the problem of the scheduling time overhead + private val maxTimesSkipped: Int = 7 + private val random: RandomGenerator = SplittableRandom(128) + // We will use a priority queue. + private val hostsQueue = List(100, { mutableListOf<HostView>() }) + private var minAvailableHost = 0 + private var numHosts = 0 + + + // Unlucky Hosts for WhatsApp + //private var unluckyHosts = listOf("H01","H02-109","H02-229","H02-107","H02-227","H02-105","H02-226","H02-103","H02-101","H02-222","H02-221","H02-220","H02-213","H02-212","H02-210","H02-208","H02-207","H02-206","H02-204","H02-203","H02-202","H01-181","H01-184","H01-185","H01-186","H01-189","H01-170","H01-174","H01-175","H01-178","H01-179","H01-169","H01-164","H01-166","H01-167","H01-168","H02-197","H02-196","H02-195","H02-194","H01-270","H02-193","H01-271","H02-192","H01-152","H02-190","H01-275","H01-155","H01-157"," H01-91"," H01-94"," H01-84"," H02-52"," H02-54"," H01-87"," H02-55"," H01-88"," H01-89"," H02-57"," H02-58"," H02-59"," H02-70"," H01-95"," H02-63"," H01-96"," H02-64"," H02-65"," H01-98"," H02-66"," H01-99"," H02-67"," H02-69"," H02-83"," H02-74"," H02-76"," H02-78"," H02-90"," H02-91","H01-192","H01-193","H01-195"," H02-87"," H02-89","H01-103","H01-224","H01-105","H01-226","H01-106","H01-227","H01-228"," H01-50","H02-148","H02-147"," H01-48"," H02-16"," H02-17","H02-144","H02-265"," H02-18","H02-264","H02-141","H02-262","H02-140","H02-261","H02-260"," H01-42"," H02-10"," H01-43"," H02-12"," H01-45","H01-221"," H02-13"," H01-46","H01-101","H01-222"," H01-47","H01-102","H01-223"," H02-15","H01-213","H01-214","H01-215","H01-218","H01-219","H02-139","H02-138","H02-135","H02-256"," H01-59"," H02-27","H02-134","H02-133","H02-254","H02-253","H02-130","H02-250"," H01-53"," H02-21"," H01-54"," H02-22"," H01-55"," H01-56","H01-210","H01-211"," H02-25","H01-202","H01-203","H01-204","H01-206"," H01-70","H01-207"," H01-72","H01-209","H02-129","H02-248","H02-126","H02-246","H02-245"," H02-38","H02-122","H02-121","H02-242","H02-241"," H01-62"," H02-30"," H01-64"," H01-65"," H01-66"," H02-35","H01-200"," H02-36","H01-201"," H02-0"," H02-1"," H01-80"," H02-50"," H01-83"," H02-51","H02-118","H02-239","H02-117","H02-238","H02-237","H02-115","H02-113"," H02-49","H02-112","H02-233","H02-111","H02-231"," H02-41"," H01-75"," H02-43"," H02-9"," H02-4"," H02-45"," H02-46"," H01-79","H01-147","H01-268","H01-149","H02-189","H02-186","H02-185","H02-184","H02-183","H02-182","H01-260","H01-140","H02-180","H01-141","H01-262","H01-263","H01-264","H01-144","H01-145","H01-146","H01-267","H01-136","H01-257"," H01-3"," H01-2"," H01-17","H02-176","H02-175","H02-173","H02-172"," H01-9","H02-170"," H01-8","H01-250","H01-130","H01-251","H01-252"," H01-5"," H01-11"," H01-12"," H01-13"," H01-6","H01-135","H01-246","H01-126","H01-127","H01-129","H02-169"," H01-27","H02-165","H02-162","H02-161","H02-160","H01-240","H01-122"," H01-24","H01-124","H01-114","H01-236","H01-117","H01-238","H01-239","H01-119","H02-158","H02-157"," H01-39","H02-275","H02-274","H02-151","H02-150","H02-270"," H01-31"," H01-33","H01-110"," H01-34","H01-111","H01-232","H01-233"," H01-36","H01-113") + + // Unlucky Hosts for Skype + //private var unluckyHosts = listOf("H01-44","H01-66","H01-73","H01-74","H01-85","H01-86","H01-89","H01-10","H01-98","H01-13","H01-39") + + // Unlucky Hosts for Twitter + //private var unluckyHosts = listOf("H01-180","H01-181","H01-182","H01-184","H01-185","H01-186","H01-188","H01-171","H01-173","H01-176","H01-177","H01-178","H01-179","H01-169"," H01","H01-162","H01-163","H01-164","H01-165","H01-166","H01-168","H01-158","H01-270","H01-150","H01-271","H01-272","H01-273","H01-274","H01-154","H01-155","H01-156","H01-157"," H01-90"," H01-91"," H01-92"," H01-93"," H01-88"," H01-89"," H01-95"," H01-96"," H01-99","H01-190","H01-191","H01-192","H01-193","H01-196","H01-197","H01-198","H01-103","H01-224","H01-225","H01-106","H01-228","H01-108"," H01-50"," H01-40"," H01-42"," H01-43"," H01-44"," H01-45","H01-100","H01-222","H01-102","H01-223","H01-214","H01-215","H01-216","H01-217","H01-218"," H01-60"," H01-59"," H01-51"," H01-52"," H01-53"," H01-56","H01-210"," H01-57","H01-211","H01-212","H01-202","H01-204","H01-205","H01-206"," H01-70"," H01-71"," H01-72","H01-209"," H01-63"," H01-64"," H01-80"," H01-82"," H01-73"," H01-76"," H01-77","H01-268","H01-269","H01-149","H01-260","H01-140","H01-262","H01-263","H01-143","H01-144","H01-265","H01-145","H01-146","H01-267"," H01-1","H01-136","H01-257","H01-137","H01-258"," H01-3","H01-139"," H01-17"," H01-18"," H01-9"," H01-8","H01-130","H01-251","H01-252"," H01-4"," H01-12","H01-133","H01-254"," H01-7"," H01-14","H01-135","H01-256","H01-126"," H01-26"," H01-27"," H01-28"," H01-29"," H01-20","H01-120","H01-241"," H01-22","H01-242","H01-243"," H01-24","H01-123"," H01-25","H01-124","H01-115","H01-116","H01-237","H01-117","H01-118","H01-239"," H01-38"," H01-31","H01-230"," H01-33","H01-110"," H01-35","H01-233","H01-113") override fun addHost(host: HostView) { - TODO("Not yet implemented") + // We do not want a host available if it is in the list of unluckyHosts + //if(host.host.getName() in unluckyHosts) {return} + val zeroQueue = hostsQueue[0] + zeroQueue.add(host) + host.priorityIndex = 0; + host.listIndex = zeroQueue.size - 1 + numHosts++ + minAvailableHost = 0 } override fun removeHost(host: HostView) { - TODO("Not yet implemented") + val priorityIdx = host.priorityIndex + val listIdx = host.listIndex + val chosenList = hostsQueue[priorityIdx] + + if (chosenList.size == 1) { + chosenList.removeLast() + if (listIdx == minAvailableHost) { + for (i in minAvailableHost + 1..hostsQueue.lastIndex) { + if (hostsQueue[i].size > 0) { + minAvailableHost = i + break + } + } + } + } else { + val lastItem = chosenList.removeLast() + chosenList[listIdx] = lastItem + lastItem.listIndex = listIdx + } + numHosts-- } override fun updateHost(host: HostView) { - TODO("Not yet implemented") + // No-op + } override fun setHostEmpty(hostView: HostView) { - TODO("Not yet implemented") + // No-op } override fun select(iter: MutableIterator<SchedulingRequest>): SchedulingResult { - TODO("Not yet implemented") - // Here be the API calls using HTTP between the other OpenDC - // You need to specify how much time do you have to make the prediction between receiving a time and putting onto a host - return SchedulingResult(SchedulingResultType.EMPTY) + if (numHosts == 0) { + return SchedulingResult(SchedulingResultType.FAILURE) + } + + val maxIters = 10000 + var numIters = 0 + + var chosenList: MutableList<HostView>? = null + var chosenHost: HostView? = null + + var result: SchedulingResult? = null + taskloop@ for (req in iter) { + if (req.isCancelled) { + iter.remove() + continue + } + + numIters++ + if (numIters > maxIters) { + return SchedulingResult(SchedulingResultType.EMPTY) + } + + for (chosenListIndex in minAvailableHost until hostsQueue.size) { + chosenList = hostsQueue[chosenListIndex] + for (host in chosenList) { + // Here be filtering, but for now we remove it completely. + iter.remove() + chosenHost = host + result = SchedulingResult(SchedulingResultType.SUCCESS, host, req) + break@taskloop + } + } + req.timesSkipped++ + } + + if (result == null) return SchedulingResult(SchedulingResultType.EMPTY) // No tasks to schedule that fit + + // Bookkeeping to maintain the calendar priority queue + if (chosenList!!.size == 1) { + chosenList.removeLast() + minAvailableHost++ + } else { + val listIdx = chosenHost!!.listIndex + // Not using removeLast here as it would cause problems during swapping + // if chosenHost is lastItem + val lastItem = chosenList.last() + chosenList[listIdx] = lastItem + lastItem.listIndex = listIdx + chosenList.removeLast() + } + + val nextList = hostsQueue[chosenHost!!.priorityIndex + 1] + nextList.add(chosenHost) + chosenHost.priorityIndex++ + chosenHost.listIndex = nextList.size - 1 + + return result } override fun removeTask( task: ServiceTask, - host: HostView?, + host: HostView? ) { - TODO("Not yet implemented") + if (host == null) return + + val priorityIdx = host.priorityIndex + val listIdx = host.listIndex + val chosenList = hostsQueue[priorityIdx] + val nextList = hostsQueue[priorityIdx - 1] + + if (chosenList.size == 1) { + chosenList.removeLast() + } else { + val lastItem = chosenList.last() + chosenList[listIdx] = lastItem + lastItem.listIndex = listIdx + chosenList.removeLast() + } + + nextList.add(host) + host.priorityIndex-- + host.listIndex = nextList.size - 1 + if (priorityIdx == minAvailableHost) { + minAvailableHost-- + } } + } diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/KafkaComputeMonitor.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/KafkaComputeMonitor.kt index ddd4a28a..d158f782 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/KafkaComputeMonitor.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/telemetry/KafkaComputeMonitor.kt @@ -51,7 +51,6 @@ public class KafkaComputeMonitor : ComputeMonitor { .setDowntime(reader.downtime.toDouble()) .build() this.send(packet) - } catch (e: Exception) { println("${e.message}") } diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/ExperimentSpec.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/ExperimentSpec.kt index 71ab4002..e3497cc4 100644 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/ExperimentSpec.kt +++ b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/ExperimentSpec.kt @@ -40,6 +40,11 @@ import java.util.UUID * @property initialSeed * @property runs * be included in the output files. + * + * The allocation policy is hardcoded here regardless of the input in experiemnt.json. + * I did not design this, it was like that before. + * + * @author Mateusz Kwiatkowski */ @Serializable @@ -50,7 +55,7 @@ public data class ExperimentSpec( val runs: Int = 1, val topologies: Set<ScenarioTopologySpec>, val workloads: Set<WorkloadSpec>, - val allocationPolicies: Set<AllocationPolicySpec> = setOf(PrefabAllocationPolicySpec(ComputeSchedulerEnum.Mem)), + val allocationPolicies: Set<AllocationPolicySpec> = setOf(PrefabAllocationPolicySpec(ComputeSchedulerEnum.Smart)), val failureModels: Set<FailureModelSpec?> = setOf(null), val maxNumFailures: Set<Int> = setOf(10), val checkpointModels: Set<CheckpointModelSpec?> = setOf(null), diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt index afe15032..3972b53f 100644 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt +++ b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt @@ -41,10 +41,14 @@ import kotlin.coroutines.CoroutineContext @Serializable public sealed interface AllocationPolicySpec +/* This has to be changed in order to enforce the scheduler policy to Smart. + * + * @author: Mateusz Kwiatkowski + */ @Serializable @SerialName("prefab") public data class PrefabAllocationPolicySpec( - val policyName: ComputeSchedulerEnum = ComputeSchedulerEnum.Mem, + val policyName: ComputeSchedulerEnum = ComputeSchedulerEnum.Smart, ) : AllocationPolicySpec { public val name: String = policyName.toString() } diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/runner/ExperimentCli.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/runner/ExperimentCli.kt index 55aed21b..0e190df0 100644 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/runner/ExperimentCli.kt +++ b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/runner/ExperimentCli.kt @@ -37,8 +37,7 @@ import java.io.IOException * Main entrypoint of the application. */ public fun main(args: Array<String>) { - if(args.size == 2) ExperimentCommand().main(args) - else ExperimentListener().main(args) + ExperimentCommand().main(args) } internal class ExperimentCommand : CliktCommand(name = "experiment") { @@ -56,17 +55,3 @@ internal class ExperimentCommand : CliktCommand(name = "experiment") { } } } -/** - * Entry point to the digital twin. - * - * @author Mateusz Kwiatkowski - */ -internal class ExperimentListener: CliktCommand(name = "listener") { - override fun run() { - try { - runListener() - } catch (e: IOException) { - println("${e.message}") - } - } -} diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/runner/ExperimentListener.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/runner/ExperimentListener.kt deleted file mode 100644 index c221543d..00000000 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/runner/ExperimentListener.kt +++ /dev/null @@ -1,20 +0,0 @@ -package org.opendc.experiments.base.runner - -import org.opendc.common.utils.JavalinRunner -import org.opendc.common.utils.PostgresqlDB -import org.opendc.common.utils.Redis - -/** - * Established a connection with PostgreSQL. - * Creates a Javalin HTTP server and listens for requests. - * - * @author Mateusz Kwiatkowski - * - * @see <a href=https://javalin.io/documentation>https://javalin.io/documentation</a> - */ -public fun runListener() { - PostgresqlDB() - val redisClient = Redis.getInstance() - redisClient?.readOne() - JavalinRunner() -} diff --git a/output/greenifier-demo-scaling/trackr.json b/output/greenifier-demo-scaling/trackr.json index f2eb187e..1633d1fe 100644 --- a/output/greenifier-demo-scaling/trackr.json +++ b/output/greenifier-demo-scaling/trackr.json @@ -7,6 +7,9 @@ "pathToFile": "resources/workloads/surf_month", "type": "ComputeWorkload" }, + "allocationPolicy": { + "type": "prefab" + }, "exportModel": { "exportInterval": 3600, "filesToExportDict": { |
