From b1c4d1f94e35445bdba5a56b614d0ec28a332624 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 11 Jan 2018 16:27:05 +0100 Subject: refactor(#18): Redesign core simulation API This change contains the redesign of the core simulation API and provides a cleaner interface for developing simulation models for the users. --- opendc-model-odc/setup/Dockerfile | 30 ++++++++ opendc-model-odc/setup/build.gradle | 87 ++++++++++++++++++++++ .../src/main/kotlin/platform/JpaPlatformRunner.kt | 66 ++++++++++++++++ .../src/main/resources/META-INF/persistence.xml | 41 ++++++++++ 4 files changed, 224 insertions(+) create mode 100644 opendc-model-odc/setup/Dockerfile create mode 100644 opendc-model-odc/setup/build.gradle create mode 100644 opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt create mode 100644 opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml (limited to 'opendc-model-odc/setup') diff --git a/opendc-model-odc/setup/Dockerfile b/opendc-model-odc/setup/Dockerfile new file mode 100644 index 00000000..70e6fe11 --- /dev/null +++ b/opendc-model-odc/setup/Dockerfile @@ -0,0 +1,30 @@ +# Docker mysql image for the OpenDC simulator project +# This image requires the context to be set to the root directory of the project in order to correctly build. +FROM gradle:alpine +MAINTAINER Fabian Mastenbroek + +# Set the home directory to our gradle user's home. +ENV HOME=/home/gradle +ENV APP_HOME=$HOME/simulator + +# Copy OpenDC simulator +COPY ./ $APP_HOME + +# Build as root +USER root + +# Set the working directory to the simulator +WORKDIR $APP_HOME + +# Build the application +RUN gradle --no-daemon :opendc-model-odc:setup:installDist + +# Fix permissions +RUN chown -R gradle:gradle $APP_HOME + +# Downgrade user +USER gradle + +# Start the Gradle application on run +CMD opendc-odc-model/setup/build/install/setup/bin/setup + diff --git a/opendc-model-odc/setup/build.gradle b/opendc-model-odc/setup/build.gradle new file mode 100644 index 00000000..042b8f37 --- /dev/null +++ b/opendc-model-odc/setup/build.gradle @@ -0,0 +1,87 @@ +/* + * MIT License + * + * Copyright (c) 2017 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. + */ + +/* Build configuration */ +buildscript { + ext.kotlin_version = '1.2.10' + ext.dokka_version = '0.9.15' + + repositories { + mavenCentral() + jcenter() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version" + classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" + } +} + +apply plugin: 'java' +apply plugin: 'application' +apply plugin: 'kotlin' +apply plugin: 'org.jetbrains.dokka' + +mainClassName = "nl.atlarge.opendc.model.odc.platform.JpaPlatformRunnerKt" + +compileKotlin { + kotlinOptions { + jvmTarget = "1.8" + } +} + +compileTestKotlin { + kotlinOptions { + jvmTarget = "1.8" + } +} + +kotlin { + experimental { + coroutines 'enable' + } +} + +dokka { + outputFormat = 'html' + outputDirectory = "$buildDir/javadoc" +} + +/* Project configuration */ +group 'com.atlarge.opendc' +version '1.1' + +repositories { + jcenter() +} + +dependencies { + compile project(':opendc-model-odc:jpa') + compile project(':opendc-kernel-omega') + + runtime 'org.slf4j:slf4j-simple:1.7.25' + runtime 'org.hibernate:hibernate-core:5.2.5.Final' + runtime 'mysql:mysql-connector-java:5.1.13' +} diff --git a/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt b/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt new file mode 100644 index 00000000..3f0fe589 --- /dev/null +++ b/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt @@ -0,0 +1,66 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 platform + +import com.atlarge.opendc.model.odc.platform.JpaExperimentManager +import com.atlarge.opendc.omega.OmegaKernelFactory +import mu.KotlinLogging +import java.util.concurrent.Executors +import javax.persistence.Persistence + +val logger = KotlinLogging.logger {} + +/** + * The main entry point of the program. This program polls experiments from a database and runs the + * simulation and reports the results back to the database. + * + * @param args The command line arguments of the program. + */ +fun main(args: Array) { + val properties = HashMap() + val env = System.getenv() + properties["javax.persistence.jdbc.url"] = env["PERSISTENCE_URL"] ?: "" + properties["javax.persistence.jdbc.user"] = env["PERSISTENCE_USER"] ?: "" + properties["javax.persistence.jdbc.password"] = env["PERSISTENCE_PASSWORD"] ?: "" + val factory = Persistence.createEntityManagerFactory("opendc-simulator", properties) + + val timeout = 10000L + val threads = 4 + val executorService = Executors.newFixedThreadPool(threads) + val experiments = JpaExperimentManager(factory) + val kernel = OmegaKernelFactory + + logger.info { "Waiting for enqueued experiments..." } + while (true) { + experiments.poll()?.let { experiment -> + logger.info { "Found experiment. Submitting for simulation now..." } + executorService.submit { + experiment.use { it.run(kernel, timeout) } + } + } + + Thread.sleep(500) + } +} diff --git a/opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml b/opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml new file mode 100644 index 00000000..0e40dc6e --- /dev/null +++ b/opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,41 @@ + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + jpa/schema.xml + + + + + + + + + -- cgit v1.2.3 From 67c8bc6cdd421262c4f59ce03506463a830af6e6 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 12 Feb 2018 14:02:21 +0100 Subject: refactor(#18): Update dependencies This change bumps the version of the dependencies used by the project. --- opendc-model-odc/setup/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'opendc-model-odc/setup') diff --git a/opendc-model-odc/setup/build.gradle b/opendc-model-odc/setup/build.gradle index 042b8f37..3962018e 100644 --- a/opendc-model-odc/setup/build.gradle +++ b/opendc-model-odc/setup/build.gradle @@ -24,7 +24,7 @@ /* Build configuration */ buildscript { - ext.kotlin_version = '1.2.10' + ext.kotlin_version = '1.2.21' ext.dokka_version = '0.9.15' repositories { -- cgit v1.2.3 From e97d9bf3f2cccf19a21631e26d55d60c9f4d7c7a Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 12 Feb 2018 14:26:44 +0100 Subject: refactor(#18): Align formatting with official Kotlin Style Guide This change aligns the code formatting of the project with the official Kotlin Style Guide. They can be found at http://kotlinlang.org/docs/reference/coding-conventions.html. --- opendc-model-odc/setup/build.gradle | 56 +++++++++++----------- .../src/main/kotlin/platform/JpaPlatformRunner.kt | 42 ++++++++-------- .../src/main/resources/META-INF/persistence.xml | 30 ++++++------ 3 files changed, 64 insertions(+), 64 deletions(-) (limited to 'opendc-model-odc/setup') diff --git a/opendc-model-odc/setup/build.gradle b/opendc-model-odc/setup/build.gradle index 3962018e..ddb5860b 100644 --- a/opendc-model-odc/setup/build.gradle +++ b/opendc-model-odc/setup/build.gradle @@ -24,19 +24,19 @@ /* Build configuration */ buildscript { - ext.kotlin_version = '1.2.21' - ext.dokka_version = '0.9.15' + ext.kotlin_version = '1.2.21' + ext.dokka_version = '0.9.15' - repositories { - mavenCentral() - jcenter() - } + repositories { + mavenCentral() + jcenter() + } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" - } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version" + classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" + } } apply plugin: 'java' @@ -47,26 +47,26 @@ apply plugin: 'org.jetbrains.dokka' mainClassName = "nl.atlarge.opendc.model.odc.platform.JpaPlatformRunnerKt" compileKotlin { - kotlinOptions { - jvmTarget = "1.8" - } + kotlinOptions { + jvmTarget = "1.8" + } } compileTestKotlin { - kotlinOptions { - jvmTarget = "1.8" - } + kotlinOptions { + jvmTarget = "1.8" + } } kotlin { - experimental { - coroutines 'enable' - } + experimental { + coroutines 'enable' + } } dokka { - outputFormat = 'html' - outputDirectory = "$buildDir/javadoc" + outputFormat = 'html' + outputDirectory = "$buildDir/javadoc" } /* Project configuration */ @@ -74,14 +74,14 @@ group 'com.atlarge.opendc' version '1.1' repositories { - jcenter() + jcenter() } dependencies { - compile project(':opendc-model-odc:jpa') - compile project(':opendc-kernel-omega') + compile project(':opendc-model-odc:jpa') + compile project(':opendc-kernel-omega') - runtime 'org.slf4j:slf4j-simple:1.7.25' - runtime 'org.hibernate:hibernate-core:5.2.5.Final' - runtime 'mysql:mysql-connector-java:5.1.13' + runtime 'org.slf4j:slf4j-simple:1.7.25' + runtime 'org.hibernate:hibernate-core:5.2.5.Final' + runtime 'mysql:mysql-connector-java:5.1.13' } diff --git a/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt b/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt index 3f0fe589..8fe49844 100644 --- a/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt +++ b/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt @@ -39,28 +39,28 @@ val logger = KotlinLogging.logger {} * @param args The command line arguments of the program. */ fun main(args: Array) { - val properties = HashMap() - val env = System.getenv() - properties["javax.persistence.jdbc.url"] = env["PERSISTENCE_URL"] ?: "" - properties["javax.persistence.jdbc.user"] = env["PERSISTENCE_USER"] ?: "" - properties["javax.persistence.jdbc.password"] = env["PERSISTENCE_PASSWORD"] ?: "" - val factory = Persistence.createEntityManagerFactory("opendc-simulator", properties) + val properties = HashMap() + val env = System.getenv() + properties["javax.persistence.jdbc.url"] = env["PERSISTENCE_URL"] ?: "" + properties["javax.persistence.jdbc.user"] = env["PERSISTENCE_USER"] ?: "" + properties["javax.persistence.jdbc.password"] = env["PERSISTENCE_PASSWORD"] ?: "" + val factory = Persistence.createEntityManagerFactory("opendc-simulator", properties) - val timeout = 10000L - val threads = 4 - val executorService = Executors.newFixedThreadPool(threads) - val experiments = JpaExperimentManager(factory) - val kernel = OmegaKernelFactory + val timeout = 10000L + val threads = 4 + val executorService = Executors.newFixedThreadPool(threads) + val experiments = JpaExperimentManager(factory) + val kernel = OmegaKernelFactory - logger.info { "Waiting for enqueued experiments..." } - while (true) { - experiments.poll()?.let { experiment -> - logger.info { "Found experiment. Submitting for simulation now..." } - executorService.submit { - experiment.use { it.run(kernel, timeout) } - } - } + logger.info { "Waiting for enqueued experiments..." } + while (true) { + experiments.poll()?.let { experiment -> + logger.info { "Found experiment. Submitting for simulation now..." } + executorService.submit { + experiment.use { it.run(kernel, timeout) } + } + } - Thread.sleep(500) - } + Thread.sleep(500) + } } diff --git a/opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml b/opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml index 0e40dc6e..4c4e6ac7 100644 --- a/opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml +++ b/opendc-model-odc/setup/src/main/resources/META-INF/persistence.xml @@ -23,19 +23,19 @@ ~ SOFTWARE. --> - - - org.hibernate.jpa.HibernatePersistenceProvider - jpa/schema.xml - - - - - - - - + + + org.hibernate.jpa.HibernatePersistenceProvider + jpa/schema.xml + + + + + + + + -- cgit v1.2.3 From 2e819d59934b5308bc58d6c69709112e2a6af402 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 13 Feb 2018 14:27:15 +0100 Subject: refactor(#18): Fix OpenDC model deployment This change fixes the deployment of the OpenDC simulation model. --- opendc-model-odc/setup/Dockerfile | 5 +- opendc-model-odc/setup/build.gradle | 2 +- .../opendc/model/odc/platform/JpaPlatformRunner.kt | 66 ++++++++++++++++++++++ .../src/main/kotlin/platform/JpaPlatformRunner.kt | 66 ---------------------- 4 files changed, 69 insertions(+), 70 deletions(-) create mode 100644 opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt delete mode 100644 opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt (limited to 'opendc-model-odc/setup') diff --git a/opendc-model-odc/setup/Dockerfile b/opendc-model-odc/setup/Dockerfile index 70e6fe11..bfebc044 100644 --- a/opendc-model-odc/setup/Dockerfile +++ b/opendc-model-odc/setup/Dockerfile @@ -17,7 +17,7 @@ USER root WORKDIR $APP_HOME # Build the application -RUN gradle --no-daemon :opendc-model-odc:setup:installDist +RUN gradle --no-daemon assemble installDist # Fix permissions RUN chown -R gradle:gradle $APP_HOME @@ -26,5 +26,4 @@ RUN chown -R gradle:gradle $APP_HOME USER gradle # Start the Gradle application on run -CMD opendc-odc-model/setup/build/install/setup/bin/setup - +CMD opendc-model-odc/setup/build/install/setup/bin/setup diff --git a/opendc-model-odc/setup/build.gradle b/opendc-model-odc/setup/build.gradle index ddb5860b..1cca2a6e 100644 --- a/opendc-model-odc/setup/build.gradle +++ b/opendc-model-odc/setup/build.gradle @@ -44,7 +44,7 @@ apply plugin: 'application' apply plugin: 'kotlin' apply plugin: 'org.jetbrains.dokka' -mainClassName = "nl.atlarge.opendc.model.odc.platform.JpaPlatformRunnerKt" +mainClassName = "com.atlarge.opendc.model.odc.platform.JpaPlatformRunnerKt" compileKotlin { kotlinOptions { diff --git a/opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt b/opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt new file mode 100644 index 00000000..eb819a5b --- /dev/null +++ b/opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt @@ -0,0 +1,66 @@ +/* + * MIT License + * + * Copyright (c) 2017 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 com.atlarge.opendc.model.odc.platform + +import com.atlarge.opendc.model.odc.platform.JpaExperimentManager +import com.atlarge.opendc.omega.OmegaKernelFactory +import mu.KotlinLogging +import java.util.concurrent.Executors +import javax.persistence.Persistence + +val logger = KotlinLogging.logger {} + +/** + * The main entry point of the program. This program polls experiments from a database and runs the + * simulation and reports the results back to the database. + * + * @param args The command line arguments of the program. + */ +fun main(args: Array) { + val properties = HashMap() + val env = System.getenv() + properties["javax.persistence.jdbc.url"] = env["PERSISTENCE_URL"] ?: "" + properties["javax.persistence.jdbc.user"] = env["PERSISTENCE_USER"] ?: "" + properties["javax.persistence.jdbc.password"] = env["PERSISTENCE_PASSWORD"] ?: "" + val factory = Persistence.createEntityManagerFactory("opendc-simulator", properties) + + val timeout = 10000L + val threads = 4 + val executorService = Executors.newFixedThreadPool(threads) + val experiments = JpaExperimentManager(factory) + val kernel = OmegaKernelFactory + + logger.info { "Waiting for enqueued experiments..." } + while (true) { + experiments.poll()?.let { experiment -> + logger.info { "Found experiment. Submitting for simulation now..." } + executorService.submit { + experiment.use { it.run(kernel, timeout) } + } + } + + Thread.sleep(500) + } +} diff --git a/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt b/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt deleted file mode 100644 index 8fe49844..00000000 --- a/opendc-model-odc/setup/src/main/kotlin/platform/JpaPlatformRunner.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 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 platform - -import com.atlarge.opendc.model.odc.platform.JpaExperimentManager -import com.atlarge.opendc.omega.OmegaKernelFactory -import mu.KotlinLogging -import java.util.concurrent.Executors -import javax.persistence.Persistence - -val logger = KotlinLogging.logger {} - -/** - * The main entry point of the program. This program polls experiments from a database and runs the - * simulation and reports the results back to the database. - * - * @param args The command line arguments of the program. - */ -fun main(args: Array) { - val properties = HashMap() - val env = System.getenv() - properties["javax.persistence.jdbc.url"] = env["PERSISTENCE_URL"] ?: "" - properties["javax.persistence.jdbc.user"] = env["PERSISTENCE_USER"] ?: "" - properties["javax.persistence.jdbc.password"] = env["PERSISTENCE_PASSWORD"] ?: "" - val factory = Persistence.createEntityManagerFactory("opendc-simulator", properties) - - val timeout = 10000L - val threads = 4 - val executorService = Executors.newFixedThreadPool(threads) - val experiments = JpaExperimentManager(factory) - val kernel = OmegaKernelFactory - - logger.info { "Waiting for enqueued experiments..." } - while (true) { - experiments.poll()?.let { experiment -> - logger.info { "Found experiment. Submitting for simulation now..." } - executorService.submit { - experiment.use { it.run(kernel, timeout) } - } - } - - Thread.sleep(500) - } -} -- cgit v1.2.3 From 157d30beb52c75831e29a1a22c199b95d6d30b42 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 14 Feb 2018 12:32:57 +0100 Subject: refactor(#18): Create distinction between kernel and simulation This change creates a distinction between a kernel and a simulation. A single simulation is represented by a `Simulation` object which provides control over the simulation, while the `Kernel` interface allows users to create a new simulation using that kernel as backend. --- .../com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'opendc-model-odc/setup') diff --git a/opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt b/opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt index eb819a5b..13f322bc 100644 --- a/opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt +++ b/opendc-model-odc/setup/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaPlatformRunner.kt @@ -24,8 +24,7 @@ package com.atlarge.opendc.model.odc.platform -import com.atlarge.opendc.model.odc.platform.JpaExperimentManager -import com.atlarge.opendc.omega.OmegaKernelFactory +import com.atlarge.opendc.omega.OmegaKernel import mu.KotlinLogging import java.util.concurrent.Executors import javax.persistence.Persistence @@ -50,7 +49,7 @@ fun main(args: Array) { val threads = 4 val executorService = Executors.newFixedThreadPool(threads) val experiments = JpaExperimentManager(factory) - val kernel = OmegaKernelFactory + val kernel = OmegaKernel logger.info { "Waiting for enqueued experiments..." } while (true) { -- cgit v1.2.3