diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2018-02-13 14:27:15 +0100 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2018-02-13 14:27:15 +0100 |
| commit | 2e819d59934b5308bc58d6c69709112e2a6af402 (patch) | |
| tree | 320532fb50b0f20ac8bb4976b2825f8003aa3f85 /opendc-model-odc/jpa | |
| parent | 407877ff24d3c54747c8b15bba73b93b38c8b6e7 (diff) | |
refactor(#18): Fix OpenDC model deployment
This change fixes the deployment of the OpenDC simulation model.
Diffstat (limited to 'opendc-model-odc/jpa')
| -rw-r--r-- | opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/JpaBootstrap.kt | 7 | ||||
| -rw-r--r-- | opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaExperiment.kt | 24 |
2 files changed, 18 insertions, 13 deletions
diff --git a/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/JpaBootstrap.kt b/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/JpaBootstrap.kt index 09d8f4b3..8c32c54d 100644 --- a/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/JpaBootstrap.kt +++ b/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/JpaBootstrap.kt @@ -5,6 +5,7 @@ import com.atlarge.opendc.model.odc.integration.jpa.schema.Task import com.atlarge.opendc.model.odc.topology.JpaTopologyFactory import com.atlarge.opendc.model.topology.bootstrap import com.atlarge.opendc.simulator.Bootstrap +import mu.KotlinLogging /** * A [Bootstrap] procedure for experiments retrieved from a JPA data store. @@ -13,6 +14,11 @@ import com.atlarge.opendc.simulator.Bootstrap */ class JpaBootstrap(val experiment: Experiment) : Bootstrap<JpaModel> { /** + * The logging instance. + */ + private val logger = KotlinLogging.logger {} + + /** * Bootstrap a model `M` for a kernel in the given context. * * @param context The context to bootstrap to model in. @@ -35,6 +41,7 @@ class JpaBootstrap(val experiment: Experiment) : Bootstrap<JpaModel> { // Schedule all messages in the trace tasks.forEach { task -> if (task is Task) { + logger.info { "Scheduling $task" } context.schedule(task, section.datacenter, delay = task.startTime) } } diff --git a/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaExperiment.kt b/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaExperiment.kt index 6c3ad5e8..74f96ccb 100644 --- a/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaExperiment.kt +++ b/opendc-model-odc/jpa/src/main/kotlin/com/atlarge/opendc/model/odc/platform/JpaExperiment.kt @@ -115,22 +115,20 @@ class JpaExperiment(private val manager: EntityManager, manager.persist(wrapped) } - trace.jobs.asSequence() - .flatMap { it.tasks.asSequence() } - .forEach { task -> - val state = InternalTaskState(0, - task as com.atlarge.opendc.model.odc.integration.jpa.schema.Task, - experiment, - simulation.time, - task.remaining.toInt(), - 1 - ) - manager.persist(state) - } + tasks.forEach { task -> + val state = InternalTaskState(0, + task as com.atlarge.opendc.model.odc.integration.jpa.schema.Task, + experiment, + simulation.time, + task.remaining.toInt(), + 1 + ) + manager.persist(state) + } } // Run next simulation cycle - simulation.run(simulation.time + 1) + simulation.step() } // Set the experiment state |
